babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /** Associative array from JSON sprite data file */
  11559. private _cellData;
  11560. /** Array of sprite names from JSON sprite data file */
  11561. private _spriteMap;
  11562. /** True when packed cell data from JSON file is ready*/
  11563. private _packedAndReady;
  11564. /**
  11565. * An event triggered when the manager is disposed.
  11566. */
  11567. onDisposeObservable: Observable<SpriteManager>;
  11568. private _onDisposeObserver;
  11569. /**
  11570. * Callback called when the manager is disposed
  11571. */
  11572. onDispose: () => void;
  11573. private _capacity;
  11574. private _fromPacked;
  11575. private _spriteTexture;
  11576. private _epsilon;
  11577. private _scene;
  11578. private _vertexData;
  11579. private _buffer;
  11580. private _vertexBuffers;
  11581. private _indexBuffer;
  11582. private _effectBase;
  11583. private _effectFog;
  11584. /**
  11585. * Gets or sets the spritesheet texture
  11586. */
  11587. texture: Texture;
  11588. /**
  11589. * Creates a new sprite manager
  11590. * @param name defines the manager's name
  11591. * @param imgUrl defines the sprite sheet url
  11592. * @param capacity defines the maximum allowed number of sprites
  11593. * @param cellSize defines the size of a sprite cell
  11594. * @param scene defines the hosting scene
  11595. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11596. * @param samplingMode defines the smapling mode to use with spritesheet
  11597. * @param fromPacked set to false; do not alter
  11598. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11599. */
  11600. constructor(
  11601. /** defines the manager's name */
  11602. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11603. private _makePacked;
  11604. private _appendSpriteVertex;
  11605. /**
  11606. * Intersects the sprites with a ray
  11607. * @param ray defines the ray to intersect with
  11608. * @param camera defines the current active camera
  11609. * @param predicate defines a predicate used to select candidate sprites
  11610. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11611. * @returns null if no hit or a PickingInfo
  11612. */
  11613. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11614. /**
  11615. * Render all child sprites
  11616. */
  11617. render(): void;
  11618. /**
  11619. * Release associated resources
  11620. */
  11621. dispose(): void;
  11622. }
  11623. }
  11624. declare module "babylonjs/Sprites/sprite" {
  11625. import { Vector3 } from "babylonjs/Maths/math.vector";
  11626. import { Nullable } from "babylonjs/types";
  11627. import { ActionManager } from "babylonjs/Actions/actionManager";
  11628. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11629. import { Color4 } from "babylonjs/Maths/math.color";
  11630. /**
  11631. * Class used to represent a sprite
  11632. * @see http://doc.babylonjs.com/babylon101/sprites
  11633. */
  11634. export class Sprite {
  11635. /** defines the name */
  11636. name: string;
  11637. /** Gets or sets the current world position */
  11638. position: Vector3;
  11639. /** Gets or sets the main color */
  11640. color: Color4;
  11641. /** Gets or sets the width */
  11642. width: number;
  11643. /** Gets or sets the height */
  11644. height: number;
  11645. /** Gets or sets rotation angle */
  11646. angle: number;
  11647. /** Gets or sets the cell index in the sprite sheet */
  11648. cellIndex: number;
  11649. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11650. cellRef: string;
  11651. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11652. invertU: number;
  11653. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11654. invertV: number;
  11655. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11656. disposeWhenFinishedAnimating: boolean;
  11657. /** Gets the list of attached animations */
  11658. animations: Animation[];
  11659. /** Gets or sets a boolean indicating if the sprite can be picked */
  11660. isPickable: boolean;
  11661. /**
  11662. * Gets or sets the associated action manager
  11663. */
  11664. actionManager: Nullable<ActionManager>;
  11665. private _animationStarted;
  11666. private _loopAnimation;
  11667. private _fromIndex;
  11668. private _toIndex;
  11669. private _delay;
  11670. private _direction;
  11671. private _manager;
  11672. private _time;
  11673. private _onAnimationEnd;
  11674. /**
  11675. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11676. */
  11677. isVisible: boolean;
  11678. /**
  11679. * Gets or sets the sprite size
  11680. */
  11681. size: number;
  11682. /**
  11683. * Creates a new Sprite
  11684. * @param name defines the name
  11685. * @param manager defines the manager
  11686. */
  11687. constructor(
  11688. /** defines the name */
  11689. name: string, manager: ISpriteManager);
  11690. /**
  11691. * Starts an animation
  11692. * @param from defines the initial key
  11693. * @param to defines the end key
  11694. * @param loop defines if the animation must loop
  11695. * @param delay defines the start delay (in ms)
  11696. * @param onAnimationEnd defines a callback to call when animation ends
  11697. */
  11698. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11699. /** Stops current animation (if any) */
  11700. stopAnimation(): void;
  11701. /** @hidden */
  11702. _animate(deltaTime: number): void;
  11703. /** Release associated resources */
  11704. dispose(): void;
  11705. }
  11706. }
  11707. declare module "babylonjs/Collisions/pickingInfo" {
  11708. import { Nullable } from "babylonjs/types";
  11709. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11711. import { Sprite } from "babylonjs/Sprites/sprite";
  11712. import { Ray } from "babylonjs/Culling/ray";
  11713. /**
  11714. * Information about the result of picking within a scene
  11715. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11716. */
  11717. export class PickingInfo {
  11718. /** @hidden */
  11719. _pickingUnavailable: boolean;
  11720. /**
  11721. * If the pick collided with an object
  11722. */
  11723. hit: boolean;
  11724. /**
  11725. * Distance away where the pick collided
  11726. */
  11727. distance: number;
  11728. /**
  11729. * The location of pick collision
  11730. */
  11731. pickedPoint: Nullable<Vector3>;
  11732. /**
  11733. * The mesh corresponding the the pick collision
  11734. */
  11735. pickedMesh: Nullable<AbstractMesh>;
  11736. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11737. bu: number;
  11738. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11739. bv: number;
  11740. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11741. faceId: number;
  11742. /** Id of the the submesh that was picked */
  11743. subMeshId: number;
  11744. /** If a sprite was picked, this will be the sprite the pick collided with */
  11745. pickedSprite: Nullable<Sprite>;
  11746. /**
  11747. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11748. */
  11749. originMesh: Nullable<AbstractMesh>;
  11750. /**
  11751. * The ray that was used to perform the picking.
  11752. */
  11753. ray: Nullable<Ray>;
  11754. /**
  11755. * Gets the normal correspodning to the face the pick collided with
  11756. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11757. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11758. * @returns The normal correspodning to the face the pick collided with
  11759. */
  11760. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11761. /**
  11762. * Gets the texture coordinates of where the pick occured
  11763. * @returns the vector containing the coordnates of the texture
  11764. */
  11765. getTextureCoordinates(): Nullable<Vector2>;
  11766. }
  11767. }
  11768. declare module "babylonjs/Events/pointerEvents" {
  11769. import { Nullable } from "babylonjs/types";
  11770. import { Vector2 } from "babylonjs/Maths/math.vector";
  11771. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11772. import { Ray } from "babylonjs/Culling/ray";
  11773. /**
  11774. * Gather the list of pointer event types as constants.
  11775. */
  11776. export class PointerEventTypes {
  11777. /**
  11778. * 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.
  11779. */
  11780. static readonly POINTERDOWN: number;
  11781. /**
  11782. * The pointerup event is fired when a pointer is no longer active.
  11783. */
  11784. static readonly POINTERUP: number;
  11785. /**
  11786. * The pointermove event is fired when a pointer changes coordinates.
  11787. */
  11788. static readonly POINTERMOVE: number;
  11789. /**
  11790. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11791. */
  11792. static readonly POINTERWHEEL: number;
  11793. /**
  11794. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11795. */
  11796. static readonly POINTERPICK: number;
  11797. /**
  11798. * The pointertap event is fired when a the object has been touched and released without drag.
  11799. */
  11800. static readonly POINTERTAP: number;
  11801. /**
  11802. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11803. */
  11804. static readonly POINTERDOUBLETAP: number;
  11805. }
  11806. /**
  11807. * Base class of pointer info types.
  11808. */
  11809. export class PointerInfoBase {
  11810. /**
  11811. * Defines the type of event (PointerEventTypes)
  11812. */
  11813. type: number;
  11814. /**
  11815. * Defines the related dom event
  11816. */
  11817. event: PointerEvent | MouseWheelEvent;
  11818. /**
  11819. * Instantiates the base class of pointers info.
  11820. * @param type Defines the type of event (PointerEventTypes)
  11821. * @param event Defines the related dom event
  11822. */
  11823. constructor(
  11824. /**
  11825. * Defines the type of event (PointerEventTypes)
  11826. */
  11827. type: number,
  11828. /**
  11829. * Defines the related dom event
  11830. */
  11831. event: PointerEvent | MouseWheelEvent);
  11832. }
  11833. /**
  11834. * This class is used to store pointer related info for the onPrePointerObservable event.
  11835. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11836. */
  11837. export class PointerInfoPre extends PointerInfoBase {
  11838. /**
  11839. * Ray from a pointer if availible (eg. 6dof controller)
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Defines the local position of the pointer on the canvas.
  11844. */
  11845. localPosition: Vector2;
  11846. /**
  11847. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11848. */
  11849. skipOnPointerObservable: boolean;
  11850. /**
  11851. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11852. * @param type Defines the type of event (PointerEventTypes)
  11853. * @param event Defines the related dom event
  11854. * @param localX Defines the local x coordinates of the pointer when the event occured
  11855. * @param localY Defines the local y coordinates of the pointer when the event occured
  11856. */
  11857. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11858. }
  11859. /**
  11860. * This type contains all the data related to a pointer event in Babylon.js.
  11861. * 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.
  11862. */
  11863. export class PointerInfo extends PointerInfoBase {
  11864. /**
  11865. * Defines the picking info associated to the info (if any)\
  11866. */
  11867. pickInfo: Nullable<PickingInfo>;
  11868. /**
  11869. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. * @param pickInfo Defines the picking info associated to the info (if any)\
  11873. */
  11874. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11875. /**
  11876. * Defines the picking info associated to the info (if any)\
  11877. */
  11878. pickInfo: Nullable<PickingInfo>);
  11879. }
  11880. /**
  11881. * Data relating to a touch event on the screen.
  11882. */
  11883. export interface PointerTouch {
  11884. /**
  11885. * X coordinate of touch.
  11886. */
  11887. x: number;
  11888. /**
  11889. * Y coordinate of touch.
  11890. */
  11891. y: number;
  11892. /**
  11893. * Id of touch. Unique for each finger.
  11894. */
  11895. pointerId: number;
  11896. /**
  11897. * Event type passed from DOM.
  11898. */
  11899. type: any;
  11900. }
  11901. }
  11902. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11903. import { Observable } from "babylonjs/Misc/observable";
  11904. import { Nullable } from "babylonjs/types";
  11905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11907. /**
  11908. * Manage the mouse inputs to control the movement of a free camera.
  11909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11910. */
  11911. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11912. /**
  11913. * Define if touch is enabled in the mouse input
  11914. */
  11915. touchEnabled: boolean;
  11916. /**
  11917. * Defines the camera the input is attached to.
  11918. */
  11919. camera: FreeCamera;
  11920. /**
  11921. * Defines the buttons associated with the input to handle camera move.
  11922. */
  11923. buttons: number[];
  11924. /**
  11925. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11926. */
  11927. angularSensibility: number;
  11928. private _pointerInput;
  11929. private _onMouseMove;
  11930. private _observer;
  11931. private previousPosition;
  11932. /**
  11933. * Observable for when a pointer move event occurs containing the move offset
  11934. */
  11935. onPointerMovedObservable: Observable<{
  11936. offsetX: number;
  11937. offsetY: number;
  11938. }>;
  11939. /**
  11940. * @hidden
  11941. * If the camera should be rotated automatically based on pointer movement
  11942. */
  11943. _allowCameraRotation: boolean;
  11944. /**
  11945. * Manage the mouse inputs to control the movement of a free camera.
  11946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11947. * @param touchEnabled Defines if touch is enabled or not
  11948. */
  11949. constructor(
  11950. /**
  11951. * Define if touch is enabled in the mouse input
  11952. */
  11953. touchEnabled?: boolean);
  11954. /**
  11955. * Attach the input controls to a specific dom element to get the input from.
  11956. * @param element Defines the element the controls should be listened from
  11957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11958. */
  11959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11960. /**
  11961. * Called on JS contextmenu event.
  11962. * Override this method to provide functionality.
  11963. */
  11964. protected onContextMenu(evt: PointerEvent): void;
  11965. /**
  11966. * Detach the current controls from the specified dom element.
  11967. * @param element Defines the element to stop listening the inputs from
  11968. */
  11969. detachControl(element: Nullable<HTMLElement>): void;
  11970. /**
  11971. * Gets the class name of the current intput.
  11972. * @returns the class name
  11973. */
  11974. getClassName(): string;
  11975. /**
  11976. * Get the friendly name associated with the input class.
  11977. * @returns the input friendly name
  11978. */
  11979. getSimpleName(): string;
  11980. }
  11981. }
  11982. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11983. import { Nullable } from "babylonjs/types";
  11984. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11985. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11986. /**
  11987. * Manage the touch inputs to control the movement of a free camera.
  11988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11989. */
  11990. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11991. /**
  11992. * Defines the camera the input is attached to.
  11993. */
  11994. camera: FreeCamera;
  11995. /**
  11996. * Defines the touch sensibility for rotation.
  11997. * The higher the faster.
  11998. */
  11999. touchAngularSensibility: number;
  12000. /**
  12001. * Defines the touch sensibility for move.
  12002. * The higher the faster.
  12003. */
  12004. touchMoveSensibility: number;
  12005. private _offsetX;
  12006. private _offsetY;
  12007. private _pointerPressed;
  12008. private _pointerInput;
  12009. private _observer;
  12010. private _onLostFocus;
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Detach the current controls from the specified dom element.
  12019. * @param element Defines the element to stop listening the inputs from
  12020. */
  12021. detachControl(element: Nullable<HTMLElement>): void;
  12022. /**
  12023. * Update the current camera state depending on the inputs that have been used this frame.
  12024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12025. */
  12026. checkInputs(): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12041. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12043. import { Nullable } from "babylonjs/types";
  12044. /**
  12045. * Default Inputs manager for the FreeCamera.
  12046. * It groups all the default supported inputs for ease of use.
  12047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12048. */
  12049. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12050. /**
  12051. * @hidden
  12052. */
  12053. _mouseInput: Nullable<FreeCameraMouseInput>;
  12054. /**
  12055. * Instantiates a new FreeCameraInputsManager.
  12056. * @param camera Defines the camera the inputs belong to
  12057. */
  12058. constructor(camera: FreeCamera);
  12059. /**
  12060. * Add keyboard input support to the input manager.
  12061. * @returns the current input manager
  12062. */
  12063. addKeyboard(): FreeCameraInputsManager;
  12064. /**
  12065. * Add mouse input support to the input manager.
  12066. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12067. * @returns the current input manager
  12068. */
  12069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12070. /**
  12071. * Removes the mouse input support from the manager
  12072. * @returns the current input manager
  12073. */
  12074. removeMouse(): FreeCameraInputsManager;
  12075. /**
  12076. * Add touch input support to the input manager.
  12077. * @returns the current input manager
  12078. */
  12079. addTouch(): FreeCameraInputsManager;
  12080. /**
  12081. * Remove all attached input methods from a camera
  12082. */
  12083. clear(): void;
  12084. }
  12085. }
  12086. declare module "babylonjs/Cameras/freeCamera" {
  12087. import { Vector3 } from "babylonjs/Maths/math.vector";
  12088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12089. import { Scene } from "babylonjs/scene";
  12090. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12091. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12092. /**
  12093. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12094. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12096. */
  12097. export class FreeCamera extends TargetCamera {
  12098. /**
  12099. * Define the collision ellipsoid of the camera.
  12100. * This is helpful to simulate a camera body like the player body around the camera
  12101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12102. */
  12103. ellipsoid: Vector3;
  12104. /**
  12105. * Define an offset for the position of the ellipsoid around the camera.
  12106. * This can be helpful to determine the center of the body near the gravity center of the body
  12107. * instead of its head.
  12108. */
  12109. ellipsoidOffset: Vector3;
  12110. /**
  12111. * Enable or disable collisions of the camera with the rest of the scene objects.
  12112. */
  12113. checkCollisions: boolean;
  12114. /**
  12115. * Enable or disable gravity on the camera.
  12116. */
  12117. applyGravity: boolean;
  12118. /**
  12119. * Define the input manager associated to the camera.
  12120. */
  12121. inputs: FreeCameraInputsManager;
  12122. /**
  12123. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12124. * Higher values reduce sensitivity.
  12125. */
  12126. /**
  12127. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12128. * Higher values reduce sensitivity.
  12129. */
  12130. angularSensibility: number;
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12133. */
  12134. keysUp: number[];
  12135. /**
  12136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12137. */
  12138. keysDown: number[];
  12139. /**
  12140. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12141. */
  12142. keysLeft: number[];
  12143. /**
  12144. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12145. */
  12146. keysRight: number[];
  12147. /**
  12148. * Event raised when the camera collide with a mesh in the scene.
  12149. */
  12150. onCollide: (collidedMesh: AbstractMesh) => void;
  12151. private _collider;
  12152. private _needMoveForGravity;
  12153. private _oldPosition;
  12154. private _diffPosition;
  12155. private _newPosition;
  12156. /** @hidden */
  12157. _localDirection: Vector3;
  12158. /** @hidden */
  12159. _transformedDirection: Vector3;
  12160. /**
  12161. * Instantiates a Free Camera.
  12162. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12163. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12165. * @param name Define the name of the camera in the scene
  12166. * @param position Define the start position of the camera in the scene
  12167. * @param scene Define the scene the camera belongs to
  12168. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12169. */
  12170. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12171. /**
  12172. * Attached controls to the current camera.
  12173. * @param element Defines the element the controls should be listened from
  12174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12175. */
  12176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12177. /**
  12178. * Detach the current controls from the camera.
  12179. * The camera will stop reacting to inputs.
  12180. * @param element Defines the element to stop listening the inputs from
  12181. */
  12182. detachControl(element: HTMLElement): void;
  12183. private _collisionMask;
  12184. /**
  12185. * Define a collision mask to limit the list of object the camera can collide with
  12186. */
  12187. collisionMask: number;
  12188. /** @hidden */
  12189. _collideWithWorld(displacement: Vector3): void;
  12190. private _onCollisionPositionChange;
  12191. /** @hidden */
  12192. _checkInputs(): void;
  12193. /** @hidden */
  12194. _decideIfNeedsToMove(): boolean;
  12195. /** @hidden */
  12196. _updatePosition(): void;
  12197. /**
  12198. * Destroy the camera and release the current resources hold by it.
  12199. */
  12200. dispose(): void;
  12201. /**
  12202. * Gets the current object class name.
  12203. * @return the class name
  12204. */
  12205. getClassName(): string;
  12206. }
  12207. }
  12208. declare module "babylonjs/Gamepads/gamepad" {
  12209. import { Observable } from "babylonjs/Misc/observable";
  12210. /**
  12211. * Represents a gamepad control stick position
  12212. */
  12213. export class StickValues {
  12214. /**
  12215. * The x component of the control stick
  12216. */
  12217. x: number;
  12218. /**
  12219. * The y component of the control stick
  12220. */
  12221. y: number;
  12222. /**
  12223. * Initializes the gamepad x and y control stick values
  12224. * @param x The x component of the gamepad control stick value
  12225. * @param y The y component of the gamepad control stick value
  12226. */
  12227. constructor(
  12228. /**
  12229. * The x component of the control stick
  12230. */
  12231. x: number,
  12232. /**
  12233. * The y component of the control stick
  12234. */
  12235. y: number);
  12236. }
  12237. /**
  12238. * An interface which manages callbacks for gamepad button changes
  12239. */
  12240. export interface GamepadButtonChanges {
  12241. /**
  12242. * Called when a gamepad has been changed
  12243. */
  12244. changed: boolean;
  12245. /**
  12246. * Called when a gamepad press event has been triggered
  12247. */
  12248. pressChanged: boolean;
  12249. /**
  12250. * Called when a touch event has been triggered
  12251. */
  12252. touchChanged: boolean;
  12253. /**
  12254. * Called when a value has changed
  12255. */
  12256. valueChanged: boolean;
  12257. }
  12258. /**
  12259. * Represents a gamepad
  12260. */
  12261. export class Gamepad {
  12262. /**
  12263. * The id of the gamepad
  12264. */
  12265. id: string;
  12266. /**
  12267. * The index of the gamepad
  12268. */
  12269. index: number;
  12270. /**
  12271. * The browser gamepad
  12272. */
  12273. browserGamepad: any;
  12274. /**
  12275. * Specifies what type of gamepad this represents
  12276. */
  12277. type: number;
  12278. private _leftStick;
  12279. private _rightStick;
  12280. /** @hidden */
  12281. _isConnected: boolean;
  12282. private _leftStickAxisX;
  12283. private _leftStickAxisY;
  12284. private _rightStickAxisX;
  12285. private _rightStickAxisY;
  12286. /**
  12287. * Triggered when the left control stick has been changed
  12288. */
  12289. private _onleftstickchanged;
  12290. /**
  12291. * Triggered when the right control stick has been changed
  12292. */
  12293. private _onrightstickchanged;
  12294. /**
  12295. * Represents a gamepad controller
  12296. */
  12297. static GAMEPAD: number;
  12298. /**
  12299. * Represents a generic controller
  12300. */
  12301. static GENERIC: number;
  12302. /**
  12303. * Represents an XBox controller
  12304. */
  12305. static XBOX: number;
  12306. /**
  12307. * Represents a pose-enabled controller
  12308. */
  12309. static POSE_ENABLED: number;
  12310. /**
  12311. * Represents an Dual Shock controller
  12312. */
  12313. static DUALSHOCK: number;
  12314. /**
  12315. * Specifies whether the left control stick should be Y-inverted
  12316. */
  12317. protected _invertLeftStickY: boolean;
  12318. /**
  12319. * Specifies if the gamepad has been connected
  12320. */
  12321. readonly isConnected: boolean;
  12322. /**
  12323. * Initializes the gamepad
  12324. * @param id The id of the gamepad
  12325. * @param index The index of the gamepad
  12326. * @param browserGamepad The browser gamepad
  12327. * @param leftStickX The x component of the left joystick
  12328. * @param leftStickY The y component of the left joystick
  12329. * @param rightStickX The x component of the right joystick
  12330. * @param rightStickY The y component of the right joystick
  12331. */
  12332. constructor(
  12333. /**
  12334. * The id of the gamepad
  12335. */
  12336. id: string,
  12337. /**
  12338. * The index of the gamepad
  12339. */
  12340. index: number,
  12341. /**
  12342. * The browser gamepad
  12343. */
  12344. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12345. /**
  12346. * Callback triggered when the left joystick has changed
  12347. * @param callback
  12348. */
  12349. onleftstickchanged(callback: (values: StickValues) => void): void;
  12350. /**
  12351. * Callback triggered when the right joystick has changed
  12352. * @param callback
  12353. */
  12354. onrightstickchanged(callback: (values: StickValues) => void): void;
  12355. /**
  12356. * Gets the left joystick
  12357. */
  12358. /**
  12359. * Sets the left joystick values
  12360. */
  12361. leftStick: StickValues;
  12362. /**
  12363. * Gets the right joystick
  12364. */
  12365. /**
  12366. * Sets the right joystick value
  12367. */
  12368. rightStick: StickValues;
  12369. /**
  12370. * Updates the gamepad joystick positions
  12371. */
  12372. update(): void;
  12373. /**
  12374. * Disposes the gamepad
  12375. */
  12376. dispose(): void;
  12377. }
  12378. /**
  12379. * Represents a generic gamepad
  12380. */
  12381. export class GenericPad extends Gamepad {
  12382. private _buttons;
  12383. private _onbuttondown;
  12384. private _onbuttonup;
  12385. /**
  12386. * Observable triggered when a button has been pressed
  12387. */
  12388. onButtonDownObservable: Observable<number>;
  12389. /**
  12390. * Observable triggered when a button has been released
  12391. */
  12392. onButtonUpObservable: Observable<number>;
  12393. /**
  12394. * Callback triggered when a button has been pressed
  12395. * @param callback Called when a button has been pressed
  12396. */
  12397. onbuttondown(callback: (buttonPressed: number) => void): void;
  12398. /**
  12399. * Callback triggered when a button has been released
  12400. * @param callback Called when a button has been released
  12401. */
  12402. onbuttonup(callback: (buttonReleased: number) => void): void;
  12403. /**
  12404. * Initializes the generic gamepad
  12405. * @param id The id of the generic gamepad
  12406. * @param index The index of the generic gamepad
  12407. * @param browserGamepad The browser gamepad
  12408. */
  12409. constructor(id: string, index: number, browserGamepad: any);
  12410. private _setButtonValue;
  12411. /**
  12412. * Updates the generic gamepad
  12413. */
  12414. update(): void;
  12415. /**
  12416. * Disposes the generic gamepad
  12417. */
  12418. dispose(): void;
  12419. }
  12420. }
  12421. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12422. import { Nullable } from "babylonjs/types";
  12423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12424. import { Scene } from "babylonjs/scene";
  12425. module "babylonjs/Engines/engine" {
  12426. interface Engine {
  12427. /**
  12428. * Creates a raw texture
  12429. * @param data defines the data to store in the texture
  12430. * @param width defines the width of the texture
  12431. * @param height defines the height of the texture
  12432. * @param format defines the format of the data
  12433. * @param generateMipMaps defines if the engine should generate the mip levels
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12436. * @param compression defines the compression used (null by default)
  12437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12438. * @returns the raw texture inside an InternalTexture
  12439. */
  12440. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12441. /**
  12442. * Update a raw texture
  12443. * @param texture defines the texture to update
  12444. * @param data defines the data to store in the texture
  12445. * @param format defines the format of the data
  12446. * @param invertY defines if data must be stored with Y axis inverted
  12447. */
  12448. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12449. /**
  12450. * Update a raw texture
  12451. * @param texture defines the texture to update
  12452. * @param data defines the data to store in the texture
  12453. * @param format defines the format of the data
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param compression defines the compression used (null by default)
  12456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12457. */
  12458. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12459. /**
  12460. * Creates a new raw cube texture
  12461. * @param data defines the array of data to use to create each face
  12462. * @param size defines the size of the textures
  12463. * @param format defines the format of the data
  12464. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12465. * @param generateMipMaps defines if the engine should generate the mip levels
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12468. * @param compression defines the compression used (null by default)
  12469. * @returns the cube texture as an InternalTexture
  12470. */
  12471. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12472. /**
  12473. * Update a raw cube texture
  12474. * @param texture defines the texture to udpdate
  12475. * @param data defines the data to store
  12476. * @param format defines the data format
  12477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12478. * @param invertY defines if data must be stored with Y axis inverted
  12479. */
  12480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12481. /**
  12482. * Update a raw cube texture
  12483. * @param texture defines the texture to udpdate
  12484. * @param data defines the data to store
  12485. * @param format defines the data format
  12486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12487. * @param invertY defines if data must be stored with Y axis inverted
  12488. * @param compression defines the compression used (null by default)
  12489. */
  12490. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12491. /**
  12492. * Update a raw cube texture
  12493. * @param texture defines the texture to udpdate
  12494. * @param data defines the data to store
  12495. * @param format defines the data format
  12496. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12497. * @param invertY defines if data must be stored with Y axis inverted
  12498. * @param compression defines the compression used (null by default)
  12499. * @param level defines which level of the texture to update
  12500. */
  12501. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12502. /**
  12503. * Creates a new raw cube texture from a specified url
  12504. * @param url defines the url where the data is located
  12505. * @param scene defines the current scene
  12506. * @param size defines the size of the textures
  12507. * @param format defines the format of the data
  12508. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12509. * @param noMipmap defines if the engine should avoid generating the mip levels
  12510. * @param callback defines a callback used to extract texture data from loaded data
  12511. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12512. * @param onLoad defines a callback called when texture is loaded
  12513. * @param onError defines a callback called if there is an error
  12514. * @returns the cube texture as an InternalTexture
  12515. */
  12516. 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;
  12517. /**
  12518. * Creates a new raw cube texture from a specified url
  12519. * @param url defines the url where the data is located
  12520. * @param scene defines the current scene
  12521. * @param size defines the size of the textures
  12522. * @param format defines the format of the data
  12523. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12524. * @param noMipmap defines if the engine should avoid generating the mip levels
  12525. * @param callback defines a callback used to extract texture data from loaded data
  12526. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12527. * @param onLoad defines a callback called when texture is loaded
  12528. * @param onError defines a callback called if there is an error
  12529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @returns the cube texture as an InternalTexture
  12532. */
  12533. 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;
  12534. /**
  12535. * Creates a new raw 3D texture
  12536. * @param data defines the data used to create the texture
  12537. * @param width defines the width of the texture
  12538. * @param height defines the height of the texture
  12539. * @param depth defines the depth of the texture
  12540. * @param format defines the format of the texture
  12541. * @param generateMipMaps defines if the engine must generate mip levels
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12544. * @param compression defines the compressed used (can be null)
  12545. * @param textureType defines the compressed used (can be null)
  12546. * @returns a new raw 3D texture (stored in an InternalTexture)
  12547. */
  12548. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12549. /**
  12550. * Update a raw 3D texture
  12551. * @param texture defines the texture to update
  12552. * @param data defines the data to store
  12553. * @param format defines the data format
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. */
  12556. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12557. /**
  12558. * Update a raw 3D texture
  12559. * @param texture defines the texture to update
  12560. * @param data defines the data to store
  12561. * @param format defines the data format
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param compression defines the used compression (can be null)
  12564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12565. */
  12566. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12567. }
  12568. }
  12569. }
  12570. declare module "babylonjs/Materials/Textures/rawTexture" {
  12571. import { Scene } from "babylonjs/scene";
  12572. import { Texture } from "babylonjs/Materials/Textures/texture";
  12573. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12574. /**
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. */
  12579. export class RawTexture extends Texture {
  12580. /**
  12581. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. */
  12583. format: number;
  12584. private _engine;
  12585. /**
  12586. * Instantiates a new RawTexture.
  12587. * Raw texture can help creating a texture directly from an array of data.
  12588. * This can be super useful if you either get the data from an uncompressed source or
  12589. * if you wish to create your texture pixel by pixel.
  12590. * @param data define the array of data to use to create the texture
  12591. * @param width define the width of the texture
  12592. * @param height define the height of the texture
  12593. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12594. * @param scene define the scene the texture belongs to
  12595. * @param generateMipMaps define whether mip maps should be generated or not
  12596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12599. */
  12600. constructor(data: ArrayBufferView, width: number, height: number,
  12601. /**
  12602. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12603. */
  12604. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12605. /**
  12606. * Updates the texture underlying data.
  12607. * @param data Define the new data of the texture
  12608. */
  12609. update(data: ArrayBufferView): void;
  12610. /**
  12611. * Creates a luminance texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance texture
  12620. */
  12621. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates a luminance alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the luminance alpha texture
  12632. */
  12633. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates an alpha texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @returns the alpha texture
  12644. */
  12645. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12646. /**
  12647. * Creates a RGB texture from some data.
  12648. * @param data Define the texture data
  12649. * @param width Define the width of the texture
  12650. * @param height Define the height of the texture
  12651. * @param scene Define the scene the texture belongs to
  12652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. * @returns the RGB alpha texture
  12657. */
  12658. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12659. /**
  12660. * Creates a RGBA texture from some data.
  12661. * @param data Define the texture data
  12662. * @param width Define the width of the texture
  12663. * @param height Define the height of the texture
  12664. * @param scene Define the scene the texture belongs to
  12665. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12668. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12669. * @returns the RGBA texture
  12670. */
  12671. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12672. /**
  12673. * Creates a R texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12682. * @returns the R texture
  12683. */
  12684. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12685. }
  12686. }
  12687. declare module "babylonjs/Maths/math.size" {
  12688. /**
  12689. * Interface for the size containing width and height
  12690. */
  12691. export interface ISize {
  12692. /**
  12693. * Width
  12694. */
  12695. width: number;
  12696. /**
  12697. * Heighht
  12698. */
  12699. height: number;
  12700. }
  12701. /**
  12702. * Size containing widht and height
  12703. */
  12704. export class Size implements ISize {
  12705. /**
  12706. * Width
  12707. */
  12708. width: number;
  12709. /**
  12710. * Height
  12711. */
  12712. height: number;
  12713. /**
  12714. * Creates a Size object from the given width and height (floats).
  12715. * @param width width of the new size
  12716. * @param height height of the new size
  12717. */
  12718. constructor(width: number, height: number);
  12719. /**
  12720. * Returns a string with the Size width and height
  12721. * @returns a string with the Size width and height
  12722. */
  12723. toString(): string;
  12724. /**
  12725. * "Size"
  12726. * @returns the string "Size"
  12727. */
  12728. getClassName(): string;
  12729. /**
  12730. * Returns the Size hash code.
  12731. * @returns a hash code for a unique width and height
  12732. */
  12733. getHashCode(): number;
  12734. /**
  12735. * Updates the current size from the given one.
  12736. * @param src the given size
  12737. */
  12738. copyFrom(src: Size): void;
  12739. /**
  12740. * Updates in place the current Size from the given floats.
  12741. * @param width width of the new size
  12742. * @param height height of the new size
  12743. * @returns the updated Size.
  12744. */
  12745. copyFromFloats(width: number, height: number): Size;
  12746. /**
  12747. * Updates in place the current Size from the given floats.
  12748. * @param width width to set
  12749. * @param height height to set
  12750. * @returns the updated Size.
  12751. */
  12752. set(width: number, height: number): Size;
  12753. /**
  12754. * Multiplies the width and height by numbers
  12755. * @param w factor to multiple the width by
  12756. * @param h factor to multiple the height by
  12757. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12758. */
  12759. multiplyByFloats(w: number, h: number): Size;
  12760. /**
  12761. * Clones the size
  12762. * @returns a new Size copied from the given one.
  12763. */
  12764. clone(): Size;
  12765. /**
  12766. * True if the current Size and the given one width and height are strictly equal.
  12767. * @param other the other size to compare against
  12768. * @returns True if the current Size and the given one width and height are strictly equal.
  12769. */
  12770. equals(other: Size): boolean;
  12771. /**
  12772. * The surface of the Size : width * height (float).
  12773. */
  12774. readonly surface: number;
  12775. /**
  12776. * Create a new size of zero
  12777. * @returns a new Size set to (0.0, 0.0)
  12778. */
  12779. static Zero(): Size;
  12780. /**
  12781. * Sums the width and height of two sizes
  12782. * @param otherSize size to add to this size
  12783. * @returns a new Size set as the addition result of the current Size and the given one.
  12784. */
  12785. add(otherSize: Size): Size;
  12786. /**
  12787. * Subtracts the width and height of two
  12788. * @param otherSize size to subtract to this size
  12789. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12790. */
  12791. subtract(otherSize: Size): Size;
  12792. /**
  12793. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12794. * @param start starting size to lerp between
  12795. * @param end end size to lerp between
  12796. * @param amount amount to lerp between the start and end values
  12797. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12798. */
  12799. static Lerp(start: Size, end: Size, amount: number): Size;
  12800. }
  12801. }
  12802. declare module "babylonjs/Animations/runtimeAnimation" {
  12803. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12804. import { Animatable } from "babylonjs/Animations/animatable";
  12805. import { Scene } from "babylonjs/scene";
  12806. /**
  12807. * Defines a runtime animation
  12808. */
  12809. export class RuntimeAnimation {
  12810. private _events;
  12811. /**
  12812. * The current frame of the runtime animation
  12813. */
  12814. private _currentFrame;
  12815. /**
  12816. * The animation used by the runtime animation
  12817. */
  12818. private _animation;
  12819. /**
  12820. * The target of the runtime animation
  12821. */
  12822. private _target;
  12823. /**
  12824. * The initiating animatable
  12825. */
  12826. private _host;
  12827. /**
  12828. * The original value of the runtime animation
  12829. */
  12830. private _originalValue;
  12831. /**
  12832. * The original blend value of the runtime animation
  12833. */
  12834. private _originalBlendValue;
  12835. /**
  12836. * The offsets cache of the runtime animation
  12837. */
  12838. private _offsetsCache;
  12839. /**
  12840. * The high limits cache of the runtime animation
  12841. */
  12842. private _highLimitsCache;
  12843. /**
  12844. * Specifies if the runtime animation has been stopped
  12845. */
  12846. private _stopped;
  12847. /**
  12848. * The blending factor of the runtime animation
  12849. */
  12850. private _blendingFactor;
  12851. /**
  12852. * The BabylonJS scene
  12853. */
  12854. private _scene;
  12855. /**
  12856. * The current value of the runtime animation
  12857. */
  12858. private _currentValue;
  12859. /** @hidden */
  12860. _animationState: _IAnimationState;
  12861. /**
  12862. * The active target of the runtime animation
  12863. */
  12864. private _activeTargets;
  12865. private _currentActiveTarget;
  12866. private _directTarget;
  12867. /**
  12868. * The target path of the runtime animation
  12869. */
  12870. private _targetPath;
  12871. /**
  12872. * The weight of the runtime animation
  12873. */
  12874. private _weight;
  12875. /**
  12876. * The ratio offset of the runtime animation
  12877. */
  12878. private _ratioOffset;
  12879. /**
  12880. * The previous delay of the runtime animation
  12881. */
  12882. private _previousDelay;
  12883. /**
  12884. * The previous ratio of the runtime animation
  12885. */
  12886. private _previousRatio;
  12887. private _enableBlending;
  12888. private _keys;
  12889. private _minFrame;
  12890. private _maxFrame;
  12891. private _minValue;
  12892. private _maxValue;
  12893. private _targetIsArray;
  12894. /**
  12895. * Gets the current frame of the runtime animation
  12896. */
  12897. readonly currentFrame: number;
  12898. /**
  12899. * Gets the weight of the runtime animation
  12900. */
  12901. readonly weight: number;
  12902. /**
  12903. * Gets the current value of the runtime animation
  12904. */
  12905. readonly currentValue: any;
  12906. /**
  12907. * Gets the target path of the runtime animation
  12908. */
  12909. readonly targetPath: string;
  12910. /**
  12911. * Gets the actual target of the runtime animation
  12912. */
  12913. readonly target: any;
  12914. /** @hidden */
  12915. _onLoop: () => void;
  12916. /**
  12917. * Create a new RuntimeAnimation object
  12918. * @param target defines the target of the animation
  12919. * @param animation defines the source animation object
  12920. * @param scene defines the hosting scene
  12921. * @param host defines the initiating Animatable
  12922. */
  12923. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12924. private _preparePath;
  12925. /**
  12926. * Gets the animation from the runtime animation
  12927. */
  12928. readonly animation: Animation;
  12929. /**
  12930. * Resets the runtime animation to the beginning
  12931. * @param restoreOriginal defines whether to restore the target property to the original value
  12932. */
  12933. reset(restoreOriginal?: boolean): void;
  12934. /**
  12935. * Specifies if the runtime animation is stopped
  12936. * @returns Boolean specifying if the runtime animation is stopped
  12937. */
  12938. isStopped(): boolean;
  12939. /**
  12940. * Disposes of the runtime animation
  12941. */
  12942. dispose(): void;
  12943. /**
  12944. * Apply the interpolated value to the target
  12945. * @param currentValue defines the value computed by the animation
  12946. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12947. */
  12948. setValue(currentValue: any, weight: number): void;
  12949. private _getOriginalValues;
  12950. private _setValue;
  12951. /**
  12952. * Gets the loop pmode of the runtime animation
  12953. * @returns Loop Mode
  12954. */
  12955. private _getCorrectLoopMode;
  12956. /**
  12957. * Move the current animation to a given frame
  12958. * @param frame defines the frame to move to
  12959. */
  12960. goToFrame(frame: number): void;
  12961. /**
  12962. * @hidden Internal use only
  12963. */
  12964. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12965. /**
  12966. * Execute the current animation
  12967. * @param delay defines the delay to add to the current frame
  12968. * @param from defines the lower bound of the animation range
  12969. * @param to defines the upper bound of the animation range
  12970. * @param loop defines if the current animation must loop
  12971. * @param speedRatio defines the current speed ratio
  12972. * @param weight defines the weight of the animation (default is -1 so no weight)
  12973. * @param onLoop optional callback called when animation loops
  12974. * @returns a boolean indicating if the animation is running
  12975. */
  12976. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12977. }
  12978. }
  12979. declare module "babylonjs/Animations/animatable" {
  12980. import { Animation } from "babylonjs/Animations/animation";
  12981. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12982. import { Nullable } from "babylonjs/types";
  12983. import { Observable } from "babylonjs/Misc/observable";
  12984. import { Scene } from "babylonjs/scene";
  12985. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12986. import { Node } from "babylonjs/node";
  12987. /**
  12988. * Class used to store an actual running animation
  12989. */
  12990. export class Animatable {
  12991. /** defines the target object */
  12992. target: any;
  12993. /** defines the starting frame number (default is 0) */
  12994. fromFrame: number;
  12995. /** defines the ending frame number (default is 100) */
  12996. toFrame: number;
  12997. /** defines if the animation must loop (default is false) */
  12998. loopAnimation: boolean;
  12999. /** defines a callback to call when animation ends if it is not looping */
  13000. onAnimationEnd?: (() => void) | null | undefined;
  13001. /** defines a callback to call when animation loops */
  13002. onAnimationLoop?: (() => void) | null | undefined;
  13003. private _localDelayOffset;
  13004. private _pausedDelay;
  13005. private _runtimeAnimations;
  13006. private _paused;
  13007. private _scene;
  13008. private _speedRatio;
  13009. private _weight;
  13010. private _syncRoot;
  13011. /**
  13012. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13013. * This will only apply for non looping animation (default is true)
  13014. */
  13015. disposeOnEnd: boolean;
  13016. /**
  13017. * Gets a boolean indicating if the animation has started
  13018. */
  13019. animationStarted: boolean;
  13020. /**
  13021. * Observer raised when the animation ends
  13022. */
  13023. onAnimationEndObservable: Observable<Animatable>;
  13024. /**
  13025. * Observer raised when the animation loops
  13026. */
  13027. onAnimationLoopObservable: Observable<Animatable>;
  13028. /**
  13029. * Gets the root Animatable used to synchronize and normalize animations
  13030. */
  13031. readonly syncRoot: Nullable<Animatable>;
  13032. /**
  13033. * Gets the current frame of the first RuntimeAnimation
  13034. * Used to synchronize Animatables
  13035. */
  13036. readonly masterFrame: number;
  13037. /**
  13038. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13039. */
  13040. weight: number;
  13041. /**
  13042. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13043. */
  13044. speedRatio: number;
  13045. /**
  13046. * Creates a new Animatable
  13047. * @param scene defines the hosting scene
  13048. * @param target defines the target object
  13049. * @param fromFrame defines the starting frame number (default is 0)
  13050. * @param toFrame defines the ending frame number (default is 100)
  13051. * @param loopAnimation defines if the animation must loop (default is false)
  13052. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13053. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13054. * @param animations defines a group of animation to add to the new Animatable
  13055. * @param onAnimationLoop defines a callback to call when animation loops
  13056. */
  13057. constructor(scene: Scene,
  13058. /** defines the target object */
  13059. target: any,
  13060. /** defines the starting frame number (default is 0) */
  13061. fromFrame?: number,
  13062. /** defines the ending frame number (default is 100) */
  13063. toFrame?: number,
  13064. /** defines if the animation must loop (default is false) */
  13065. loopAnimation?: boolean, speedRatio?: number,
  13066. /** defines a callback to call when animation ends if it is not looping */
  13067. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13068. /** defines a callback to call when animation loops */
  13069. onAnimationLoop?: (() => void) | null | undefined);
  13070. /**
  13071. * Synchronize and normalize current Animatable with a source Animatable
  13072. * This is useful when using animation weights and when animations are not of the same length
  13073. * @param root defines the root Animatable to synchronize with
  13074. * @returns the current Animatable
  13075. */
  13076. syncWith(root: Animatable): Animatable;
  13077. /**
  13078. * Gets the list of runtime animations
  13079. * @returns an array of RuntimeAnimation
  13080. */
  13081. getAnimations(): RuntimeAnimation[];
  13082. /**
  13083. * Adds more animations to the current animatable
  13084. * @param target defines the target of the animations
  13085. * @param animations defines the new animations to add
  13086. */
  13087. appendAnimations(target: any, animations: Animation[]): void;
  13088. /**
  13089. * Gets the source animation for a specific property
  13090. * @param property defines the propertyu to look for
  13091. * @returns null or the source animation for the given property
  13092. */
  13093. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13094. /**
  13095. * Gets the runtime animation for a specific property
  13096. * @param property defines the propertyu to look for
  13097. * @returns null or the runtime animation for the given property
  13098. */
  13099. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13100. /**
  13101. * Resets the animatable to its original state
  13102. */
  13103. reset(): void;
  13104. /**
  13105. * Allows the animatable to blend with current running animations
  13106. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13107. * @param blendingSpeed defines the blending speed to use
  13108. */
  13109. enableBlending(blendingSpeed: number): void;
  13110. /**
  13111. * Disable animation blending
  13112. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13113. */
  13114. disableBlending(): void;
  13115. /**
  13116. * Jump directly to a given frame
  13117. * @param frame defines the frame to jump to
  13118. */
  13119. goToFrame(frame: number): void;
  13120. /**
  13121. * Pause the animation
  13122. */
  13123. pause(): void;
  13124. /**
  13125. * Restart the animation
  13126. */
  13127. restart(): void;
  13128. private _raiseOnAnimationEnd;
  13129. /**
  13130. * Stop and delete the current animation
  13131. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13132. * @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)
  13133. */
  13134. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13135. /**
  13136. * Wait asynchronously for the animation to end
  13137. * @returns a promise which will be fullfilled when the animation ends
  13138. */
  13139. waitAsync(): Promise<Animatable>;
  13140. /** @hidden */
  13141. _animate(delay: number): boolean;
  13142. }
  13143. module "babylonjs/scene" {
  13144. interface Scene {
  13145. /** @hidden */
  13146. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13147. /** @hidden */
  13148. _processLateAnimationBindingsForMatrices(holder: {
  13149. totalWeight: number;
  13150. animations: RuntimeAnimation[];
  13151. originalValue: Matrix;
  13152. }): any;
  13153. /** @hidden */
  13154. _processLateAnimationBindingsForQuaternions(holder: {
  13155. totalWeight: number;
  13156. animations: RuntimeAnimation[];
  13157. originalValue: Quaternion;
  13158. }, refQuaternion: Quaternion): Quaternion;
  13159. /** @hidden */
  13160. _processLateAnimationBindings(): void;
  13161. /**
  13162. * Will start the animation sequence of a given target
  13163. * @param target defines the target
  13164. * @param from defines from which frame should animation start
  13165. * @param to defines until which frame should animation run.
  13166. * @param weight defines the weight to apply to the animation (1.0 by default)
  13167. * @param loop defines if the animation loops
  13168. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13169. * @param onAnimationEnd defines the function to be executed when the animation ends
  13170. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13171. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13172. * @param onAnimationLoop defines the callback to call when an animation loops
  13173. * @returns the animatable object created for this animation
  13174. */
  13175. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13176. /**
  13177. * Will start the animation sequence of a given target
  13178. * @param target defines the target
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the animatable object created for this animation
  13189. */
  13190. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13191. /**
  13192. * Will start the animation sequence of a given target and its hierarchy
  13193. * @param target defines the target
  13194. * @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.
  13195. * @param from defines from which frame should animation start
  13196. * @param to defines until which frame should animation run.
  13197. * @param loop defines if the animation loops
  13198. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13199. * @param onAnimationEnd defines the function to be executed when the animation ends
  13200. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13201. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13202. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13203. * @param onAnimationLoop defines the callback to call when an animation loops
  13204. * @returns the list of created animatables
  13205. */
  13206. 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[];
  13207. /**
  13208. * Begin a new animation on a given node
  13209. * @param target defines the target where the animation will take place
  13210. * @param animations defines the list of animations to start
  13211. * @param from defines the initial value
  13212. * @param to defines the final value
  13213. * @param loop defines if you want animation to loop (off by default)
  13214. * @param speedRatio defines the speed ratio to apply to all animations
  13215. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13216. * @param onAnimationLoop defines the callback to call when an animation loops
  13217. * @returns the list of created animatables
  13218. */
  13219. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13220. /**
  13221. * Begin a new animation on a given node and its hierarchy
  13222. * @param target defines the root node where the animation will take place
  13223. * @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.
  13224. * @param animations defines the list of animations to start
  13225. * @param from defines the initial value
  13226. * @param to defines the final value
  13227. * @param loop defines if you want animation to loop (off by default)
  13228. * @param speedRatio defines the speed ratio to apply to all animations
  13229. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13230. * @param onAnimationLoop defines the callback to call when an animation loops
  13231. * @returns the list of animatables created for all nodes
  13232. */
  13233. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13234. /**
  13235. * Gets the animatable associated with a specific target
  13236. * @param target defines the target of the animatable
  13237. * @returns the required animatable if found
  13238. */
  13239. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13240. /**
  13241. * Gets all animatables associated with a given target
  13242. * @param target defines the target to look animatables for
  13243. * @returns an array of Animatables
  13244. */
  13245. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13246. /**
  13247. * Stops and removes all animations that have been applied to the scene
  13248. */
  13249. stopAllAnimations(): void;
  13250. }
  13251. }
  13252. module "babylonjs/Bones/bone" {
  13253. interface Bone {
  13254. /**
  13255. * Copy an animation range from another bone
  13256. * @param source defines the source bone
  13257. * @param rangeName defines the range name to copy
  13258. * @param frameOffset defines the frame offset
  13259. * @param rescaleAsRequired defines if rescaling must be applied if required
  13260. * @param skelDimensionsRatio defines the scaling ratio
  13261. * @returns true if operation was successful
  13262. */
  13263. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13264. }
  13265. }
  13266. }
  13267. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13268. /**
  13269. * Class used to override all child animations of a given target
  13270. */
  13271. export class AnimationPropertiesOverride {
  13272. /**
  13273. * Gets or sets a value indicating if animation blending must be used
  13274. */
  13275. enableBlending: boolean;
  13276. /**
  13277. * Gets or sets the blending speed to use when enableBlending is true
  13278. */
  13279. blendingSpeed: number;
  13280. /**
  13281. * Gets or sets the default loop mode to use
  13282. */
  13283. loopMode: number;
  13284. }
  13285. }
  13286. declare module "babylonjs/Bones/skeleton" {
  13287. import { Bone } from "babylonjs/Bones/bone";
  13288. import { Observable } from "babylonjs/Misc/observable";
  13289. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Nullable } from "babylonjs/types";
  13292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13293. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13294. import { Animatable } from "babylonjs/Animations/animatable";
  13295. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13296. import { Animation } from "babylonjs/Animations/animation";
  13297. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13298. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13300. /**
  13301. * Class used to handle skinning animations
  13302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13303. */
  13304. export class Skeleton implements IAnimatable {
  13305. /** defines the skeleton name */
  13306. name: string;
  13307. /** defines the skeleton Id */
  13308. id: string;
  13309. /**
  13310. * Defines the list of child bones
  13311. */
  13312. bones: Bone[];
  13313. /**
  13314. * Defines an estimate of the dimension of the skeleton at rest
  13315. */
  13316. dimensionsAtRest: Vector3;
  13317. /**
  13318. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13319. */
  13320. needInitialSkinMatrix: boolean;
  13321. /**
  13322. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13323. */
  13324. overrideMesh: Nullable<AbstractMesh>;
  13325. /**
  13326. * Gets the list of animations attached to this skeleton
  13327. */
  13328. animations: Array<Animation>;
  13329. private _scene;
  13330. private _isDirty;
  13331. private _transformMatrices;
  13332. private _transformMatrixTexture;
  13333. private _meshesWithPoseMatrix;
  13334. private _animatables;
  13335. private _identity;
  13336. private _synchronizedWithMesh;
  13337. private _ranges;
  13338. private _lastAbsoluteTransformsUpdateId;
  13339. private _canUseTextureForBones;
  13340. private _uniqueId;
  13341. /** @hidden */
  13342. _numBonesWithLinkedTransformNode: number;
  13343. /** @hidden */
  13344. _hasWaitingData: Nullable<boolean>;
  13345. /**
  13346. * Specifies if the skeleton should be serialized
  13347. */
  13348. doNotSerialize: boolean;
  13349. private _useTextureToStoreBoneMatrices;
  13350. /**
  13351. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13352. * Please note that this option is not available if the hardware does not support it
  13353. */
  13354. useTextureToStoreBoneMatrices: boolean;
  13355. private _animationPropertiesOverride;
  13356. /**
  13357. * Gets or sets the animation properties override
  13358. */
  13359. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13360. /**
  13361. * List of inspectable custom properties (used by the Inspector)
  13362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13363. */
  13364. inspectableCustomProperties: IInspectable[];
  13365. /**
  13366. * An observable triggered before computing the skeleton's matrices
  13367. */
  13368. onBeforeComputeObservable: Observable<Skeleton>;
  13369. /**
  13370. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13371. */
  13372. readonly isUsingTextureForMatrices: boolean;
  13373. /**
  13374. * Gets the unique ID of this skeleton
  13375. */
  13376. readonly uniqueId: number;
  13377. /**
  13378. * Creates a new skeleton
  13379. * @param name defines the skeleton name
  13380. * @param id defines the skeleton Id
  13381. * @param scene defines the hosting scene
  13382. */
  13383. constructor(
  13384. /** defines the skeleton name */
  13385. name: string,
  13386. /** defines the skeleton Id */
  13387. id: string, scene: Scene);
  13388. /**
  13389. * Gets the current object class name.
  13390. * @return the class name
  13391. */
  13392. getClassName(): string;
  13393. /**
  13394. * Returns an array containing the root bones
  13395. * @returns an array containing the root bones
  13396. */
  13397. getChildren(): Array<Bone>;
  13398. /**
  13399. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13400. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13401. * @returns a Float32Array containing matrices data
  13402. */
  13403. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13404. /**
  13405. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13406. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13407. * @returns a raw texture containing the data
  13408. */
  13409. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13410. /**
  13411. * Gets the current hosting scene
  13412. * @returns a scene object
  13413. */
  13414. getScene(): Scene;
  13415. /**
  13416. * Gets a string representing the current skeleton data
  13417. * @param fullDetails defines a boolean indicating if we want a verbose version
  13418. * @returns a string representing the current skeleton data
  13419. */
  13420. toString(fullDetails?: boolean): string;
  13421. /**
  13422. * Get bone's index searching by name
  13423. * @param name defines bone's name to search for
  13424. * @return the indice of the bone. Returns -1 if not found
  13425. */
  13426. getBoneIndexByName(name: string): number;
  13427. /**
  13428. * Creater a new animation range
  13429. * @param name defines the name of the range
  13430. * @param from defines the start key
  13431. * @param to defines the end key
  13432. */
  13433. createAnimationRange(name: string, from: number, to: number): void;
  13434. /**
  13435. * Delete a specific animation range
  13436. * @param name defines the name of the range
  13437. * @param deleteFrames defines if frames must be removed as well
  13438. */
  13439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13440. /**
  13441. * Gets a specific animation range
  13442. * @param name defines the name of the range to look for
  13443. * @returns the requested animation range or null if not found
  13444. */
  13445. getAnimationRange(name: string): Nullable<AnimationRange>;
  13446. /**
  13447. * Gets the list of all animation ranges defined on this skeleton
  13448. * @returns an array
  13449. */
  13450. getAnimationRanges(): Nullable<AnimationRange>[];
  13451. /**
  13452. * Copy animation range from a source skeleton.
  13453. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13454. * @param source defines the source skeleton
  13455. * @param name defines the name of the range to copy
  13456. * @param rescaleAsRequired defines if rescaling must be applied if required
  13457. * @returns true if operation was successful
  13458. */
  13459. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13460. /**
  13461. * Forces the skeleton to go to rest pose
  13462. */
  13463. returnToRest(): void;
  13464. private _getHighestAnimationFrame;
  13465. /**
  13466. * Begin a specific animation range
  13467. * @param name defines the name of the range to start
  13468. * @param loop defines if looping must be turned on (false by default)
  13469. * @param speedRatio defines the speed ratio to apply (1 by default)
  13470. * @param onAnimationEnd defines a callback which will be called when animation will end
  13471. * @returns a new animatable
  13472. */
  13473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13474. /** @hidden */
  13475. _markAsDirty(): void;
  13476. /** @hidden */
  13477. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13478. /** @hidden */
  13479. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13480. private _computeTransformMatrices;
  13481. /**
  13482. * Build all resources required to render a skeleton
  13483. */
  13484. prepare(): void;
  13485. /**
  13486. * Gets the list of animatables currently running for this skeleton
  13487. * @returns an array of animatables
  13488. */
  13489. getAnimatables(): IAnimatable[];
  13490. /**
  13491. * Clone the current skeleton
  13492. * @param name defines the name of the new skeleton
  13493. * @param id defines the id of the new skeleton
  13494. * @returns the new skeleton
  13495. */
  13496. clone(name: string, id: string): Skeleton;
  13497. /**
  13498. * Enable animation blending for this skeleton
  13499. * @param blendingSpeed defines the blending speed to apply
  13500. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13501. */
  13502. enableBlending(blendingSpeed?: number): void;
  13503. /**
  13504. * Releases all resources associated with the current skeleton
  13505. */
  13506. dispose(): void;
  13507. /**
  13508. * Serialize the skeleton in a JSON object
  13509. * @returns a JSON object
  13510. */
  13511. serialize(): any;
  13512. /**
  13513. * Creates a new skeleton from serialized data
  13514. * @param parsedSkeleton defines the serialized data
  13515. * @param scene defines the hosting scene
  13516. * @returns a new skeleton
  13517. */
  13518. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13519. /**
  13520. * Compute all node absolute transforms
  13521. * @param forceUpdate defines if computation must be done even if cache is up to date
  13522. */
  13523. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13524. /**
  13525. * Gets the root pose matrix
  13526. * @returns a matrix
  13527. */
  13528. getPoseMatrix(): Nullable<Matrix>;
  13529. /**
  13530. * Sorts bones per internal index
  13531. */
  13532. sortBones(): void;
  13533. private _sortBones;
  13534. }
  13535. }
  13536. declare module "babylonjs/Bones/bone" {
  13537. import { Skeleton } from "babylonjs/Bones/skeleton";
  13538. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13539. import { Nullable } from "babylonjs/types";
  13540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13542. import { Node } from "babylonjs/node";
  13543. import { Space } from "babylonjs/Maths/math.axis";
  13544. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13545. /**
  13546. * Class used to store bone information
  13547. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13548. */
  13549. export class Bone extends Node {
  13550. /**
  13551. * defines the bone name
  13552. */
  13553. name: string;
  13554. private static _tmpVecs;
  13555. private static _tmpQuat;
  13556. private static _tmpMats;
  13557. /**
  13558. * Gets the list of child bones
  13559. */
  13560. children: Bone[];
  13561. /** Gets the animations associated with this bone */
  13562. animations: import("babylonjs/Animations/animation").Animation[];
  13563. /**
  13564. * Gets or sets bone length
  13565. */
  13566. length: number;
  13567. /**
  13568. * @hidden Internal only
  13569. * Set this value to map this bone to a different index in the transform matrices
  13570. * Set this value to -1 to exclude the bone from the transform matrices
  13571. */
  13572. _index: Nullable<number>;
  13573. private _skeleton;
  13574. private _localMatrix;
  13575. private _restPose;
  13576. private _baseMatrix;
  13577. private _absoluteTransform;
  13578. private _invertedAbsoluteTransform;
  13579. private _parent;
  13580. private _scalingDeterminant;
  13581. private _worldTransform;
  13582. private _localScaling;
  13583. private _localRotation;
  13584. private _localPosition;
  13585. private _needToDecompose;
  13586. private _needToCompose;
  13587. /** @hidden */
  13588. _linkedTransformNode: Nullable<TransformNode>;
  13589. /** @hidden */
  13590. _waitingTransformNodeId: Nullable<string>;
  13591. /** @hidden */
  13592. /** @hidden */
  13593. _matrix: Matrix;
  13594. /**
  13595. * Create a new bone
  13596. * @param name defines the bone name
  13597. * @param skeleton defines the parent skeleton
  13598. * @param parentBone defines the parent (can be null if the bone is the root)
  13599. * @param localMatrix defines the local matrix
  13600. * @param restPose defines the rest pose matrix
  13601. * @param baseMatrix defines the base matrix
  13602. * @param index defines index of the bone in the hiearchy
  13603. */
  13604. constructor(
  13605. /**
  13606. * defines the bone name
  13607. */
  13608. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13609. /**
  13610. * Gets the current object class name.
  13611. * @return the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Gets the parent skeleton
  13616. * @returns a skeleton
  13617. */
  13618. getSkeleton(): Skeleton;
  13619. /**
  13620. * Gets parent bone
  13621. * @returns a bone or null if the bone is the root of the bone hierarchy
  13622. */
  13623. getParent(): Nullable<Bone>;
  13624. /**
  13625. * Returns an array containing the root bones
  13626. * @returns an array containing the root bones
  13627. */
  13628. getChildren(): Array<Bone>;
  13629. /**
  13630. * Sets the parent bone
  13631. * @param parent defines the parent (can be null if the bone is the root)
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. */
  13634. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13635. /**
  13636. * Gets the local matrix
  13637. * @returns a matrix
  13638. */
  13639. getLocalMatrix(): Matrix;
  13640. /**
  13641. * Gets the base matrix (initial matrix which remains unchanged)
  13642. * @returns a matrix
  13643. */
  13644. getBaseMatrix(): Matrix;
  13645. /**
  13646. * Gets the rest pose matrix
  13647. * @returns a matrix
  13648. */
  13649. getRestPose(): Matrix;
  13650. /**
  13651. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13652. */
  13653. getWorldMatrix(): Matrix;
  13654. /**
  13655. * Sets the local matrix to rest pose matrix
  13656. */
  13657. returnToRest(): void;
  13658. /**
  13659. * Gets the inverse of the absolute transform matrix.
  13660. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13661. * @returns a matrix
  13662. */
  13663. getInvertedAbsoluteTransform(): Matrix;
  13664. /**
  13665. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13666. * @returns a matrix
  13667. */
  13668. getAbsoluteTransform(): Matrix;
  13669. /**
  13670. * Links with the given transform node.
  13671. * The local matrix of this bone is copied from the transform node every frame.
  13672. * @param transformNode defines the transform node to link to
  13673. */
  13674. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13675. /**
  13676. * Gets the node used to drive the bone's transformation
  13677. * @returns a transform node or null
  13678. */
  13679. getTransformNode(): Nullable<TransformNode>;
  13680. /** Gets or sets current position (in local space) */
  13681. position: Vector3;
  13682. /** Gets or sets current rotation (in local space) */
  13683. rotation: Vector3;
  13684. /** Gets or sets current rotation quaternion (in local space) */
  13685. rotationQuaternion: Quaternion;
  13686. /** Gets or sets current scaling (in local space) */
  13687. scaling: Vector3;
  13688. /**
  13689. * Gets the animation properties override
  13690. */
  13691. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. private _decompose;
  13693. private _compose;
  13694. /**
  13695. * Update the base and local matrices
  13696. * @param matrix defines the new base or local matrix
  13697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13698. * @param updateLocalMatrix defines if the local matrix should be updated
  13699. */
  13700. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13701. /** @hidden */
  13702. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13703. /**
  13704. * Flag the bone as dirty (Forcing it to update everything)
  13705. */
  13706. markAsDirty(): void;
  13707. /** @hidden */
  13708. _markAsDirtyAndCompose(): void;
  13709. private _markAsDirtyAndDecompose;
  13710. /**
  13711. * Translate the bone in local or world space
  13712. * @param vec The amount to translate the bone
  13713. * @param space The space that the translation is in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Set the postion of the bone in local or world space
  13719. * @param position The position to set the bone
  13720. * @param space The space that the position is in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. */
  13723. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13724. /**
  13725. * Set the absolute position of the bone (world space)
  13726. * @param position The position to set the bone
  13727. * @param mesh The mesh that this bone is attached to
  13728. */
  13729. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13730. /**
  13731. * Scale the bone on the x, y and z axes (in local space)
  13732. * @param x The amount to scale the bone on the x axis
  13733. * @param y The amount to scale the bone on the y axis
  13734. * @param z The amount to scale the bone on the z axis
  13735. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13736. */
  13737. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13738. /**
  13739. * Set the bone scaling in local space
  13740. * @param scale defines the scaling vector
  13741. */
  13742. setScale(scale: Vector3): void;
  13743. /**
  13744. * Gets the current scaling in local space
  13745. * @returns the current scaling vector
  13746. */
  13747. getScale(): Vector3;
  13748. /**
  13749. * Gets the current scaling in local space and stores it in a target vector
  13750. * @param result defines the target vector
  13751. */
  13752. getScaleToRef(result: Vector3): void;
  13753. /**
  13754. * Set the yaw, pitch, and roll of the bone in local or world space
  13755. * @param yaw The rotation of the bone on the y axis
  13756. * @param pitch The rotation of the bone on the x axis
  13757. * @param roll The rotation of the bone on the z axis
  13758. * @param space The space that the axes of rotation are in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Add a rotation to the bone on an axis in local or world space
  13764. * @param axis The axis to rotate the bone on
  13765. * @param amount The amount to rotate the bone
  13766. * @param space The space that the axis is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the rotation of the bone to a particular axis angle in local or world space
  13772. * @param axis The axis to rotate the bone on
  13773. * @param angle The angle that the bone should be rotated to
  13774. * @param space The space that the axis is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13778. /**
  13779. * Set the euler rotation of the bone in local of world space
  13780. * @param rotation The euler rotation that the bone should be set to
  13781. * @param space The space that the rotation is in
  13782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13783. */
  13784. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13785. /**
  13786. * Set the quaternion rotation of the bone in local of world space
  13787. * @param quat The quaternion rotation that the bone should be set to
  13788. * @param space The space that the rotation is in
  13789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13790. */
  13791. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13792. /**
  13793. * Set the rotation matrix of the bone in local of world space
  13794. * @param rotMat The rotation matrix that the bone should be set to
  13795. * @param space The space that the rotation is in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13799. private _rotateWithMatrix;
  13800. private _getNegativeRotationToRef;
  13801. /**
  13802. * Get the position of the bone in local or world space
  13803. * @param space The space that the returned position is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @returns The position of the bone
  13806. */
  13807. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13808. /**
  13809. * Copy the position of the bone to a vector3 in local or world space
  13810. * @param space The space that the returned position is in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @param result The vector3 to copy the position to
  13813. */
  13814. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13815. /**
  13816. * Get the absolute position of the bone (world space)
  13817. * @param mesh The mesh that this bone is attached to
  13818. * @returns The absolute position of the bone
  13819. */
  13820. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13821. /**
  13822. * Copy the absolute position of the bone (world space) to the result param
  13823. * @param mesh The mesh that this bone is attached to
  13824. * @param result The vector3 to copy the absolute position to
  13825. */
  13826. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13827. /**
  13828. * Compute the absolute transforms of this bone and its children
  13829. */
  13830. computeAbsoluteTransforms(): void;
  13831. /**
  13832. * Get the world direction from an axis that is in the local space of the bone
  13833. * @param localAxis The local direction that is used to compute the world direction
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The world direction
  13836. */
  13837. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13840. * @param localAxis The local direction that is used to compute the world direction
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the world direction will be copied to
  13843. */
  13844. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. /**
  13846. * Get the euler rotation of the bone in local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @returns The euler rotation
  13850. */
  13851. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13852. /**
  13853. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @param result The vector3 that the rotation should be copied to
  13857. */
  13858. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13859. /**
  13860. * Get the quaternion rotation of the bone in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @returns The quaternion rotation
  13864. */
  13865. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13866. /**
  13867. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13868. * @param space The space that the rotation should be in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. * @param result The quaternion that the rotation should be copied to
  13871. */
  13872. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13873. /**
  13874. * Get the rotation matrix of the bone in local or world space
  13875. * @param space The space that the rotation should be in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. * @returns The rotation matrix
  13878. */
  13879. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13880. /**
  13881. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13882. * @param space The space that the rotation should be in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. * @param result The quaternion that the rotation should be copied to
  13885. */
  13886. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13887. /**
  13888. * Get the world position of a point that is in the local space of the bone
  13889. * @param position The local position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @returns The world position
  13892. */
  13893. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13896. * @param position The local position
  13897. * @param mesh The mesh that this bone is attached to
  13898. * @param result The vector3 that the world position should be copied to
  13899. */
  13900. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the local position of a point that is in world space
  13903. * @param position The world position
  13904. * @param mesh The mesh that this bone is attached to
  13905. * @returns The local position
  13906. */
  13907. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13908. /**
  13909. * Get the local position of a point that is in world space and copy it to the result param
  13910. * @param position The world position
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 that the local position should be copied to
  13913. */
  13914. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13915. }
  13916. }
  13917. declare module "babylonjs/Meshes/transformNode" {
  13918. import { DeepImmutable } from "babylonjs/types";
  13919. import { Observable } from "babylonjs/Misc/observable";
  13920. import { Nullable } from "babylonjs/types";
  13921. import { Camera } from "babylonjs/Cameras/camera";
  13922. import { Scene } from "babylonjs/scene";
  13923. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13924. import { Node } from "babylonjs/node";
  13925. import { Bone } from "babylonjs/Bones/bone";
  13926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13927. import { Space } from "babylonjs/Maths/math.axis";
  13928. /**
  13929. * 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.
  13930. * @see https://doc.babylonjs.com/how_to/transformnode
  13931. */
  13932. export class TransformNode extends Node {
  13933. /**
  13934. * Object will not rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_NONE: number;
  13937. /**
  13938. * Object will rotate to face the camera but only on the x axis
  13939. */
  13940. static BILLBOARDMODE_X: number;
  13941. /**
  13942. * Object will rotate to face the camera but only on the y axis
  13943. */
  13944. static BILLBOARDMODE_Y: number;
  13945. /**
  13946. * Object will rotate to face the camera but only on the z axis
  13947. */
  13948. static BILLBOARDMODE_Z: number;
  13949. /**
  13950. * Object will rotate to face the camera
  13951. */
  13952. static BILLBOARDMODE_ALL: number;
  13953. /**
  13954. * Object will rotate to face the camera's position instead of orientation
  13955. */
  13956. static BILLBOARDMODE_USE_POSITION: number;
  13957. private _forward;
  13958. private _forwardInverted;
  13959. private _up;
  13960. private _right;
  13961. private _rightInverted;
  13962. private _position;
  13963. private _rotation;
  13964. private _rotationQuaternion;
  13965. protected _scaling: Vector3;
  13966. protected _isDirty: boolean;
  13967. private _transformToBoneReferal;
  13968. private _isAbsoluteSynced;
  13969. private _billboardMode;
  13970. /**
  13971. * Gets or sets the billboard mode. Default is 0.
  13972. *
  13973. * | Value | Type | Description |
  13974. * | --- | --- | --- |
  13975. * | 0 | BILLBOARDMODE_NONE | |
  13976. * | 1 | BILLBOARDMODE_X | |
  13977. * | 2 | BILLBOARDMODE_Y | |
  13978. * | 4 | BILLBOARDMODE_Z | |
  13979. * | 7 | BILLBOARDMODE_ALL | |
  13980. *
  13981. */
  13982. billboardMode: number;
  13983. private _preserveParentRotationForBillboard;
  13984. /**
  13985. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13986. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13987. */
  13988. preserveParentRotationForBillboard: boolean;
  13989. /**
  13990. * 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
  13991. */
  13992. scalingDeterminant: number;
  13993. private _infiniteDistance;
  13994. /**
  13995. * Gets or sets the distance of the object to max, often used by skybox
  13996. */
  13997. infiniteDistance: boolean;
  13998. /**
  13999. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14000. * By default the system will update normals to compensate
  14001. */
  14002. ignoreNonUniformScaling: boolean;
  14003. /**
  14004. * 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
  14005. */
  14006. reIntegrateRotationIntoRotationQuaternion: boolean;
  14007. /** @hidden */
  14008. _poseMatrix: Nullable<Matrix>;
  14009. /** @hidden */
  14010. _localMatrix: Matrix;
  14011. private _usePivotMatrix;
  14012. private _absolutePosition;
  14013. private _absoluteScaling;
  14014. private _absoluteRotationQuaternion;
  14015. private _pivotMatrix;
  14016. private _pivotMatrixInverse;
  14017. protected _postMultiplyPivotMatrix: boolean;
  14018. protected _isWorldMatrixFrozen: boolean;
  14019. /** @hidden */
  14020. _indexInSceneTransformNodesArray: number;
  14021. /**
  14022. * An event triggered after the world matrix is updated
  14023. */
  14024. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14025. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14026. /**
  14027. * Gets a string identifying the name of the class
  14028. * @returns "TransformNode" string
  14029. */
  14030. getClassName(): string;
  14031. /**
  14032. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14033. */
  14034. position: Vector3;
  14035. /**
  14036. * 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)).
  14037. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14038. */
  14039. rotation: Vector3;
  14040. /**
  14041. * 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)).
  14042. */
  14043. scaling: Vector3;
  14044. /**
  14045. * 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).
  14046. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14047. */
  14048. rotationQuaternion: Nullable<Quaternion>;
  14049. /**
  14050. * The forward direction of that transform in world space.
  14051. */
  14052. readonly forward: Vector3;
  14053. /**
  14054. * The up direction of that transform in world space.
  14055. */
  14056. readonly up: Vector3;
  14057. /**
  14058. * The right direction of that transform in world space.
  14059. */
  14060. readonly right: Vector3;
  14061. /**
  14062. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14063. * @param matrix the matrix to copy the pose from
  14064. * @returns this TransformNode.
  14065. */
  14066. updatePoseMatrix(matrix: Matrix): TransformNode;
  14067. /**
  14068. * Returns the mesh Pose matrix.
  14069. * @returns the pose matrix
  14070. */
  14071. getPoseMatrix(): Matrix;
  14072. /** @hidden */
  14073. _isSynchronized(): boolean;
  14074. /** @hidden */
  14075. _initCache(): void;
  14076. /**
  14077. * Flag the transform node as dirty (Forcing it to update everything)
  14078. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14079. * @returns this transform node
  14080. */
  14081. markAsDirty(property: string): TransformNode;
  14082. /**
  14083. * Returns the current mesh absolute position.
  14084. * Returns a Vector3.
  14085. */
  14086. readonly absolutePosition: Vector3;
  14087. /**
  14088. * Returns the current mesh absolute scaling.
  14089. * Returns a Vector3.
  14090. */
  14091. readonly absoluteScaling: Vector3;
  14092. /**
  14093. * Returns the current mesh absolute rotation.
  14094. * Returns a Quaternion.
  14095. */
  14096. readonly absoluteRotationQuaternion: Quaternion;
  14097. /**
  14098. * Sets a new matrix to apply before all other transformation
  14099. * @param matrix defines the transform matrix
  14100. * @returns the current TransformNode
  14101. */
  14102. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14103. /**
  14104. * Sets a new pivot matrix to the current node
  14105. * @param matrix defines the new pivot matrix to use
  14106. * @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
  14107. * @returns the current TransformNode
  14108. */
  14109. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14110. /**
  14111. * Returns the mesh pivot matrix.
  14112. * Default : Identity.
  14113. * @returns the matrix
  14114. */
  14115. getPivotMatrix(): Matrix;
  14116. /**
  14117. * Instantiate (when possible) or clone that node with its hierarchy
  14118. * @param newParent defines the new parent to use for the instance (or clone)
  14119. * @returns an instance (or a clone) of the current node with its hiearchy
  14120. */
  14121. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14122. /**
  14123. * Prevents the World matrix to be computed any longer
  14124. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14125. * @returns the TransformNode.
  14126. */
  14127. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14128. /**
  14129. * Allows back the World matrix computation.
  14130. * @returns the TransformNode.
  14131. */
  14132. unfreezeWorldMatrix(): this;
  14133. /**
  14134. * True if the World matrix has been frozen.
  14135. */
  14136. readonly isWorldMatrixFrozen: boolean;
  14137. /**
  14138. * Retuns the mesh absolute position in the World.
  14139. * @returns a Vector3.
  14140. */
  14141. getAbsolutePosition(): Vector3;
  14142. /**
  14143. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14144. * @param absolutePosition the absolute position to set
  14145. * @returns the TransformNode.
  14146. */
  14147. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14148. /**
  14149. * Sets the mesh position in its local space.
  14150. * @param vector3 the position to set in localspace
  14151. * @returns the TransformNode.
  14152. */
  14153. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14154. /**
  14155. * Returns the mesh position in the local space from the current World matrix values.
  14156. * @returns a new Vector3.
  14157. */
  14158. getPositionExpressedInLocalSpace(): Vector3;
  14159. /**
  14160. * Translates the mesh along the passed Vector3 in its local space.
  14161. * @param vector3 the distance to translate in localspace
  14162. * @returns the TransformNode.
  14163. */
  14164. locallyTranslate(vector3: Vector3): TransformNode;
  14165. private static _lookAtVectorCache;
  14166. /**
  14167. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14168. * @param targetPoint the position (must be in same space as current mesh) to look at
  14169. * @param yawCor optional yaw (y-axis) correction in radians
  14170. * @param pitchCor optional pitch (x-axis) correction in radians
  14171. * @param rollCor optional roll (z-axis) correction in radians
  14172. * @param space the choosen space of the target
  14173. * @returns the TransformNode.
  14174. */
  14175. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14176. /**
  14177. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14178. * This Vector3 is expressed in the World space.
  14179. * @param localAxis axis to rotate
  14180. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14181. */
  14182. getDirection(localAxis: Vector3): Vector3;
  14183. /**
  14184. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14185. * localAxis is expressed in the mesh local space.
  14186. * result is computed in the Wordl space from the mesh World matrix.
  14187. * @param localAxis axis to rotate
  14188. * @param result the resulting transformnode
  14189. * @returns this TransformNode.
  14190. */
  14191. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14192. /**
  14193. * Sets this transform node rotation to the given local axis.
  14194. * @param localAxis the axis in local space
  14195. * @param yawCor optional yaw (y-axis) correction in radians
  14196. * @param pitchCor optional pitch (x-axis) correction in radians
  14197. * @param rollCor optional roll (z-axis) correction in radians
  14198. * @returns this TransformNode
  14199. */
  14200. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14201. /**
  14202. * Sets a new pivot point to the current node
  14203. * @param point defines the new pivot point to use
  14204. * @param space defines if the point is in world or local space (local by default)
  14205. * @returns the current TransformNode
  14206. */
  14207. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14208. /**
  14209. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14210. * @returns the pivot point
  14211. */
  14212. getPivotPoint(): Vector3;
  14213. /**
  14214. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14215. * @param result the vector3 to store the result
  14216. * @returns this TransformNode.
  14217. */
  14218. getPivotPointToRef(result: Vector3): TransformNode;
  14219. /**
  14220. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14221. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14222. */
  14223. getAbsolutePivotPoint(): Vector3;
  14224. /**
  14225. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14226. * @param result vector3 to store the result
  14227. * @returns this TransformNode.
  14228. */
  14229. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14230. /**
  14231. * Defines the passed node as the parent of the current node.
  14232. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14233. * @see https://doc.babylonjs.com/how_to/parenting
  14234. * @param node the node ot set as the parent
  14235. * @returns this TransformNode.
  14236. */
  14237. setParent(node: Nullable<Node>): TransformNode;
  14238. private _nonUniformScaling;
  14239. /**
  14240. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14241. */
  14242. readonly nonUniformScaling: boolean;
  14243. /** @hidden */
  14244. _updateNonUniformScalingState(value: boolean): boolean;
  14245. /**
  14246. * Attach the current TransformNode to another TransformNode associated with a bone
  14247. * @param bone Bone affecting the TransformNode
  14248. * @param affectedTransformNode TransformNode associated with the bone
  14249. * @returns this object
  14250. */
  14251. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14252. /**
  14253. * Detach the transform node if its associated with a bone
  14254. * @returns this object
  14255. */
  14256. detachFromBone(): TransformNode;
  14257. private static _rotationAxisCache;
  14258. /**
  14259. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14260. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14261. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14262. * The passed axis is also normalized.
  14263. * @param axis the axis to rotate around
  14264. * @param amount the amount to rotate in radians
  14265. * @param space Space to rotate in (Default: local)
  14266. * @returns the TransformNode.
  14267. */
  14268. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14269. /**
  14270. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14271. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14272. * The passed axis is also normalized. .
  14273. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14274. * @param point the point to rotate around
  14275. * @param axis the axis to rotate around
  14276. * @param amount the amount to rotate in radians
  14277. * @returns the TransformNode
  14278. */
  14279. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14280. /**
  14281. * Translates the mesh along the axis vector for the passed distance in the given space.
  14282. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14283. * @param axis the axis to translate in
  14284. * @param distance the distance to translate
  14285. * @param space Space to rotate in (Default: local)
  14286. * @returns the TransformNode.
  14287. */
  14288. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14289. /**
  14290. * Adds a rotation step to the mesh current rotation.
  14291. * x, y, z are Euler angles expressed in radians.
  14292. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14293. * This means this rotation is made in the mesh local space only.
  14294. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14295. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14296. * ```javascript
  14297. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14298. * ```
  14299. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14300. * 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.
  14301. * @param x Rotation to add
  14302. * @param y Rotation to add
  14303. * @param z Rotation to add
  14304. * @returns the TransformNode.
  14305. */
  14306. addRotation(x: number, y: number, z: number): TransformNode;
  14307. /**
  14308. * @hidden
  14309. */
  14310. protected _getEffectiveParent(): Nullable<Node>;
  14311. /**
  14312. * Computes the world matrix of the node
  14313. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14314. * @returns the world matrix
  14315. */
  14316. computeWorldMatrix(force?: boolean): Matrix;
  14317. protected _afterComputeWorldMatrix(): void;
  14318. /**
  14319. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14320. * @param func callback function to add
  14321. *
  14322. * @returns the TransformNode.
  14323. */
  14324. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14325. /**
  14326. * Removes a registered callback function.
  14327. * @param func callback function to remove
  14328. * @returns the TransformNode.
  14329. */
  14330. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14331. /**
  14332. * Gets the position of the current mesh in camera space
  14333. * @param camera defines the camera to use
  14334. * @returns a position
  14335. */
  14336. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14337. /**
  14338. * Returns the distance from the mesh to the active camera
  14339. * @param camera defines the camera to use
  14340. * @returns the distance
  14341. */
  14342. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14343. /**
  14344. * Clone the current transform node
  14345. * @param name Name of the new clone
  14346. * @param newParent New parent for the clone
  14347. * @param doNotCloneChildren Do not clone children hierarchy
  14348. * @returns the new transform node
  14349. */
  14350. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14351. /**
  14352. * Serializes the objects information.
  14353. * @param currentSerializationObject defines the object to serialize in
  14354. * @returns the serialized object
  14355. */
  14356. serialize(currentSerializationObject?: any): any;
  14357. /**
  14358. * Returns a new TransformNode object parsed from the source provided.
  14359. * @param parsedTransformNode is the source.
  14360. * @param scene the scne the object belongs to
  14361. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14362. * @returns a new TransformNode object parsed from the source provided.
  14363. */
  14364. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14365. /**
  14366. * Get all child-transformNodes of this node
  14367. * @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
  14368. * @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
  14369. * @returns an array of TransformNode
  14370. */
  14371. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14372. /**
  14373. * Releases resources associated with this transform node.
  14374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14376. */
  14377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14378. /**
  14379. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14380. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14381. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14382. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14383. * @returns the current mesh
  14384. */
  14385. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14386. private _syncAbsoluteScalingAndRotation;
  14387. }
  14388. }
  14389. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14390. import { Observable } from "babylonjs/Misc/observable";
  14391. import { Nullable } from "babylonjs/types";
  14392. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14395. import { Ray } from "babylonjs/Culling/ray";
  14396. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14397. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14398. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14399. /**
  14400. * Defines the types of pose enabled controllers that are supported
  14401. */
  14402. export enum PoseEnabledControllerType {
  14403. /**
  14404. * HTC Vive
  14405. */
  14406. VIVE = 0,
  14407. /**
  14408. * Oculus Rift
  14409. */
  14410. OCULUS = 1,
  14411. /**
  14412. * Windows mixed reality
  14413. */
  14414. WINDOWS = 2,
  14415. /**
  14416. * Samsung gear VR
  14417. */
  14418. GEAR_VR = 3,
  14419. /**
  14420. * Google Daydream
  14421. */
  14422. DAYDREAM = 4,
  14423. /**
  14424. * Generic
  14425. */
  14426. GENERIC = 5
  14427. }
  14428. /**
  14429. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14430. */
  14431. export interface MutableGamepadButton {
  14432. /**
  14433. * Value of the button/trigger
  14434. */
  14435. value: number;
  14436. /**
  14437. * If the button/trigger is currently touched
  14438. */
  14439. touched: boolean;
  14440. /**
  14441. * If the button/trigger is currently pressed
  14442. */
  14443. pressed: boolean;
  14444. }
  14445. /**
  14446. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14447. * @hidden
  14448. */
  14449. export interface ExtendedGamepadButton extends GamepadButton {
  14450. /**
  14451. * If the button/trigger is currently pressed
  14452. */
  14453. readonly pressed: boolean;
  14454. /**
  14455. * If the button/trigger is currently touched
  14456. */
  14457. readonly touched: boolean;
  14458. /**
  14459. * Value of the button/trigger
  14460. */
  14461. readonly value: number;
  14462. }
  14463. /** @hidden */
  14464. export interface _GamePadFactory {
  14465. /**
  14466. * Returns wether or not the current gamepad can be created for this type of controller.
  14467. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14468. * @returns true if it can be created, otherwise false
  14469. */
  14470. canCreate(gamepadInfo: any): boolean;
  14471. /**
  14472. * Creates a new instance of the Gamepad.
  14473. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14474. * @returns the new gamepad instance
  14475. */
  14476. create(gamepadInfo: any): Gamepad;
  14477. }
  14478. /**
  14479. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14480. */
  14481. export class PoseEnabledControllerHelper {
  14482. /** @hidden */
  14483. static _ControllerFactories: _GamePadFactory[];
  14484. /** @hidden */
  14485. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14486. /**
  14487. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14488. * @param vrGamepad the gamepad to initialized
  14489. * @returns a vr controller of the type the gamepad identified as
  14490. */
  14491. static InitiateController(vrGamepad: any): Gamepad;
  14492. }
  14493. /**
  14494. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14495. */
  14496. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14497. /**
  14498. * If the controller is used in a webXR session
  14499. */
  14500. isXR: boolean;
  14501. private _deviceRoomPosition;
  14502. private _deviceRoomRotationQuaternion;
  14503. /**
  14504. * The device position in babylon space
  14505. */
  14506. devicePosition: Vector3;
  14507. /**
  14508. * The device rotation in babylon space
  14509. */
  14510. deviceRotationQuaternion: Quaternion;
  14511. /**
  14512. * The scale factor of the device in babylon space
  14513. */
  14514. deviceScaleFactor: number;
  14515. /**
  14516. * (Likely devicePosition should be used instead) The device position in its room space
  14517. */
  14518. position: Vector3;
  14519. /**
  14520. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14521. */
  14522. rotationQuaternion: Quaternion;
  14523. /**
  14524. * The type of controller (Eg. Windows mixed reality)
  14525. */
  14526. controllerType: PoseEnabledControllerType;
  14527. protected _calculatedPosition: Vector3;
  14528. private _calculatedRotation;
  14529. /**
  14530. * The raw pose from the device
  14531. */
  14532. rawPose: DevicePose;
  14533. private _trackPosition;
  14534. private _maxRotationDistFromHeadset;
  14535. private _draggedRoomRotation;
  14536. /**
  14537. * @hidden
  14538. */
  14539. _disableTrackPosition(fixedPosition: Vector3): void;
  14540. /**
  14541. * Internal, the mesh attached to the controller
  14542. * @hidden
  14543. */
  14544. _mesh: Nullable<AbstractMesh>;
  14545. private _poseControlledCamera;
  14546. private _leftHandSystemQuaternion;
  14547. /**
  14548. * Internal, matrix used to convert room space to babylon space
  14549. * @hidden
  14550. */
  14551. _deviceToWorld: Matrix;
  14552. /**
  14553. * Node to be used when casting a ray from the controller
  14554. * @hidden
  14555. */
  14556. _pointingPoseNode: Nullable<TransformNode>;
  14557. /**
  14558. * Name of the child mesh that can be used to cast a ray from the controller
  14559. */
  14560. static readonly POINTING_POSE: string;
  14561. /**
  14562. * Creates a new PoseEnabledController from a gamepad
  14563. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14564. */
  14565. constructor(browserGamepad: any);
  14566. private _workingMatrix;
  14567. /**
  14568. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14569. */
  14570. update(): void;
  14571. /**
  14572. * Updates only the pose device and mesh without doing any button event checking
  14573. */
  14574. protected _updatePoseAndMesh(): void;
  14575. /**
  14576. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14577. * @param poseData raw pose fromthe device
  14578. */
  14579. updateFromDevice(poseData: DevicePose): void;
  14580. /**
  14581. * @hidden
  14582. */
  14583. _meshAttachedObservable: Observable<AbstractMesh>;
  14584. /**
  14585. * Attaches a mesh to the controller
  14586. * @param mesh the mesh to be attached
  14587. */
  14588. attachToMesh(mesh: AbstractMesh): void;
  14589. /**
  14590. * Attaches the controllers mesh to a camera
  14591. * @param camera the camera the mesh should be attached to
  14592. */
  14593. attachToPoseControlledCamera(camera: TargetCamera): void;
  14594. /**
  14595. * Disposes of the controller
  14596. */
  14597. dispose(): void;
  14598. /**
  14599. * The mesh that is attached to the controller
  14600. */
  14601. readonly mesh: Nullable<AbstractMesh>;
  14602. /**
  14603. * Gets the ray of the controller in the direction the controller is pointing
  14604. * @param length the length the resulting ray should be
  14605. * @returns a ray in the direction the controller is pointing
  14606. */
  14607. getForwardRay(length?: number): Ray;
  14608. }
  14609. }
  14610. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14611. import { Observable } from "babylonjs/Misc/observable";
  14612. import { Scene } from "babylonjs/scene";
  14613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14614. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14615. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14616. /**
  14617. * Defines the WebVRController object that represents controllers tracked in 3D space
  14618. */
  14619. export abstract class WebVRController extends PoseEnabledController {
  14620. /**
  14621. * Internal, the default controller model for the controller
  14622. */
  14623. protected _defaultModel: AbstractMesh;
  14624. /**
  14625. * Fired when the trigger state has changed
  14626. */
  14627. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14628. /**
  14629. * Fired when the main button state has changed
  14630. */
  14631. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14632. /**
  14633. * Fired when the secondary button state has changed
  14634. */
  14635. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14636. /**
  14637. * Fired when the pad state has changed
  14638. */
  14639. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14640. /**
  14641. * Fired when controllers stick values have changed
  14642. */
  14643. onPadValuesChangedObservable: Observable<StickValues>;
  14644. /**
  14645. * Array of button availible on the controller
  14646. */
  14647. protected _buttons: Array<MutableGamepadButton>;
  14648. private _onButtonStateChange;
  14649. /**
  14650. * Fired when a controller button's state has changed
  14651. * @param callback the callback containing the button that was modified
  14652. */
  14653. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14654. /**
  14655. * X and Y axis corresponding to the controllers joystick
  14656. */
  14657. pad: StickValues;
  14658. /**
  14659. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14660. */
  14661. hand: string;
  14662. /**
  14663. * The default controller model for the controller
  14664. */
  14665. readonly defaultModel: AbstractMesh;
  14666. /**
  14667. * Creates a new WebVRController from a gamepad
  14668. * @param vrGamepad the gamepad that the WebVRController should be created from
  14669. */
  14670. constructor(vrGamepad: any);
  14671. /**
  14672. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14673. */
  14674. update(): void;
  14675. /**
  14676. * Function to be called when a button is modified
  14677. */
  14678. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14679. /**
  14680. * Loads a mesh and attaches it to the controller
  14681. * @param scene the scene the mesh should be added to
  14682. * @param meshLoaded callback for when the mesh has been loaded
  14683. */
  14684. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14685. private _setButtonValue;
  14686. private _changes;
  14687. private _checkChanges;
  14688. /**
  14689. * Disposes of th webVRCOntroller
  14690. */
  14691. dispose(): void;
  14692. }
  14693. }
  14694. declare module "babylonjs/Lights/hemisphericLight" {
  14695. import { Nullable } from "babylonjs/types";
  14696. import { Scene } from "babylonjs/scene";
  14697. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14698. import { Color3 } from "babylonjs/Maths/math.color";
  14699. import { Effect } from "babylonjs/Materials/effect";
  14700. import { Light } from "babylonjs/Lights/light";
  14701. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14702. /**
  14703. * The HemisphericLight simulates the ambient environment light,
  14704. * so the passed direction is the light reflection direction, not the incoming direction.
  14705. */
  14706. export class HemisphericLight extends Light {
  14707. /**
  14708. * The groundColor is the light in the opposite direction to the one specified during creation.
  14709. * 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.
  14710. */
  14711. groundColor: Color3;
  14712. /**
  14713. * The light reflection direction, not the incoming direction.
  14714. */
  14715. direction: Vector3;
  14716. /**
  14717. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14718. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14719. * The HemisphericLight can't cast shadows.
  14720. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14721. * @param name The friendly name of the light
  14722. * @param direction The direction of the light reflection
  14723. * @param scene The scene the light belongs to
  14724. */
  14725. constructor(name: string, direction: Vector3, scene: Scene);
  14726. protected _buildUniformLayout(): void;
  14727. /**
  14728. * Returns the string "HemisphericLight".
  14729. * @return The class name
  14730. */
  14731. getClassName(): string;
  14732. /**
  14733. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14734. * Returns the updated direction.
  14735. * @param target The target the direction should point to
  14736. * @return The computed direction
  14737. */
  14738. setDirectionToTarget(target: Vector3): Vector3;
  14739. /**
  14740. * Returns the shadow generator associated to the light.
  14741. * @returns Always null for hemispheric lights because it does not support shadows.
  14742. */
  14743. getShadowGenerator(): Nullable<IShadowGenerator>;
  14744. /**
  14745. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14746. * @param effect The effect to update
  14747. * @param lightIndex The index of the light in the effect to update
  14748. * @returns The hemispheric light
  14749. */
  14750. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14751. /**
  14752. * Computes the world matrix of the node
  14753. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14754. * @param useWasUpdatedFlag defines a reserved property
  14755. * @returns the world matrix
  14756. */
  14757. computeWorldMatrix(): Matrix;
  14758. /**
  14759. * Returns the integer 3.
  14760. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14761. */
  14762. getTypeID(): number;
  14763. /**
  14764. * Prepares the list of defines specific to the light type.
  14765. * @param defines the list of defines
  14766. * @param lightIndex defines the index of the light for the effect
  14767. */
  14768. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14769. }
  14770. }
  14771. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14772. /** @hidden */
  14773. export var vrMultiviewToSingleviewPixelShader: {
  14774. name: string;
  14775. shader: string;
  14776. };
  14777. }
  14778. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14780. import { Scene } from "babylonjs/scene";
  14781. /**
  14782. * Renders to multiple views with a single draw call
  14783. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14784. */
  14785. export class MultiviewRenderTarget extends RenderTargetTexture {
  14786. /**
  14787. * Creates a multiview render target
  14788. * @param scene scene used with the render target
  14789. * @param size the size of the render target (used for each view)
  14790. */
  14791. constructor(scene: Scene, size?: number | {
  14792. width: number;
  14793. height: number;
  14794. } | {
  14795. ratio: number;
  14796. });
  14797. /**
  14798. * @hidden
  14799. * @param faceIndex the face index, if its a cube texture
  14800. */
  14801. _bindFrameBuffer(faceIndex?: number): void;
  14802. /**
  14803. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14804. * @returns the view count
  14805. */
  14806. getViewCount(): number;
  14807. }
  14808. }
  14809. declare module "babylonjs/Maths/math.frustum" {
  14810. import { Matrix } from "babylonjs/Maths/math.vector";
  14811. import { DeepImmutable } from "babylonjs/types";
  14812. import { Plane } from "babylonjs/Maths/math.plane";
  14813. /**
  14814. * Reprasents a camera frustum
  14815. */
  14816. export class Frustum {
  14817. /**
  14818. * Gets the planes representing the frustum
  14819. * @param transform matrix to be applied to the returned planes
  14820. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14821. */
  14822. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14823. /**
  14824. * Gets the near frustum plane transformed by the transform matrix
  14825. * @param transform transformation matrix to be applied to the resulting frustum plane
  14826. * @param frustumPlane the resuling frustum plane
  14827. */
  14828. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14829. /**
  14830. * Gets the far frustum plane transformed by the transform matrix
  14831. * @param transform transformation matrix to be applied to the resulting frustum plane
  14832. * @param frustumPlane the resuling frustum plane
  14833. */
  14834. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14835. /**
  14836. * Gets the left frustum plane transformed by the transform matrix
  14837. * @param transform transformation matrix to be applied to the resulting frustum plane
  14838. * @param frustumPlane the resuling frustum plane
  14839. */
  14840. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14841. /**
  14842. * Gets the right frustum plane transformed by the transform matrix
  14843. * @param transform transformation matrix to be applied to the resulting frustum plane
  14844. * @param frustumPlane the resuling frustum plane
  14845. */
  14846. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14847. /**
  14848. * Gets the top frustum plane transformed by the transform matrix
  14849. * @param transform transformation matrix to be applied to the resulting frustum plane
  14850. * @param frustumPlane the resuling frustum plane
  14851. */
  14852. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14853. /**
  14854. * Gets the bottom frustum plane transformed by the transform matrix
  14855. * @param transform transformation matrix to be applied to the resulting frustum plane
  14856. * @param frustumPlane the resuling frustum plane
  14857. */
  14858. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14859. /**
  14860. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14861. * @param transform transformation matrix to be applied to the resulting frustum planes
  14862. * @param frustumPlanes the resuling frustum planes
  14863. */
  14864. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14865. }
  14866. }
  14867. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14868. import { Camera } from "babylonjs/Cameras/camera";
  14869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14870. import { Nullable } from "babylonjs/types";
  14871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14872. import { Matrix } from "babylonjs/Maths/math.vector";
  14873. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14874. module "babylonjs/Engines/engine" {
  14875. interface Engine {
  14876. /**
  14877. * Creates a new multiview render target
  14878. * @param width defines the width of the texture
  14879. * @param height defines the height of the texture
  14880. * @returns the created multiview texture
  14881. */
  14882. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14883. /**
  14884. * Binds a multiview framebuffer to be drawn to
  14885. * @param multiviewTexture texture to bind
  14886. */
  14887. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14888. }
  14889. }
  14890. module "babylonjs/Cameras/camera" {
  14891. interface Camera {
  14892. /**
  14893. * @hidden
  14894. * 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)
  14895. */
  14896. _useMultiviewToSingleView: boolean;
  14897. /**
  14898. * @hidden
  14899. * 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)
  14900. */
  14901. _multiviewTexture: Nullable<RenderTargetTexture>;
  14902. /**
  14903. * @hidden
  14904. * ensures the multiview texture of the camera exists and has the specified width/height
  14905. * @param width height to set on the multiview texture
  14906. * @param height width to set on the multiview texture
  14907. */
  14908. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14909. }
  14910. }
  14911. module "babylonjs/scene" {
  14912. interface Scene {
  14913. /** @hidden */
  14914. _transformMatrixR: Matrix;
  14915. /** @hidden */
  14916. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14917. /** @hidden */
  14918. _createMultiviewUbo(): void;
  14919. /** @hidden */
  14920. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14921. /** @hidden */
  14922. _renderMultiviewToSingleView(camera: Camera): void;
  14923. }
  14924. }
  14925. }
  14926. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14927. import { Camera } from "babylonjs/Cameras/camera";
  14928. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14929. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14930. import "babylonjs/Engines/Extensions/engine.multiview";
  14931. /**
  14932. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14933. * This will not be used for webXR as it supports displaying texture arrays directly
  14934. */
  14935. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14936. /**
  14937. * Initializes a VRMultiviewToSingleview
  14938. * @param name name of the post process
  14939. * @param camera camera to be applied to
  14940. * @param scaleFactor scaling factor to the size of the output texture
  14941. */
  14942. constructor(name: string, camera: Camera, scaleFactor: number);
  14943. }
  14944. }
  14945. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14946. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14947. import { Nullable } from "babylonjs/types";
  14948. import { Size } from "babylonjs/Maths/math.size";
  14949. import { Observable } from "babylonjs/Misc/observable";
  14950. module "babylonjs/Engines/engine" {
  14951. interface Engine {
  14952. /** @hidden */
  14953. _vrDisplay: any;
  14954. /** @hidden */
  14955. _vrSupported: boolean;
  14956. /** @hidden */
  14957. _oldSize: Size;
  14958. /** @hidden */
  14959. _oldHardwareScaleFactor: number;
  14960. /** @hidden */
  14961. _vrExclusivePointerMode: boolean;
  14962. /** @hidden */
  14963. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14964. /** @hidden */
  14965. _onVRDisplayPointerRestricted: () => void;
  14966. /** @hidden */
  14967. _onVRDisplayPointerUnrestricted: () => void;
  14968. /** @hidden */
  14969. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14970. /** @hidden */
  14971. _onVrDisplayDisconnect: Nullable<() => void>;
  14972. /** @hidden */
  14973. _onVrDisplayPresentChange: Nullable<() => void>;
  14974. /**
  14975. * Observable signaled when VR display mode changes
  14976. */
  14977. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14978. /**
  14979. * Observable signaled when VR request present is complete
  14980. */
  14981. onVRRequestPresentComplete: Observable<boolean>;
  14982. /**
  14983. * Observable signaled when VR request present starts
  14984. */
  14985. onVRRequestPresentStart: Observable<Engine>;
  14986. /**
  14987. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14988. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14989. */
  14990. isInVRExclusivePointerMode: boolean;
  14991. /**
  14992. * Gets a boolean indicating if a webVR device was detected
  14993. * @returns true if a webVR device was detected
  14994. */
  14995. isVRDevicePresent(): boolean;
  14996. /**
  14997. * Gets the current webVR device
  14998. * @returns the current webVR device (or null)
  14999. */
  15000. getVRDevice(): any;
  15001. /**
  15002. * Initializes a webVR display and starts listening to display change events
  15003. * The onVRDisplayChangedObservable will be notified upon these changes
  15004. * @returns A promise containing a VRDisplay and if vr is supported
  15005. */
  15006. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15007. /** @hidden */
  15008. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15009. /**
  15010. * Call this function to switch to webVR mode
  15011. * Will do nothing if webVR is not supported or if there is no webVR device
  15012. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15013. */
  15014. enableVR(): void;
  15015. /** @hidden */
  15016. _onVRFullScreenTriggered(): void;
  15017. }
  15018. }
  15019. }
  15020. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15021. import { Nullable } from "babylonjs/types";
  15022. import { Observable } from "babylonjs/Misc/observable";
  15023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15024. import { Scene } from "babylonjs/scene";
  15025. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15026. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15027. import { Node } from "babylonjs/node";
  15028. import { Ray } from "babylonjs/Culling/ray";
  15029. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15030. import "babylonjs/Engines/Extensions/engine.webVR";
  15031. /**
  15032. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15033. * IMPORTANT!! The data is right-hand data.
  15034. * @export
  15035. * @interface DevicePose
  15036. */
  15037. export interface DevicePose {
  15038. /**
  15039. * The position of the device, values in array are [x,y,z].
  15040. */
  15041. readonly position: Nullable<Float32Array>;
  15042. /**
  15043. * The linearVelocity of the device, values in array are [x,y,z].
  15044. */
  15045. readonly linearVelocity: Nullable<Float32Array>;
  15046. /**
  15047. * The linearAcceleration of the device, values in array are [x,y,z].
  15048. */
  15049. readonly linearAcceleration: Nullable<Float32Array>;
  15050. /**
  15051. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15052. */
  15053. readonly orientation: Nullable<Float32Array>;
  15054. /**
  15055. * The angularVelocity of the device, values in array are [x,y,z].
  15056. */
  15057. readonly angularVelocity: Nullable<Float32Array>;
  15058. /**
  15059. * The angularAcceleration of the device, values in array are [x,y,z].
  15060. */
  15061. readonly angularAcceleration: Nullable<Float32Array>;
  15062. }
  15063. /**
  15064. * Interface representing a pose controlled object in Babylon.
  15065. * A pose controlled object has both regular pose values as well as pose values
  15066. * from an external device such as a VR head mounted display
  15067. */
  15068. export interface PoseControlled {
  15069. /**
  15070. * The position of the object in babylon space.
  15071. */
  15072. position: Vector3;
  15073. /**
  15074. * The rotation quaternion of the object in babylon space.
  15075. */
  15076. rotationQuaternion: Quaternion;
  15077. /**
  15078. * The position of the device in babylon space.
  15079. */
  15080. devicePosition?: Vector3;
  15081. /**
  15082. * The rotation quaternion of the device in babylon space.
  15083. */
  15084. deviceRotationQuaternion: Quaternion;
  15085. /**
  15086. * The raw pose coming from the device.
  15087. */
  15088. rawPose: Nullable<DevicePose>;
  15089. /**
  15090. * The scale of the device to be used when translating from device space to babylon space.
  15091. */
  15092. deviceScaleFactor: number;
  15093. /**
  15094. * Updates the poseControlled values based on the input device pose.
  15095. * @param poseData the pose data to update the object with
  15096. */
  15097. updateFromDevice(poseData: DevicePose): void;
  15098. }
  15099. /**
  15100. * Set of options to customize the webVRCamera
  15101. */
  15102. export interface WebVROptions {
  15103. /**
  15104. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15105. */
  15106. trackPosition?: boolean;
  15107. /**
  15108. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15109. */
  15110. positionScale?: number;
  15111. /**
  15112. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15113. */
  15114. displayName?: string;
  15115. /**
  15116. * Should the native controller meshes be initialized. (default: true)
  15117. */
  15118. controllerMeshes?: boolean;
  15119. /**
  15120. * Creating a default HemiLight only on controllers. (default: true)
  15121. */
  15122. defaultLightingOnControllers?: boolean;
  15123. /**
  15124. * If you don't want to use the default VR button of the helper. (default: false)
  15125. */
  15126. useCustomVRButton?: boolean;
  15127. /**
  15128. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15129. */
  15130. customVRButton?: HTMLButtonElement;
  15131. /**
  15132. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15133. */
  15134. rayLength?: number;
  15135. /**
  15136. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15137. */
  15138. defaultHeight?: number;
  15139. /**
  15140. * If multiview should be used if availible (default: false)
  15141. */
  15142. useMultiview?: boolean;
  15143. }
  15144. /**
  15145. * This represents a WebVR camera.
  15146. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15147. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15148. */
  15149. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15150. private webVROptions;
  15151. /**
  15152. * @hidden
  15153. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15154. */
  15155. _vrDevice: any;
  15156. /**
  15157. * The rawPose of the vrDevice.
  15158. */
  15159. rawPose: Nullable<DevicePose>;
  15160. private _onVREnabled;
  15161. private _specsVersion;
  15162. private _attached;
  15163. private _frameData;
  15164. protected _descendants: Array<Node>;
  15165. private _deviceRoomPosition;
  15166. /** @hidden */
  15167. _deviceRoomRotationQuaternion: Quaternion;
  15168. private _standingMatrix;
  15169. /**
  15170. * Represents device position in babylon space.
  15171. */
  15172. devicePosition: Vector3;
  15173. /**
  15174. * Represents device rotation in babylon space.
  15175. */
  15176. deviceRotationQuaternion: Quaternion;
  15177. /**
  15178. * The scale of the device to be used when translating from device space to babylon space.
  15179. */
  15180. deviceScaleFactor: number;
  15181. private _deviceToWorld;
  15182. private _worldToDevice;
  15183. /**
  15184. * References to the webVR controllers for the vrDevice.
  15185. */
  15186. controllers: Array<WebVRController>;
  15187. /**
  15188. * Emits an event when a controller is attached.
  15189. */
  15190. onControllersAttachedObservable: Observable<WebVRController[]>;
  15191. /**
  15192. * Emits an event when a controller's mesh has been loaded;
  15193. */
  15194. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15195. /**
  15196. * Emits an event when the HMD's pose has been updated.
  15197. */
  15198. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15199. private _poseSet;
  15200. /**
  15201. * If the rig cameras be used as parent instead of this camera.
  15202. */
  15203. rigParenting: boolean;
  15204. private _lightOnControllers;
  15205. private _defaultHeight?;
  15206. /**
  15207. * Instantiates a WebVRFreeCamera.
  15208. * @param name The name of the WebVRFreeCamera
  15209. * @param position The starting anchor position for the camera
  15210. * @param scene The scene the camera belongs to
  15211. * @param webVROptions a set of customizable options for the webVRCamera
  15212. */
  15213. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15214. /**
  15215. * Gets the device distance from the ground in meters.
  15216. * @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.
  15217. */
  15218. deviceDistanceToRoomGround(): number;
  15219. /**
  15220. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15221. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15222. */
  15223. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15224. /**
  15225. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15226. * @returns A promise with a boolean set to if the standing matrix is supported.
  15227. */
  15228. useStandingMatrixAsync(): Promise<boolean>;
  15229. /**
  15230. * Disposes the camera
  15231. */
  15232. dispose(): void;
  15233. /**
  15234. * Gets a vrController by name.
  15235. * @param name The name of the controller to retreive
  15236. * @returns the controller matching the name specified or null if not found
  15237. */
  15238. getControllerByName(name: string): Nullable<WebVRController>;
  15239. private _leftController;
  15240. /**
  15241. * The controller corresponding to the users left hand.
  15242. */
  15243. readonly leftController: Nullable<WebVRController>;
  15244. private _rightController;
  15245. /**
  15246. * The controller corresponding to the users right hand.
  15247. */
  15248. readonly rightController: Nullable<WebVRController>;
  15249. /**
  15250. * Casts a ray forward from the vrCamera's gaze.
  15251. * @param length Length of the ray (default: 100)
  15252. * @returns the ray corresponding to the gaze
  15253. */
  15254. getForwardRay(length?: number): Ray;
  15255. /**
  15256. * @hidden
  15257. * Updates the camera based on device's frame data
  15258. */
  15259. _checkInputs(): void;
  15260. /**
  15261. * Updates the poseControlled values based on the input device pose.
  15262. * @param poseData Pose coming from the device
  15263. */
  15264. updateFromDevice(poseData: DevicePose): void;
  15265. private _htmlElementAttached;
  15266. private _detachIfAttached;
  15267. /**
  15268. * WebVR's attach control will start broadcasting frames to the device.
  15269. * Note that in certain browsers (chrome for example) this function must be called
  15270. * within a user-interaction callback. Example:
  15271. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15272. *
  15273. * @param element html element to attach the vrDevice to
  15274. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15275. */
  15276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15277. /**
  15278. * Detaches the camera from the html element and disables VR
  15279. *
  15280. * @param element html element to detach from
  15281. */
  15282. detachControl(element: HTMLElement): void;
  15283. /**
  15284. * @returns the name of this class
  15285. */
  15286. getClassName(): string;
  15287. /**
  15288. * Calls resetPose on the vrDisplay
  15289. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15290. */
  15291. resetToCurrentRotation(): void;
  15292. /**
  15293. * @hidden
  15294. * Updates the rig cameras (left and right eye)
  15295. */
  15296. _updateRigCameras(): void;
  15297. private _workingVector;
  15298. private _oneVector;
  15299. private _workingMatrix;
  15300. private updateCacheCalled;
  15301. private _correctPositionIfNotTrackPosition;
  15302. /**
  15303. * @hidden
  15304. * Updates the cached values of the camera
  15305. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15306. */
  15307. _updateCache(ignoreParentClass?: boolean): void;
  15308. /**
  15309. * @hidden
  15310. * Get current device position in babylon world
  15311. */
  15312. _computeDevicePosition(): void;
  15313. /**
  15314. * Updates the current device position and rotation in the babylon world
  15315. */
  15316. update(): void;
  15317. /**
  15318. * @hidden
  15319. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15320. * @returns an identity matrix
  15321. */
  15322. _getViewMatrix(): Matrix;
  15323. private _tmpMatrix;
  15324. /**
  15325. * This function is called by the two RIG cameras.
  15326. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15327. * @hidden
  15328. */
  15329. _getWebVRViewMatrix(): Matrix;
  15330. /** @hidden */
  15331. _getWebVRProjectionMatrix(): Matrix;
  15332. private _onGamepadConnectedObserver;
  15333. private _onGamepadDisconnectedObserver;
  15334. private _updateCacheWhenTrackingDisabledObserver;
  15335. /**
  15336. * Initializes the controllers and their meshes
  15337. */
  15338. initControllers(): void;
  15339. }
  15340. }
  15341. declare module "babylonjs/PostProcesses/postProcess" {
  15342. import { Nullable } from "babylonjs/types";
  15343. import { SmartArray } from "babylonjs/Misc/smartArray";
  15344. import { Observable } from "babylonjs/Misc/observable";
  15345. import { Vector2 } from "babylonjs/Maths/math.vector";
  15346. import { Camera } from "babylonjs/Cameras/camera";
  15347. import { Effect } from "babylonjs/Materials/effect";
  15348. import "babylonjs/Shaders/postprocess.vertex";
  15349. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15350. import { Engine } from "babylonjs/Engines/engine";
  15351. import { Color4 } from "babylonjs/Maths/math.color";
  15352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15353. /**
  15354. * Size options for a post process
  15355. */
  15356. export type PostProcessOptions = {
  15357. width: number;
  15358. height: number;
  15359. };
  15360. /**
  15361. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15362. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15363. */
  15364. export class PostProcess {
  15365. /** Name of the PostProcess. */
  15366. name: string;
  15367. /**
  15368. * Gets or sets the unique id of the post process
  15369. */
  15370. uniqueId: number;
  15371. /**
  15372. * Width of the texture to apply the post process on
  15373. */
  15374. width: number;
  15375. /**
  15376. * Height of the texture to apply the post process on
  15377. */
  15378. height: number;
  15379. /**
  15380. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15381. * @hidden
  15382. */
  15383. _outputTexture: Nullable<InternalTexture>;
  15384. /**
  15385. * Sampling mode used by the shader
  15386. * See https://doc.babylonjs.com/classes/3.1/texture
  15387. */
  15388. renderTargetSamplingMode: number;
  15389. /**
  15390. * Clear color to use when screen clearing
  15391. */
  15392. clearColor: Color4;
  15393. /**
  15394. * If the buffer needs to be cleared before applying the post process. (default: true)
  15395. * Should be set to false if shader will overwrite all previous pixels.
  15396. */
  15397. autoClear: boolean;
  15398. /**
  15399. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15400. */
  15401. alphaMode: number;
  15402. /**
  15403. * Sets the setAlphaBlendConstants of the babylon engine
  15404. */
  15405. alphaConstants: Color4;
  15406. /**
  15407. * Animations to be used for the post processing
  15408. */
  15409. animations: import("babylonjs/Animations/animation").Animation[];
  15410. /**
  15411. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15412. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15413. */
  15414. enablePixelPerfectMode: boolean;
  15415. /**
  15416. * Force the postprocess to be applied without taking in account viewport
  15417. */
  15418. forceFullscreenViewport: boolean;
  15419. /**
  15420. * List of inspectable custom properties (used by the Inspector)
  15421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15422. */
  15423. inspectableCustomProperties: IInspectable[];
  15424. /**
  15425. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15426. *
  15427. * | Value | Type | Description |
  15428. * | ----- | ----------------------------------- | ----------- |
  15429. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15430. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15431. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15432. *
  15433. */
  15434. scaleMode: number;
  15435. /**
  15436. * Force textures to be a power of two (default: false)
  15437. */
  15438. alwaysForcePOT: boolean;
  15439. private _samples;
  15440. /**
  15441. * Number of sample textures (default: 1)
  15442. */
  15443. samples: number;
  15444. /**
  15445. * Modify the scale of the post process to be the same as the viewport (default: false)
  15446. */
  15447. adaptScaleToCurrentViewport: boolean;
  15448. private _camera;
  15449. private _scene;
  15450. private _engine;
  15451. private _options;
  15452. private _reusable;
  15453. private _textureType;
  15454. /**
  15455. * Smart array of input and output textures for the post process.
  15456. * @hidden
  15457. */
  15458. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15459. /**
  15460. * The index in _textures that corresponds to the output texture.
  15461. * @hidden
  15462. */
  15463. _currentRenderTextureInd: number;
  15464. private _effect;
  15465. private _samplers;
  15466. private _fragmentUrl;
  15467. private _vertexUrl;
  15468. private _parameters;
  15469. private _scaleRatio;
  15470. protected _indexParameters: any;
  15471. private _shareOutputWithPostProcess;
  15472. private _texelSize;
  15473. private _forcedOutputTexture;
  15474. /**
  15475. * Returns the fragment url or shader name used in the post process.
  15476. * @returns the fragment url or name in the shader store.
  15477. */
  15478. getEffectName(): string;
  15479. /**
  15480. * An event triggered when the postprocess is activated.
  15481. */
  15482. onActivateObservable: Observable<Camera>;
  15483. private _onActivateObserver;
  15484. /**
  15485. * A function that is added to the onActivateObservable
  15486. */
  15487. onActivate: Nullable<(camera: Camera) => void>;
  15488. /**
  15489. * An event triggered when the postprocess changes its size.
  15490. */
  15491. onSizeChangedObservable: Observable<PostProcess>;
  15492. private _onSizeChangedObserver;
  15493. /**
  15494. * A function that is added to the onSizeChangedObservable
  15495. */
  15496. onSizeChanged: (postProcess: PostProcess) => void;
  15497. /**
  15498. * An event triggered when the postprocess applies its effect.
  15499. */
  15500. onApplyObservable: Observable<Effect>;
  15501. private _onApplyObserver;
  15502. /**
  15503. * A function that is added to the onApplyObservable
  15504. */
  15505. onApply: (effect: Effect) => void;
  15506. /**
  15507. * An event triggered before rendering the postprocess
  15508. */
  15509. onBeforeRenderObservable: Observable<Effect>;
  15510. private _onBeforeRenderObserver;
  15511. /**
  15512. * A function that is added to the onBeforeRenderObservable
  15513. */
  15514. onBeforeRender: (effect: Effect) => void;
  15515. /**
  15516. * An event triggered after rendering the postprocess
  15517. */
  15518. onAfterRenderObservable: Observable<Effect>;
  15519. private _onAfterRenderObserver;
  15520. /**
  15521. * A function that is added to the onAfterRenderObservable
  15522. */
  15523. onAfterRender: (efect: Effect) => void;
  15524. /**
  15525. * 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
  15526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15527. */
  15528. inputTexture: InternalTexture;
  15529. /**
  15530. * Gets the camera which post process is applied to.
  15531. * @returns The camera the post process is applied to.
  15532. */
  15533. getCamera(): Camera;
  15534. /**
  15535. * Gets the texel size of the postprocess.
  15536. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15537. */
  15538. readonly texelSize: Vector2;
  15539. /**
  15540. * Creates a new instance PostProcess
  15541. * @param name The name of the PostProcess.
  15542. * @param fragmentUrl The url of the fragment shader to be used.
  15543. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15544. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15545. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15546. * @param camera The camera to apply the render pass to.
  15547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15548. * @param engine The engine which the post process will be applied. (default: current engine)
  15549. * @param reusable If the post process can be reused on the same frame. (default: false)
  15550. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15551. * @param textureType Type of textures used when performing the post process. (default: 0)
  15552. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15553. * @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
  15554. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15555. */
  15556. constructor(
  15557. /** Name of the PostProcess. */
  15558. 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);
  15559. /**
  15560. * Gets a string idenfifying the name of the class
  15561. * @returns "PostProcess" string
  15562. */
  15563. getClassName(): string;
  15564. /**
  15565. * Gets the engine which this post process belongs to.
  15566. * @returns The engine the post process was enabled with.
  15567. */
  15568. getEngine(): Engine;
  15569. /**
  15570. * The effect that is created when initializing the post process.
  15571. * @returns The created effect corresponding the the postprocess.
  15572. */
  15573. getEffect(): Effect;
  15574. /**
  15575. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15576. * @param postProcess The post process to share the output with.
  15577. * @returns This post process.
  15578. */
  15579. shareOutputWith(postProcess: PostProcess): PostProcess;
  15580. /**
  15581. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15582. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15583. */
  15584. useOwnOutput(): void;
  15585. /**
  15586. * Updates the effect with the current post process compile time values and recompiles the shader.
  15587. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15588. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15589. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15590. * @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
  15591. * @param onCompiled Called when the shader has been compiled.
  15592. * @param onError Called if there is an error when compiling a shader.
  15593. */
  15594. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15595. /**
  15596. * The post process is reusable if it can be used multiple times within one frame.
  15597. * @returns If the post process is reusable
  15598. */
  15599. isReusable(): boolean;
  15600. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15601. markTextureDirty(): void;
  15602. /**
  15603. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15604. * 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.
  15605. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15606. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15607. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15608. * @returns The target texture that was bound to be written to.
  15609. */
  15610. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15611. /**
  15612. * If the post process is supported.
  15613. */
  15614. readonly isSupported: boolean;
  15615. /**
  15616. * The aspect ratio of the output texture.
  15617. */
  15618. readonly aspectRatio: number;
  15619. /**
  15620. * Get a value indicating if the post-process is ready to be used
  15621. * @returns true if the post-process is ready (shader is compiled)
  15622. */
  15623. isReady(): boolean;
  15624. /**
  15625. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15626. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15627. */
  15628. apply(): Nullable<Effect>;
  15629. private _disposeTextures;
  15630. /**
  15631. * Disposes the post process.
  15632. * @param camera The camera to dispose the post process on.
  15633. */
  15634. dispose(camera?: Camera): void;
  15635. }
  15636. }
  15637. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15638. /** @hidden */
  15639. export var kernelBlurVaryingDeclaration: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15645. /** @hidden */
  15646. export var kernelBlurFragment: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15652. /** @hidden */
  15653. export var kernelBlurFragment2: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15659. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15660. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15661. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15662. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15663. /** @hidden */
  15664. export var kernelBlurPixelShader: {
  15665. name: string;
  15666. shader: string;
  15667. };
  15668. }
  15669. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15670. /** @hidden */
  15671. export var kernelBlurVertex: {
  15672. name: string;
  15673. shader: string;
  15674. };
  15675. }
  15676. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15677. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15678. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15679. /** @hidden */
  15680. export var kernelBlurVertexShader: {
  15681. name: string;
  15682. shader: string;
  15683. };
  15684. }
  15685. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15686. import { Vector2 } from "babylonjs/Maths/math.vector";
  15687. import { Nullable } from "babylonjs/types";
  15688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15689. import { Camera } from "babylonjs/Cameras/camera";
  15690. import { Effect } from "babylonjs/Materials/effect";
  15691. import { Engine } from "babylonjs/Engines/engine";
  15692. import "babylonjs/Shaders/kernelBlur.fragment";
  15693. import "babylonjs/Shaders/kernelBlur.vertex";
  15694. /**
  15695. * The Blur Post Process which blurs an image based on a kernel and direction.
  15696. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15697. */
  15698. export class BlurPostProcess extends PostProcess {
  15699. /** The direction in which to blur the image. */
  15700. direction: Vector2;
  15701. private blockCompilation;
  15702. protected _kernel: number;
  15703. protected _idealKernel: number;
  15704. protected _packedFloat: boolean;
  15705. private _staticDefines;
  15706. /**
  15707. * Sets the length in pixels of the blur sample region
  15708. */
  15709. /**
  15710. * Gets the length in pixels of the blur sample region
  15711. */
  15712. kernel: number;
  15713. /**
  15714. * Sets wether or not the blur needs to unpack/repack floats
  15715. */
  15716. /**
  15717. * Gets wether or not the blur is unpacking/repacking floats
  15718. */
  15719. packedFloat: boolean;
  15720. /**
  15721. * Creates a new instance BlurPostProcess
  15722. * @param name The name of the effect.
  15723. * @param direction The direction in which to blur the image.
  15724. * @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.
  15725. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15726. * @param camera The camera to apply the render pass to.
  15727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15728. * @param engine The engine which the post process will be applied. (default: current engine)
  15729. * @param reusable If the post process can be reused on the same frame. (default: false)
  15730. * @param textureType Type of textures used when performing the post process. (default: 0)
  15731. * @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)
  15732. */
  15733. constructor(name: string,
  15734. /** The direction in which to blur the image. */
  15735. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15736. /**
  15737. * Updates the effect with the current post process compile time values and recompiles the shader.
  15738. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15739. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15740. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15741. * @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
  15742. * @param onCompiled Called when the shader has been compiled.
  15743. * @param onError Called if there is an error when compiling a shader.
  15744. */
  15745. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15746. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15747. /**
  15748. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15749. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15750. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15751. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15752. * The gaps between physical kernels are compensated for in the weighting of the samples
  15753. * @param idealKernel Ideal blur kernel.
  15754. * @return Nearest best kernel.
  15755. */
  15756. protected _nearestBestKernel(idealKernel: number): number;
  15757. /**
  15758. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15759. * @param x The point on the Gaussian distribution to sample.
  15760. * @return the value of the Gaussian function at x.
  15761. */
  15762. protected _gaussianWeight(x: number): number;
  15763. /**
  15764. * Generates a string that can be used as a floating point number in GLSL.
  15765. * @param x Value to print.
  15766. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15767. * @return GLSL float string.
  15768. */
  15769. protected _glslFloat(x: number, decimalFigures?: number): string;
  15770. }
  15771. }
  15772. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15773. import { Scene } from "babylonjs/scene";
  15774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15775. import { Plane } from "babylonjs/Maths/math.plane";
  15776. /**
  15777. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15778. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15779. * You can then easily use it as a reflectionTexture on a flat surface.
  15780. * In case the surface is not a plane, please consider relying on reflection probes.
  15781. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15782. */
  15783. export class MirrorTexture extends RenderTargetTexture {
  15784. private scene;
  15785. /**
  15786. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15787. * 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.
  15788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15789. */
  15790. mirrorPlane: Plane;
  15791. /**
  15792. * Define the blur ratio used to blur the reflection if needed.
  15793. */
  15794. blurRatio: number;
  15795. /**
  15796. * Define the adaptive blur kernel used to blur the reflection if needed.
  15797. * This will autocompute the closest best match for the `blurKernel`
  15798. */
  15799. adaptiveBlurKernel: number;
  15800. /**
  15801. * Define the blur kernel used to blur the reflection if needed.
  15802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15803. */
  15804. blurKernel: number;
  15805. /**
  15806. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15807. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15808. */
  15809. blurKernelX: number;
  15810. /**
  15811. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15812. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15813. */
  15814. blurKernelY: number;
  15815. private _autoComputeBlurKernel;
  15816. protected _onRatioRescale(): void;
  15817. private _updateGammaSpace;
  15818. private _imageProcessingConfigChangeObserver;
  15819. private _transformMatrix;
  15820. private _mirrorMatrix;
  15821. private _savedViewMatrix;
  15822. private _blurX;
  15823. private _blurY;
  15824. private _adaptiveBlurKernel;
  15825. private _blurKernelX;
  15826. private _blurKernelY;
  15827. private _blurRatio;
  15828. /**
  15829. * Instantiates a Mirror Texture.
  15830. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15831. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15832. * You can then easily use it as a reflectionTexture on a flat surface.
  15833. * In case the surface is not a plane, please consider relying on reflection probes.
  15834. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15835. * @param name
  15836. * @param size
  15837. * @param scene
  15838. * @param generateMipMaps
  15839. * @param type
  15840. * @param samplingMode
  15841. * @param generateDepthBuffer
  15842. */
  15843. constructor(name: string, size: number | {
  15844. width: number;
  15845. height: number;
  15846. } | {
  15847. ratio: number;
  15848. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15849. private _preparePostProcesses;
  15850. /**
  15851. * Clone the mirror texture.
  15852. * @returns the cloned texture
  15853. */
  15854. clone(): MirrorTexture;
  15855. /**
  15856. * Serialize the texture to a JSON representation you could use in Parse later on
  15857. * @returns the serialized JSON representation
  15858. */
  15859. serialize(): any;
  15860. /**
  15861. * Dispose the texture and release its associated resources.
  15862. */
  15863. dispose(): void;
  15864. }
  15865. }
  15866. declare module "babylonjs/Materials/Textures/texture" {
  15867. import { Observable } from "babylonjs/Misc/observable";
  15868. import { Nullable } from "babylonjs/types";
  15869. import { Scene } from "babylonjs/scene";
  15870. import { Matrix } from "babylonjs/Maths/math.vector";
  15871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15872. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15873. import { Engine } from "babylonjs/Engines/engine";
  15874. /**
  15875. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15876. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15877. */
  15878. export class Texture extends BaseTexture {
  15879. /** @hidden */
  15880. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15881. /** @hidden */
  15882. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15883. /** @hidden */
  15884. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15885. /** nearest is mag = nearest and min = nearest and mip = linear */
  15886. static readonly NEAREST_SAMPLINGMODE: number;
  15887. /** nearest is mag = nearest and min = nearest and mip = linear */
  15888. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15889. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15890. static readonly BILINEAR_SAMPLINGMODE: number;
  15891. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15892. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15893. /** Trilinear is mag = linear and min = linear and mip = linear */
  15894. static readonly TRILINEAR_SAMPLINGMODE: number;
  15895. /** Trilinear is mag = linear and min = linear and mip = linear */
  15896. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15897. /** mag = nearest and min = nearest and mip = nearest */
  15898. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15899. /** mag = nearest and min = linear and mip = nearest */
  15900. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15901. /** mag = nearest and min = linear and mip = linear */
  15902. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15903. /** mag = nearest and min = linear and mip = none */
  15904. static readonly NEAREST_LINEAR: number;
  15905. /** mag = nearest and min = nearest and mip = none */
  15906. static readonly NEAREST_NEAREST: number;
  15907. /** mag = linear and min = nearest and mip = nearest */
  15908. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15909. /** mag = linear and min = nearest and mip = linear */
  15910. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15911. /** mag = linear and min = linear and mip = none */
  15912. static readonly LINEAR_LINEAR: number;
  15913. /** mag = linear and min = nearest and mip = none */
  15914. static readonly LINEAR_NEAREST: number;
  15915. /** Explicit coordinates mode */
  15916. static readonly EXPLICIT_MODE: number;
  15917. /** Spherical coordinates mode */
  15918. static readonly SPHERICAL_MODE: number;
  15919. /** Planar coordinates mode */
  15920. static readonly PLANAR_MODE: number;
  15921. /** Cubic coordinates mode */
  15922. static readonly CUBIC_MODE: number;
  15923. /** Projection coordinates mode */
  15924. static readonly PROJECTION_MODE: number;
  15925. /** Inverse Cubic coordinates mode */
  15926. static readonly SKYBOX_MODE: number;
  15927. /** Inverse Cubic coordinates mode */
  15928. static readonly INVCUBIC_MODE: number;
  15929. /** Equirectangular coordinates mode */
  15930. static readonly EQUIRECTANGULAR_MODE: number;
  15931. /** Equirectangular Fixed coordinates mode */
  15932. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15933. /** Equirectangular Fixed Mirrored coordinates mode */
  15934. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15935. /** Texture is not repeating outside of 0..1 UVs */
  15936. static readonly CLAMP_ADDRESSMODE: number;
  15937. /** Texture is repeating outside of 0..1 UVs */
  15938. static readonly WRAP_ADDRESSMODE: number;
  15939. /** Texture is repeating and mirrored */
  15940. static readonly MIRROR_ADDRESSMODE: number;
  15941. /**
  15942. * 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
  15943. */
  15944. static UseSerializedUrlIfAny: boolean;
  15945. /**
  15946. * Define the url of the texture.
  15947. */
  15948. url: Nullable<string>;
  15949. /**
  15950. * Define an offset on the texture to offset the u coordinates of the UVs
  15951. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15952. */
  15953. uOffset: number;
  15954. /**
  15955. * Define an offset on the texture to offset the v coordinates of the UVs
  15956. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15957. */
  15958. vOffset: number;
  15959. /**
  15960. * Define an offset on the texture to scale the u coordinates of the UVs
  15961. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15962. */
  15963. uScale: number;
  15964. /**
  15965. * Define an offset on the texture to scale the v coordinates of the UVs
  15966. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15967. */
  15968. vScale: number;
  15969. /**
  15970. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15971. * @see http://doc.babylonjs.com/how_to/more_materials
  15972. */
  15973. uAng: number;
  15974. /**
  15975. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15976. * @see http://doc.babylonjs.com/how_to/more_materials
  15977. */
  15978. vAng: number;
  15979. /**
  15980. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15981. * @see http://doc.babylonjs.com/how_to/more_materials
  15982. */
  15983. wAng: number;
  15984. /**
  15985. * Defines the center of rotation (U)
  15986. */
  15987. uRotationCenter: number;
  15988. /**
  15989. * Defines the center of rotation (V)
  15990. */
  15991. vRotationCenter: number;
  15992. /**
  15993. * Defines the center of rotation (W)
  15994. */
  15995. wRotationCenter: number;
  15996. /**
  15997. * Are mip maps generated for this texture or not.
  15998. */
  15999. readonly noMipmap: boolean;
  16000. /**
  16001. * List of inspectable custom properties (used by the Inspector)
  16002. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16003. */
  16004. inspectableCustomProperties: Nullable<IInspectable[]>;
  16005. private _noMipmap;
  16006. /** @hidden */
  16007. _invertY: boolean;
  16008. private _rowGenerationMatrix;
  16009. private _cachedTextureMatrix;
  16010. private _projectionModeMatrix;
  16011. private _t0;
  16012. private _t1;
  16013. private _t2;
  16014. private _cachedUOffset;
  16015. private _cachedVOffset;
  16016. private _cachedUScale;
  16017. private _cachedVScale;
  16018. private _cachedUAng;
  16019. private _cachedVAng;
  16020. private _cachedWAng;
  16021. private _cachedProjectionMatrixId;
  16022. private _cachedCoordinatesMode;
  16023. /** @hidden */
  16024. protected _initialSamplingMode: number;
  16025. /** @hidden */
  16026. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16027. private _deleteBuffer;
  16028. protected _format: Nullable<number>;
  16029. private _delayedOnLoad;
  16030. private _delayedOnError;
  16031. /**
  16032. * Observable triggered once the texture has been loaded.
  16033. */
  16034. onLoadObservable: Observable<Texture>;
  16035. protected _isBlocking: boolean;
  16036. /**
  16037. * Is the texture preventing material to render while loading.
  16038. * If false, a default texture will be used instead of the loading one during the preparation step.
  16039. */
  16040. isBlocking: boolean;
  16041. /**
  16042. * Get the current sampling mode associated with the texture.
  16043. */
  16044. readonly samplingMode: number;
  16045. /**
  16046. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16047. */
  16048. readonly invertY: boolean;
  16049. /**
  16050. * Instantiates a new texture.
  16051. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16052. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16053. * @param url define the url of the picture to load as a texture
  16054. * @param scene define the scene or engine the texture will belong to
  16055. * @param noMipmap define if the texture will require mip maps or not
  16056. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16057. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16058. * @param onLoad define a callback triggered when the texture has been loaded
  16059. * @param onError define a callback triggered when an error occurred during the loading session
  16060. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16061. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16062. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16063. */
  16064. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16065. /**
  16066. * Update the url (and optional buffer) of this texture if url was null during construction.
  16067. * @param url the url of the texture
  16068. * @param buffer the buffer of the texture (defaults to null)
  16069. * @param onLoad callback called when the texture is loaded (defaults to null)
  16070. */
  16071. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16072. /**
  16073. * Finish the loading sequence of a texture flagged as delayed load.
  16074. * @hidden
  16075. */
  16076. delayLoad(): void;
  16077. private _prepareRowForTextureGeneration;
  16078. /**
  16079. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16080. * @returns the transform matrix of the texture.
  16081. */
  16082. getTextureMatrix(): Matrix;
  16083. /**
  16084. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16085. * @returns The reflection texture transform
  16086. */
  16087. getReflectionTextureMatrix(): Matrix;
  16088. /**
  16089. * Clones the texture.
  16090. * @returns the cloned texture
  16091. */
  16092. clone(): Texture;
  16093. /**
  16094. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16095. * @returns The JSON representation of the texture
  16096. */
  16097. serialize(): any;
  16098. /**
  16099. * Get the current class name of the texture useful for serialization or dynamic coding.
  16100. * @returns "Texture"
  16101. */
  16102. getClassName(): string;
  16103. /**
  16104. * Dispose the texture and release its associated resources.
  16105. */
  16106. dispose(): void;
  16107. /**
  16108. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16109. * @param parsedTexture Define the JSON representation of the texture
  16110. * @param scene Define the scene the parsed texture should be instantiated in
  16111. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16112. * @returns The parsed texture if successful
  16113. */
  16114. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16115. /**
  16116. * Creates a texture from its base 64 representation.
  16117. * @param data Define the base64 payload without the data: prefix
  16118. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16119. * @param scene Define the scene the texture should belong to
  16120. * @param noMipmap Forces the texture to not create mip map information if true
  16121. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16122. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16123. * @param onLoad define a callback triggered when the texture has been loaded
  16124. * @param onError define a callback triggered when an error occurred during the loading session
  16125. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16126. * @returns the created texture
  16127. */
  16128. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16129. /**
  16130. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16131. * @param data Define the base64 payload without the data: prefix
  16132. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16133. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16134. * @param scene Define the scene the texture should belong to
  16135. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16136. * @param noMipmap Forces the texture to not create mip map information if true
  16137. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16138. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16139. * @param onLoad define a callback triggered when the texture has been loaded
  16140. * @param onError define a callback triggered when an error occurred during the loading session
  16141. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16142. * @returns the created texture
  16143. */
  16144. 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;
  16145. }
  16146. }
  16147. declare module "babylonjs/PostProcesses/postProcessManager" {
  16148. import { Nullable } from "babylonjs/types";
  16149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16151. import { Scene } from "babylonjs/scene";
  16152. /**
  16153. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16154. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16155. */
  16156. export class PostProcessManager {
  16157. private _scene;
  16158. private _indexBuffer;
  16159. private _vertexBuffers;
  16160. /**
  16161. * Creates a new instance PostProcess
  16162. * @param scene The scene that the post process is associated with.
  16163. */
  16164. constructor(scene: Scene);
  16165. private _prepareBuffers;
  16166. private _buildIndexBuffer;
  16167. /**
  16168. * Rebuilds the vertex buffers of the manager.
  16169. * @hidden
  16170. */
  16171. _rebuild(): void;
  16172. /**
  16173. * Prepares a frame to be run through a post process.
  16174. * @param sourceTexture The input texture to the post procesess. (default: null)
  16175. * @param postProcesses An array of post processes to be run. (default: null)
  16176. * @returns True if the post processes were able to be run.
  16177. * @hidden
  16178. */
  16179. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16180. /**
  16181. * Manually render a set of post processes to a texture.
  16182. * @param postProcesses An array of post processes to be run.
  16183. * @param targetTexture The target texture to render to.
  16184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16185. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16186. * @param lodLevel defines which lod of the texture to render to
  16187. */
  16188. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16189. /**
  16190. * Finalize the result of the output of the postprocesses.
  16191. * @param doNotPresent If true the result will not be displayed to the screen.
  16192. * @param targetTexture The target texture to render to.
  16193. * @param faceIndex The index of the face to bind the target texture to.
  16194. * @param postProcesses The array of post processes to render.
  16195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16196. * @hidden
  16197. */
  16198. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16199. /**
  16200. * Disposes of the post process manager.
  16201. */
  16202. dispose(): void;
  16203. }
  16204. }
  16205. declare module "babylonjs/Misc/gradients" {
  16206. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16207. /** Interface used by value gradients (color, factor, ...) */
  16208. export interface IValueGradient {
  16209. /**
  16210. * Gets or sets the gradient value (between 0 and 1)
  16211. */
  16212. gradient: number;
  16213. }
  16214. /** Class used to store color4 gradient */
  16215. export class ColorGradient implements IValueGradient {
  16216. /**
  16217. * Gets or sets the gradient value (between 0 and 1)
  16218. */
  16219. gradient: number;
  16220. /**
  16221. * Gets or sets first associated color
  16222. */
  16223. color1: Color4;
  16224. /**
  16225. * Gets or sets second associated color
  16226. */
  16227. color2?: Color4;
  16228. /**
  16229. * Will get a color picked randomly between color1 and color2.
  16230. * If color2 is undefined then color1 will be used
  16231. * @param result defines the target Color4 to store the result in
  16232. */
  16233. getColorToRef(result: Color4): void;
  16234. }
  16235. /** Class used to store color 3 gradient */
  16236. export class Color3Gradient implements IValueGradient {
  16237. /**
  16238. * Gets or sets the gradient value (between 0 and 1)
  16239. */
  16240. gradient: number;
  16241. /**
  16242. * Gets or sets the associated color
  16243. */
  16244. color: Color3;
  16245. }
  16246. /** Class used to store factor gradient */
  16247. export class FactorGradient implements IValueGradient {
  16248. /**
  16249. * Gets or sets the gradient value (between 0 and 1)
  16250. */
  16251. gradient: number;
  16252. /**
  16253. * Gets or sets first associated factor
  16254. */
  16255. factor1: number;
  16256. /**
  16257. * Gets or sets second associated factor
  16258. */
  16259. factor2?: number;
  16260. /**
  16261. * Will get a number picked randomly between factor1 and factor2.
  16262. * If factor2 is undefined then factor1 will be used
  16263. * @returns the picked number
  16264. */
  16265. getFactor(): number;
  16266. }
  16267. /**
  16268. * Helper used to simplify some generic gradient tasks
  16269. */
  16270. export class GradientHelper {
  16271. /**
  16272. * Gets the current gradient from an array of IValueGradient
  16273. * @param ratio defines the current ratio to get
  16274. * @param gradients defines the array of IValueGradient
  16275. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16276. */
  16277. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16278. }
  16279. }
  16280. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16281. import { Scene } from "babylonjs/scene";
  16282. import { ISceneComponent } from "babylonjs/sceneComponent";
  16283. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16284. module "babylonjs/abstractScene" {
  16285. interface AbstractScene {
  16286. /**
  16287. * The list of procedural textures added to the scene
  16288. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16289. */
  16290. proceduralTextures: Array<ProceduralTexture>;
  16291. }
  16292. }
  16293. /**
  16294. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16295. * in a given scene.
  16296. */
  16297. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16298. /**
  16299. * The component name helpfull to identify the component in the list of scene components.
  16300. */
  16301. readonly name: string;
  16302. /**
  16303. * The scene the component belongs to.
  16304. */
  16305. scene: Scene;
  16306. /**
  16307. * Creates a new instance of the component for the given scene
  16308. * @param scene Defines the scene to register the component in
  16309. */
  16310. constructor(scene: Scene);
  16311. /**
  16312. * Registers the component in a given scene
  16313. */
  16314. register(): void;
  16315. /**
  16316. * Rebuilds the elements related to this component in case of
  16317. * context lost for instance.
  16318. */
  16319. rebuild(): void;
  16320. /**
  16321. * Disposes the component and the associated ressources.
  16322. */
  16323. dispose(): void;
  16324. private _beforeClear;
  16325. }
  16326. }
  16327. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16329. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16330. module "babylonjs/Engines/engine" {
  16331. interface Engine {
  16332. /**
  16333. * Creates a new render target cube texture
  16334. * @param size defines the size of the texture
  16335. * @param options defines the options used to create the texture
  16336. * @returns a new render target cube texture stored in an InternalTexture
  16337. */
  16338. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16339. }
  16340. }
  16341. }
  16342. declare module "babylonjs/Shaders/procedural.vertex" {
  16343. /** @hidden */
  16344. export var proceduralVertexShader: {
  16345. name: string;
  16346. shader: string;
  16347. };
  16348. }
  16349. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16350. import { Observable } from "babylonjs/Misc/observable";
  16351. import { Nullable } from "babylonjs/types";
  16352. import { Scene } from "babylonjs/scene";
  16353. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16354. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16355. import { Effect } from "babylonjs/Materials/effect";
  16356. import { Texture } from "babylonjs/Materials/Textures/texture";
  16357. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16358. import "babylonjs/Shaders/procedural.vertex";
  16359. /**
  16360. * 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.
  16361. * This is the base class of any Procedural texture and contains most of the shareable code.
  16362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16363. */
  16364. export class ProceduralTexture extends Texture {
  16365. isCube: boolean;
  16366. /**
  16367. * Define if the texture is enabled or not (disabled texture will not render)
  16368. */
  16369. isEnabled: boolean;
  16370. /**
  16371. * Define if the texture must be cleared before rendering (default is true)
  16372. */
  16373. autoClear: boolean;
  16374. /**
  16375. * Callback called when the texture is generated
  16376. */
  16377. onGenerated: () => void;
  16378. /**
  16379. * Event raised when the texture is generated
  16380. */
  16381. onGeneratedObservable: Observable<ProceduralTexture>;
  16382. /** @hidden */
  16383. _generateMipMaps: boolean;
  16384. /** @hidden **/
  16385. _effect: Effect;
  16386. /** @hidden */
  16387. _textures: {
  16388. [key: string]: Texture;
  16389. };
  16390. private _size;
  16391. private _currentRefreshId;
  16392. private _refreshRate;
  16393. private _vertexBuffers;
  16394. private _indexBuffer;
  16395. private _uniforms;
  16396. private _samplers;
  16397. private _fragment;
  16398. private _floats;
  16399. private _ints;
  16400. private _floatsArrays;
  16401. private _colors3;
  16402. private _colors4;
  16403. private _vectors2;
  16404. private _vectors3;
  16405. private _matrices;
  16406. private _fallbackTexture;
  16407. private _fallbackTextureUsed;
  16408. private _engine;
  16409. private _cachedDefines;
  16410. private _contentUpdateId;
  16411. private _contentData;
  16412. /**
  16413. * Instantiates a new procedural texture.
  16414. * 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.
  16415. * This is the base class of any Procedural texture and contains most of the shareable code.
  16416. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16417. * @param name Define the name of the texture
  16418. * @param size Define the size of the texture to create
  16419. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16420. * @param scene Define the scene the texture belongs to
  16421. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16422. * @param generateMipMaps Define if the texture should creates mip maps or not
  16423. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16424. */
  16425. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16426. /**
  16427. * The effect that is created when initializing the post process.
  16428. * @returns The created effect corresponding the the postprocess.
  16429. */
  16430. getEffect(): Effect;
  16431. /**
  16432. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16433. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16434. */
  16435. getContent(): Nullable<ArrayBufferView>;
  16436. private _createIndexBuffer;
  16437. /** @hidden */
  16438. _rebuild(): void;
  16439. /**
  16440. * Resets the texture in order to recreate its associated resources.
  16441. * This can be called in case of context loss
  16442. */
  16443. reset(): void;
  16444. protected _getDefines(): string;
  16445. /**
  16446. * Is the texture ready to be used ? (rendered at least once)
  16447. * @returns true if ready, otherwise, false.
  16448. */
  16449. isReady(): boolean;
  16450. /**
  16451. * Resets the refresh counter of the texture and start bak from scratch.
  16452. * Could be useful to regenerate the texture if it is setup to render only once.
  16453. */
  16454. resetRefreshCounter(): void;
  16455. /**
  16456. * Set the fragment shader to use in order to render the texture.
  16457. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16458. */
  16459. setFragment(fragment: any): void;
  16460. /**
  16461. * Define the refresh rate of the texture or the rendering frequency.
  16462. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16463. */
  16464. refreshRate: number;
  16465. /** @hidden */
  16466. _shouldRender(): boolean;
  16467. /**
  16468. * Get the size the texture is rendering at.
  16469. * @returns the size (texture is always squared)
  16470. */
  16471. getRenderSize(): number;
  16472. /**
  16473. * Resize the texture to new value.
  16474. * @param size Define the new size the texture should have
  16475. * @param generateMipMaps Define whether the new texture should create mip maps
  16476. */
  16477. resize(size: number, generateMipMaps: boolean): void;
  16478. private _checkUniform;
  16479. /**
  16480. * Set a texture in the shader program used to render.
  16481. * @param name Define the name of the uniform samplers as defined in the shader
  16482. * @param texture Define the texture to bind to this sampler
  16483. * @return the texture itself allowing "fluent" like uniform updates
  16484. */
  16485. setTexture(name: string, texture: Texture): ProceduralTexture;
  16486. /**
  16487. * Set a float in the shader.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the texture itself allowing "fluent" like uniform updates
  16491. */
  16492. setFloat(name: string, value: number): ProceduralTexture;
  16493. /**
  16494. * Set a int in the shader.
  16495. * @param name Define the name of the uniform as defined in the shader
  16496. * @param value Define the value to give to the uniform
  16497. * @return the texture itself allowing "fluent" like uniform updates
  16498. */
  16499. setInt(name: string, value: number): ProceduralTexture;
  16500. /**
  16501. * Set an array of floats in the shader.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the texture itself allowing "fluent" like uniform updates
  16505. */
  16506. setFloats(name: string, value: number[]): ProceduralTexture;
  16507. /**
  16508. * Set a vec3 in the shader from a Color3.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the texture itself allowing "fluent" like uniform updates
  16512. */
  16513. setColor3(name: string, value: Color3): ProceduralTexture;
  16514. /**
  16515. * Set a vec4 in the shader from a Color4.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the texture itself allowing "fluent" like uniform updates
  16519. */
  16520. setColor4(name: string, value: Color4): ProceduralTexture;
  16521. /**
  16522. * Set a vec2 in the shader from a Vector2.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the texture itself allowing "fluent" like uniform updates
  16526. */
  16527. setVector2(name: string, value: Vector2): ProceduralTexture;
  16528. /**
  16529. * Set a vec3 in the shader from a Vector3.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the texture itself allowing "fluent" like uniform updates
  16533. */
  16534. setVector3(name: string, value: Vector3): ProceduralTexture;
  16535. /**
  16536. * Set a mat4 in the shader from a MAtrix.
  16537. * @param name Define the name of the uniform as defined in the shader
  16538. * @param value Define the value to give to the uniform
  16539. * @return the texture itself allowing "fluent" like uniform updates
  16540. */
  16541. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16542. /**
  16543. * Render the texture to its associated render target.
  16544. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16545. */
  16546. render(useCameraPostProcess?: boolean): void;
  16547. /**
  16548. * Clone the texture.
  16549. * @returns the cloned texture
  16550. */
  16551. clone(): ProceduralTexture;
  16552. /**
  16553. * Dispose the texture and release its asoociated resources.
  16554. */
  16555. dispose(): void;
  16556. }
  16557. }
  16558. declare module "babylonjs/Particles/baseParticleSystem" {
  16559. import { Nullable } from "babylonjs/types";
  16560. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16562. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16563. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16564. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16565. import { Scene } from "babylonjs/scene";
  16566. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16567. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16568. import { Texture } from "babylonjs/Materials/Textures/texture";
  16569. import { Color4 } from "babylonjs/Maths/math.color";
  16570. import { Animation } from "babylonjs/Animations/animation";
  16571. /**
  16572. * This represents the base class for particle system in Babylon.
  16573. * 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.
  16574. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16575. * @example https://doc.babylonjs.com/babylon101/particles
  16576. */
  16577. export class BaseParticleSystem {
  16578. /**
  16579. * Source color is added to the destination color without alpha affecting the result
  16580. */
  16581. static BLENDMODE_ONEONE: number;
  16582. /**
  16583. * Blend current color and particle color using particle’s alpha
  16584. */
  16585. static BLENDMODE_STANDARD: number;
  16586. /**
  16587. * Add current color and particle color multiplied by particle’s alpha
  16588. */
  16589. static BLENDMODE_ADD: number;
  16590. /**
  16591. * Multiply current color with particle color
  16592. */
  16593. static BLENDMODE_MULTIPLY: number;
  16594. /**
  16595. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16596. */
  16597. static BLENDMODE_MULTIPLYADD: number;
  16598. /**
  16599. * List of animations used by the particle system.
  16600. */
  16601. animations: Animation[];
  16602. /**
  16603. * The id of the Particle system.
  16604. */
  16605. id: string;
  16606. /**
  16607. * The friendly name of the Particle system.
  16608. */
  16609. name: string;
  16610. /**
  16611. * The rendering group used by the Particle system to chose when to render.
  16612. */
  16613. renderingGroupId: number;
  16614. /**
  16615. * The emitter represents the Mesh or position we are attaching the particle system to.
  16616. */
  16617. emitter: Nullable<AbstractMesh | Vector3>;
  16618. /**
  16619. * The maximum number of particles to emit per frame
  16620. */
  16621. emitRate: number;
  16622. /**
  16623. * If you want to launch only a few particles at once, that can be done, as well.
  16624. */
  16625. manualEmitCount: number;
  16626. /**
  16627. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16628. */
  16629. updateSpeed: number;
  16630. /**
  16631. * The amount of time the particle system is running (depends of the overall update speed).
  16632. */
  16633. targetStopDuration: number;
  16634. /**
  16635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16636. */
  16637. disposeOnStop: boolean;
  16638. /**
  16639. * Minimum power of emitting particles.
  16640. */
  16641. minEmitPower: number;
  16642. /**
  16643. * Maximum power of emitting particles.
  16644. */
  16645. maxEmitPower: number;
  16646. /**
  16647. * Minimum life time of emitting particles.
  16648. */
  16649. minLifeTime: number;
  16650. /**
  16651. * Maximum life time of emitting particles.
  16652. */
  16653. maxLifeTime: number;
  16654. /**
  16655. * Minimum Size of emitting particles.
  16656. */
  16657. minSize: number;
  16658. /**
  16659. * Maximum Size of emitting particles.
  16660. */
  16661. maxSize: number;
  16662. /**
  16663. * Minimum scale of emitting particles on X axis.
  16664. */
  16665. minScaleX: number;
  16666. /**
  16667. * Maximum scale of emitting particles on X axis.
  16668. */
  16669. maxScaleX: number;
  16670. /**
  16671. * Minimum scale of emitting particles on Y axis.
  16672. */
  16673. minScaleY: number;
  16674. /**
  16675. * Maximum scale of emitting particles on Y axis.
  16676. */
  16677. maxScaleY: number;
  16678. /**
  16679. * Gets or sets the minimal initial rotation in radians.
  16680. */
  16681. minInitialRotation: number;
  16682. /**
  16683. * Gets or sets the maximal initial rotation in radians.
  16684. */
  16685. maxInitialRotation: number;
  16686. /**
  16687. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16688. */
  16689. minAngularSpeed: number;
  16690. /**
  16691. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16692. */
  16693. maxAngularSpeed: number;
  16694. /**
  16695. * The texture used to render each particle. (this can be a spritesheet)
  16696. */
  16697. particleTexture: Nullable<Texture>;
  16698. /**
  16699. * The layer mask we are rendering the particles through.
  16700. */
  16701. layerMask: number;
  16702. /**
  16703. * This can help using your own shader to render the particle system.
  16704. * The according effect will be created
  16705. */
  16706. customShader: any;
  16707. /**
  16708. * By default particle system starts as soon as they are created. This prevents the
  16709. * automatic start to happen and let you decide when to start emitting particles.
  16710. */
  16711. preventAutoStart: boolean;
  16712. private _noiseTexture;
  16713. /**
  16714. * Gets or sets a texture used to add random noise to particle positions
  16715. */
  16716. noiseTexture: Nullable<ProceduralTexture>;
  16717. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16718. noiseStrength: Vector3;
  16719. /**
  16720. * Callback triggered when the particle animation is ending.
  16721. */
  16722. onAnimationEnd: Nullable<() => void>;
  16723. /**
  16724. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16725. */
  16726. blendMode: number;
  16727. /**
  16728. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16729. * to override the particles.
  16730. */
  16731. forceDepthWrite: boolean;
  16732. /** 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 */
  16733. preWarmCycles: number;
  16734. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16735. preWarmStepOffset: number;
  16736. /**
  16737. * 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)
  16738. */
  16739. spriteCellChangeSpeed: number;
  16740. /**
  16741. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16742. */
  16743. startSpriteCellID: number;
  16744. /**
  16745. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16746. */
  16747. endSpriteCellID: number;
  16748. /**
  16749. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16750. */
  16751. spriteCellWidth: number;
  16752. /**
  16753. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16754. */
  16755. spriteCellHeight: number;
  16756. /**
  16757. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16758. */
  16759. spriteRandomStartCell: boolean;
  16760. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16761. translationPivot: Vector2;
  16762. /** @hidden */
  16763. protected _isAnimationSheetEnabled: boolean;
  16764. /**
  16765. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16766. */
  16767. beginAnimationOnStart: boolean;
  16768. /**
  16769. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16770. */
  16771. beginAnimationFrom: number;
  16772. /**
  16773. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16774. */
  16775. beginAnimationTo: number;
  16776. /**
  16777. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16778. */
  16779. beginAnimationLoop: boolean;
  16780. /**
  16781. * Gets or sets a world offset applied to all particles
  16782. */
  16783. worldOffset: Vector3;
  16784. /**
  16785. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16786. */
  16787. isAnimationSheetEnabled: boolean;
  16788. /**
  16789. * Get hosting scene
  16790. * @returns the scene
  16791. */
  16792. getScene(): Scene;
  16793. /**
  16794. * You can use gravity if you want to give an orientation to your particles.
  16795. */
  16796. gravity: Vector3;
  16797. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16798. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16799. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16800. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16801. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16802. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16803. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16804. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16805. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16806. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16807. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16808. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16809. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16810. /**
  16811. * Defines the delay in milliseconds before starting the system (0 by default)
  16812. */
  16813. startDelay: number;
  16814. /**
  16815. * Gets the current list of drag gradients.
  16816. * You must use addDragGradient and removeDragGradient to udpate this list
  16817. * @returns the list of drag gradients
  16818. */
  16819. getDragGradients(): Nullable<Array<FactorGradient>>;
  16820. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16821. limitVelocityDamping: number;
  16822. /**
  16823. * Gets the current list of limit velocity gradients.
  16824. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16825. * @returns the list of limit velocity gradients
  16826. */
  16827. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16828. /**
  16829. * Gets the current list of color gradients.
  16830. * You must use addColorGradient and removeColorGradient to udpate this list
  16831. * @returns the list of color gradients
  16832. */
  16833. getColorGradients(): Nullable<Array<ColorGradient>>;
  16834. /**
  16835. * Gets the current list of size gradients.
  16836. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16837. * @returns the list of size gradients
  16838. */
  16839. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16840. /**
  16841. * Gets the current list of color remap gradients.
  16842. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16843. * @returns the list of color remap gradients
  16844. */
  16845. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16846. /**
  16847. * Gets the current list of alpha remap gradients.
  16848. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16849. * @returns the list of alpha remap gradients
  16850. */
  16851. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16852. /**
  16853. * Gets the current list of life time gradients.
  16854. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16855. * @returns the list of life time gradients
  16856. */
  16857. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16858. /**
  16859. * Gets the current list of angular speed gradients.
  16860. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16861. * @returns the list of angular speed gradients
  16862. */
  16863. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16864. /**
  16865. * Gets the current list of velocity gradients.
  16866. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16867. * @returns the list of velocity gradients
  16868. */
  16869. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16870. /**
  16871. * Gets the current list of start size gradients.
  16872. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16873. * @returns the list of start size gradients
  16874. */
  16875. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16876. /**
  16877. * Gets the current list of emit rate gradients.
  16878. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16879. * @returns the list of emit rate gradients
  16880. */
  16881. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16882. /**
  16883. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16884. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16885. */
  16886. direction1: Vector3;
  16887. /**
  16888. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16889. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16890. */
  16891. direction2: Vector3;
  16892. /**
  16893. * 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.
  16894. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16895. */
  16896. minEmitBox: Vector3;
  16897. /**
  16898. * 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.
  16899. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16900. */
  16901. maxEmitBox: Vector3;
  16902. /**
  16903. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16904. */
  16905. color1: Color4;
  16906. /**
  16907. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16908. */
  16909. color2: Color4;
  16910. /**
  16911. * Color the particle will have at the end of its lifetime
  16912. */
  16913. colorDead: Color4;
  16914. /**
  16915. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16916. */
  16917. textureMask: Color4;
  16918. /**
  16919. * The particle emitter type defines the emitter used by the particle system.
  16920. * It can be for example box, sphere, or cone...
  16921. */
  16922. particleEmitterType: IParticleEmitterType;
  16923. /** @hidden */
  16924. _isSubEmitter: boolean;
  16925. /**
  16926. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16927. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16928. */
  16929. billboardMode: number;
  16930. protected _isBillboardBased: boolean;
  16931. /**
  16932. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16933. */
  16934. isBillboardBased: boolean;
  16935. /**
  16936. * The scene the particle system belongs to.
  16937. */
  16938. protected _scene: Scene;
  16939. /**
  16940. * Local cache of defines for image processing.
  16941. */
  16942. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16943. /**
  16944. * Default configuration related to image processing available in the standard Material.
  16945. */
  16946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16947. /**
  16948. * Gets the image processing configuration used either in this material.
  16949. */
  16950. /**
  16951. * Sets the Default image processing configuration used either in the this material.
  16952. *
  16953. * If sets to null, the scene one is in use.
  16954. */
  16955. imageProcessingConfiguration: ImageProcessingConfiguration;
  16956. /**
  16957. * Attaches a new image processing configuration to the Standard Material.
  16958. * @param configuration
  16959. */
  16960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16961. /** @hidden */
  16962. protected _reset(): void;
  16963. /** @hidden */
  16964. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16965. /**
  16966. * Instantiates a particle system.
  16967. * 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.
  16968. * @param name The name of the particle system
  16969. */
  16970. constructor(name: string);
  16971. /**
  16972. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16975. * @returns the emitter
  16976. */
  16977. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16978. /**
  16979. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16980. * @param radius The radius of the hemisphere to emit from
  16981. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16982. * @returns the emitter
  16983. */
  16984. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16985. /**
  16986. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16987. * @param radius The radius of the sphere to emit from
  16988. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16989. * @returns the emitter
  16990. */
  16991. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16992. /**
  16993. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16994. * @param radius The radius of the sphere to emit from
  16995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16997. * @returns the emitter
  16998. */
  16999. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17000. /**
  17001. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17002. * @param radius The radius of the emission cylinder
  17003. * @param height The height of the emission cylinder
  17004. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17005. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17006. * @returns the emitter
  17007. */
  17008. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17009. /**
  17010. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17011. * @param radius The radius of the cylinder to emit from
  17012. * @param height The height of the emission cylinder
  17013. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17014. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17015. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17016. * @returns the emitter
  17017. */
  17018. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17019. /**
  17020. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17021. * @param radius The radius of the cone to emit from
  17022. * @param angle The base angle of the cone
  17023. * @returns the emitter
  17024. */
  17025. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17026. /**
  17027. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17030. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17031. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17032. * @returns the emitter
  17033. */
  17034. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17035. }
  17036. }
  17037. declare module "babylonjs/Particles/subEmitter" {
  17038. import { Scene } from "babylonjs/scene";
  17039. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17040. /**
  17041. * Type of sub emitter
  17042. */
  17043. export enum SubEmitterType {
  17044. /**
  17045. * Attached to the particle over it's lifetime
  17046. */
  17047. ATTACHED = 0,
  17048. /**
  17049. * Created when the particle dies
  17050. */
  17051. END = 1
  17052. }
  17053. /**
  17054. * Sub emitter class used to emit particles from an existing particle
  17055. */
  17056. export class SubEmitter {
  17057. /**
  17058. * the particle system to be used by the sub emitter
  17059. */
  17060. particleSystem: ParticleSystem;
  17061. /**
  17062. * Type of the submitter (Default: END)
  17063. */
  17064. type: SubEmitterType;
  17065. /**
  17066. * 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)
  17067. * Note: This only is supported when using an emitter of type Mesh
  17068. */
  17069. inheritDirection: boolean;
  17070. /**
  17071. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17072. */
  17073. inheritedVelocityAmount: number;
  17074. /**
  17075. * Creates a sub emitter
  17076. * @param particleSystem the particle system to be used by the sub emitter
  17077. */
  17078. constructor(
  17079. /**
  17080. * the particle system to be used by the sub emitter
  17081. */
  17082. particleSystem: ParticleSystem);
  17083. /**
  17084. * Clones the sub emitter
  17085. * @returns the cloned sub emitter
  17086. */
  17087. clone(): SubEmitter;
  17088. /**
  17089. * Serialize current object to a JSON object
  17090. * @returns the serialized object
  17091. */
  17092. serialize(): any;
  17093. /** @hidden */
  17094. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17095. /**
  17096. * Creates a new SubEmitter from a serialized JSON version
  17097. * @param serializationObject defines the JSON object to read from
  17098. * @param scene defines the hosting scene
  17099. * @param rootUrl defines the rootUrl for data loading
  17100. * @returns a new SubEmitter
  17101. */
  17102. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17103. /** Release associated resources */
  17104. dispose(): void;
  17105. }
  17106. }
  17107. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17108. /** @hidden */
  17109. export var clipPlaneFragmentDeclaration: {
  17110. name: string;
  17111. shader: string;
  17112. };
  17113. }
  17114. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17115. /** @hidden */
  17116. export var imageProcessingDeclaration: {
  17117. name: string;
  17118. shader: string;
  17119. };
  17120. }
  17121. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17122. /** @hidden */
  17123. export var imageProcessingFunctions: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17129. /** @hidden */
  17130. export var clipPlaneFragment: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Shaders/particles.fragment" {
  17136. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17137. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17138. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17139. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17140. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17141. /** @hidden */
  17142. export var particlesPixelShader: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17148. /** @hidden */
  17149. export var clipPlaneVertexDeclaration: {
  17150. name: string;
  17151. shader: string;
  17152. };
  17153. }
  17154. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17155. /** @hidden */
  17156. export var clipPlaneVertex: {
  17157. name: string;
  17158. shader: string;
  17159. };
  17160. }
  17161. declare module "babylonjs/Shaders/particles.vertex" {
  17162. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17164. /** @hidden */
  17165. export var particlesVertexShader: {
  17166. name: string;
  17167. shader: string;
  17168. };
  17169. }
  17170. declare module "babylonjs/Particles/particleSystem" {
  17171. import { Nullable } from "babylonjs/types";
  17172. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17173. import { Observable } from "babylonjs/Misc/observable";
  17174. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17175. import { Effect } from "babylonjs/Materials/effect";
  17176. import { Scene, IDisposable } from "babylonjs/scene";
  17177. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17178. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17179. import { Particle } from "babylonjs/Particles/particle";
  17180. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17181. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17182. import "babylonjs/Shaders/particles.fragment";
  17183. import "babylonjs/Shaders/particles.vertex";
  17184. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17185. /**
  17186. * This represents a particle system in Babylon.
  17187. * 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.
  17188. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17189. * @example https://doc.babylonjs.com/babylon101/particles
  17190. */
  17191. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17192. /**
  17193. * Billboard mode will only apply to Y axis
  17194. */
  17195. static readonly BILLBOARDMODE_Y: number;
  17196. /**
  17197. * Billboard mode will apply to all axes
  17198. */
  17199. static readonly BILLBOARDMODE_ALL: number;
  17200. /**
  17201. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17202. */
  17203. static readonly BILLBOARDMODE_STRETCHED: number;
  17204. /**
  17205. * This function can be defined to provide custom update for active particles.
  17206. * This function will be called instead of regular update (age, position, color, etc.).
  17207. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17208. */
  17209. updateFunction: (particles: Particle[]) => void;
  17210. private _emitterWorldMatrix;
  17211. /**
  17212. * This function can be defined to specify initial direction for every new particle.
  17213. * It by default use the emitterType defined function
  17214. */
  17215. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17216. /**
  17217. * This function can be defined to specify initial position for every new particle.
  17218. * It by default use the emitterType defined function
  17219. */
  17220. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17221. /**
  17222. * @hidden
  17223. */
  17224. _inheritedVelocityOffset: Vector3;
  17225. /**
  17226. * An event triggered when the system is disposed
  17227. */
  17228. onDisposeObservable: Observable<ParticleSystem>;
  17229. private _onDisposeObserver;
  17230. /**
  17231. * Sets a callback that will be triggered when the system is disposed
  17232. */
  17233. onDispose: () => void;
  17234. private _particles;
  17235. private _epsilon;
  17236. private _capacity;
  17237. private _stockParticles;
  17238. private _newPartsExcess;
  17239. private _vertexData;
  17240. private _vertexBuffer;
  17241. private _vertexBuffers;
  17242. private _spriteBuffer;
  17243. private _indexBuffer;
  17244. private _effect;
  17245. private _customEffect;
  17246. private _cachedDefines;
  17247. private _scaledColorStep;
  17248. private _colorDiff;
  17249. private _scaledDirection;
  17250. private _scaledGravity;
  17251. private _currentRenderId;
  17252. private _alive;
  17253. private _useInstancing;
  17254. private _started;
  17255. private _stopped;
  17256. private _actualFrame;
  17257. private _scaledUpdateSpeed;
  17258. private _vertexBufferSize;
  17259. /** @hidden */
  17260. _currentEmitRateGradient: Nullable<FactorGradient>;
  17261. /** @hidden */
  17262. _currentEmitRate1: number;
  17263. /** @hidden */
  17264. _currentEmitRate2: number;
  17265. /** @hidden */
  17266. _currentStartSizeGradient: Nullable<FactorGradient>;
  17267. /** @hidden */
  17268. _currentStartSize1: number;
  17269. /** @hidden */
  17270. _currentStartSize2: number;
  17271. private readonly _rawTextureWidth;
  17272. private _rampGradientsTexture;
  17273. private _useRampGradients;
  17274. /** Gets or sets a boolean indicating that ramp gradients must be used
  17275. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17276. */
  17277. useRampGradients: boolean;
  17278. /**
  17279. * 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.
  17280. * 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: [])
  17281. */
  17282. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17283. private _subEmitters;
  17284. /**
  17285. * @hidden
  17286. * If the particle systems emitter should be disposed when the particle system is disposed
  17287. */
  17288. _disposeEmitterOnDispose: boolean;
  17289. /**
  17290. * The current active Sub-systems, this property is used by the root particle system only.
  17291. */
  17292. activeSubSystems: Array<ParticleSystem>;
  17293. private _rootParticleSystem;
  17294. /**
  17295. * Gets the current list of active particles
  17296. */
  17297. readonly particles: Particle[];
  17298. /**
  17299. * Returns the string "ParticleSystem"
  17300. * @returns a string containing the class name
  17301. */
  17302. getClassName(): string;
  17303. /**
  17304. * Instantiates a particle system.
  17305. * 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.
  17306. * @param name The name of the particle system
  17307. * @param capacity The max number of particles alive at the same time
  17308. * @param scene The scene the particle system belongs to
  17309. * @param customEffect a custom effect used to change the way particles are rendered by default
  17310. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17311. * @param epsilon Offset used to render the particles
  17312. */
  17313. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17314. private _addFactorGradient;
  17315. private _removeFactorGradient;
  17316. /**
  17317. * Adds a new life time gradient
  17318. * @param gradient defines the gradient to use (between 0 and 1)
  17319. * @param factor defines the life time factor to affect to the specified gradient
  17320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17321. * @returns the current particle system
  17322. */
  17323. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17324. /**
  17325. * Remove a specific life time gradient
  17326. * @param gradient defines the gradient to remove
  17327. * @returns the current particle system
  17328. */
  17329. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17330. /**
  17331. * Adds a new size gradient
  17332. * @param gradient defines the gradient to use (between 0 and 1)
  17333. * @param factor defines the size factor to affect to the specified gradient
  17334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17335. * @returns the current particle system
  17336. */
  17337. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17338. /**
  17339. * Remove a specific size gradient
  17340. * @param gradient defines the gradient to remove
  17341. * @returns the current particle system
  17342. */
  17343. removeSizeGradient(gradient: number): IParticleSystem;
  17344. /**
  17345. * Adds a new color remap gradient
  17346. * @param gradient defines the gradient to use (between 0 and 1)
  17347. * @param min defines the color remap minimal range
  17348. * @param max defines the color remap maximal range
  17349. * @returns the current particle system
  17350. */
  17351. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17352. /**
  17353. * Remove a specific color remap gradient
  17354. * @param gradient defines the gradient to remove
  17355. * @returns the current particle system
  17356. */
  17357. removeColorRemapGradient(gradient: number): IParticleSystem;
  17358. /**
  17359. * Adds a new alpha remap gradient
  17360. * @param gradient defines the gradient to use (between 0 and 1)
  17361. * @param min defines the alpha remap minimal range
  17362. * @param max defines the alpha remap maximal range
  17363. * @returns the current particle system
  17364. */
  17365. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17366. /**
  17367. * Remove a specific alpha remap gradient
  17368. * @param gradient defines the gradient to remove
  17369. * @returns the current particle system
  17370. */
  17371. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17372. /**
  17373. * Adds a new angular speed gradient
  17374. * @param gradient defines the gradient to use (between 0 and 1)
  17375. * @param factor defines the angular speed to affect to the specified gradient
  17376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17377. * @returns the current particle system
  17378. */
  17379. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17380. /**
  17381. * Remove a specific angular speed gradient
  17382. * @param gradient defines the gradient to remove
  17383. * @returns the current particle system
  17384. */
  17385. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17386. /**
  17387. * Adds a new velocity gradient
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the velocity to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific velocity gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeVelocityGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Adds a new limit velocity gradient
  17402. * @param gradient defines the gradient to use (between 0 and 1)
  17403. * @param factor defines the limit velocity value to affect to the specified gradient
  17404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17405. * @returns the current particle system
  17406. */
  17407. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17408. /**
  17409. * Remove a specific limit velocity gradient
  17410. * @param gradient defines the gradient to remove
  17411. * @returns the current particle system
  17412. */
  17413. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17414. /**
  17415. * Adds a new drag gradient
  17416. * @param gradient defines the gradient to use (between 0 and 1)
  17417. * @param factor defines the drag value to affect to the specified gradient
  17418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17419. * @returns the current particle system
  17420. */
  17421. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17422. /**
  17423. * Remove a specific drag gradient
  17424. * @param gradient defines the gradient to remove
  17425. * @returns the current particle system
  17426. */
  17427. removeDragGradient(gradient: number): IParticleSystem;
  17428. /**
  17429. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17430. * @param gradient defines the gradient to use (between 0 and 1)
  17431. * @param factor defines the emit rate value to affect to the specified gradient
  17432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17433. * @returns the current particle system
  17434. */
  17435. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17436. /**
  17437. * Remove a specific emit rate gradient
  17438. * @param gradient defines the gradient to remove
  17439. * @returns the current particle system
  17440. */
  17441. removeEmitRateGradient(gradient: number): IParticleSystem;
  17442. /**
  17443. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17444. * @param gradient defines the gradient to use (between 0 and 1)
  17445. * @param factor defines the start size value to affect to the specified gradient
  17446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17447. * @returns the current particle system
  17448. */
  17449. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17450. /**
  17451. * Remove a specific start size gradient
  17452. * @param gradient defines the gradient to remove
  17453. * @returns the current particle system
  17454. */
  17455. removeStartSizeGradient(gradient: number): IParticleSystem;
  17456. private _createRampGradientTexture;
  17457. /**
  17458. * Gets the current list of ramp gradients.
  17459. * You must use addRampGradient and removeRampGradient to udpate this list
  17460. * @returns the list of ramp gradients
  17461. */
  17462. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17463. /**
  17464. * Adds a new ramp gradient used to remap particle colors
  17465. * @param gradient defines the gradient to use (between 0 and 1)
  17466. * @param color defines the color to affect to the specified gradient
  17467. * @returns the current particle system
  17468. */
  17469. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17470. /**
  17471. * Remove a specific ramp gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeRampGradient(gradient: number): ParticleSystem;
  17476. /**
  17477. * Adds a new color gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param color1 defines the color to affect to the specified gradient
  17480. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17481. * @returns this particle system
  17482. */
  17483. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17484. /**
  17485. * Remove a specific color gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns this particle system
  17488. */
  17489. removeColorGradient(gradient: number): IParticleSystem;
  17490. private _fetchR;
  17491. protected _reset(): void;
  17492. private _resetEffect;
  17493. private _createVertexBuffers;
  17494. private _createIndexBuffer;
  17495. /**
  17496. * Gets the maximum number of particles active at the same time.
  17497. * @returns The max number of active particles.
  17498. */
  17499. getCapacity(): number;
  17500. /**
  17501. * Gets whether there are still active particles in the system.
  17502. * @returns True if it is alive, otherwise false.
  17503. */
  17504. isAlive(): boolean;
  17505. /**
  17506. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17507. * @returns True if it has been started, otherwise false.
  17508. */
  17509. isStarted(): boolean;
  17510. private _prepareSubEmitterInternalArray;
  17511. /**
  17512. * Starts the particle system and begins to emit
  17513. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17514. */
  17515. start(delay?: number): void;
  17516. /**
  17517. * Stops the particle system.
  17518. * @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.
  17519. */
  17520. stop(stopSubEmitters?: boolean): void;
  17521. /**
  17522. * Remove all active particles
  17523. */
  17524. reset(): void;
  17525. /**
  17526. * @hidden (for internal use only)
  17527. */
  17528. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17529. /**
  17530. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17531. * Its lifetime will start back at 0.
  17532. */
  17533. recycleParticle: (particle: Particle) => void;
  17534. private _stopSubEmitters;
  17535. private _createParticle;
  17536. private _removeFromRoot;
  17537. private _emitFromParticle;
  17538. private _update;
  17539. /** @hidden */
  17540. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17541. /** @hidden */
  17542. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17543. /** @hidden */
  17544. private _getEffect;
  17545. /**
  17546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17547. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17548. */
  17549. animate(preWarmOnly?: boolean): void;
  17550. private _appendParticleVertices;
  17551. /**
  17552. * Rebuilds the particle system.
  17553. */
  17554. rebuild(): void;
  17555. /**
  17556. * Is this system ready to be used/rendered
  17557. * @return true if the system is ready
  17558. */
  17559. isReady(): boolean;
  17560. private _render;
  17561. /**
  17562. * Renders the particle system in its current state.
  17563. * @returns the current number of particles
  17564. */
  17565. render(): number;
  17566. /**
  17567. * Disposes the particle system and free the associated resources
  17568. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17569. */
  17570. dispose(disposeTexture?: boolean): void;
  17571. /**
  17572. * Clones the particle system.
  17573. * @param name The name of the cloned object
  17574. * @param newEmitter The new emitter to use
  17575. * @returns the cloned particle system
  17576. */
  17577. clone(name: string, newEmitter: any): ParticleSystem;
  17578. /**
  17579. * Serializes the particle system to a JSON object.
  17580. * @returns the JSON object
  17581. */
  17582. serialize(): any;
  17583. /** @hidden */
  17584. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17585. /** @hidden */
  17586. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17587. /**
  17588. * Parses a JSON object to create a particle system.
  17589. * @param parsedParticleSystem The JSON object to parse
  17590. * @param scene The scene to create the particle system in
  17591. * @param rootUrl The root url to use to load external dependencies like texture
  17592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17593. * @returns the Parsed particle system
  17594. */
  17595. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17596. }
  17597. }
  17598. declare module "babylonjs/Particles/particle" {
  17599. import { Nullable } from "babylonjs/types";
  17600. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17601. import { Color4 } from "babylonjs/Maths/math.color";
  17602. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17603. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17604. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17605. /**
  17606. * A particle represents one of the element emitted by a particle system.
  17607. * This is mainly define by its coordinates, direction, velocity and age.
  17608. */
  17609. export class Particle {
  17610. /**
  17611. * The particle system the particle belongs to.
  17612. */
  17613. particleSystem: ParticleSystem;
  17614. private static _Count;
  17615. /**
  17616. * Unique ID of the particle
  17617. */
  17618. id: number;
  17619. /**
  17620. * The world position of the particle in the scene.
  17621. */
  17622. position: Vector3;
  17623. /**
  17624. * The world direction of the particle in the scene.
  17625. */
  17626. direction: Vector3;
  17627. /**
  17628. * The color of the particle.
  17629. */
  17630. color: Color4;
  17631. /**
  17632. * The color change of the particle per step.
  17633. */
  17634. colorStep: Color4;
  17635. /**
  17636. * Defines how long will the life of the particle be.
  17637. */
  17638. lifeTime: number;
  17639. /**
  17640. * The current age of the particle.
  17641. */
  17642. age: number;
  17643. /**
  17644. * The current size of the particle.
  17645. */
  17646. size: number;
  17647. /**
  17648. * The current scale of the particle.
  17649. */
  17650. scale: Vector2;
  17651. /**
  17652. * The current angle of the particle.
  17653. */
  17654. angle: number;
  17655. /**
  17656. * Defines how fast is the angle changing.
  17657. */
  17658. angularSpeed: number;
  17659. /**
  17660. * Defines the cell index used by the particle to be rendered from a sprite.
  17661. */
  17662. cellIndex: number;
  17663. /**
  17664. * The information required to support color remapping
  17665. */
  17666. remapData: Vector4;
  17667. /** @hidden */
  17668. _randomCellOffset?: number;
  17669. /** @hidden */
  17670. _initialDirection: Nullable<Vector3>;
  17671. /** @hidden */
  17672. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17673. /** @hidden */
  17674. _initialStartSpriteCellID: number;
  17675. /** @hidden */
  17676. _initialEndSpriteCellID: number;
  17677. /** @hidden */
  17678. _currentColorGradient: Nullable<ColorGradient>;
  17679. /** @hidden */
  17680. _currentColor1: Color4;
  17681. /** @hidden */
  17682. _currentColor2: Color4;
  17683. /** @hidden */
  17684. _currentSizeGradient: Nullable<FactorGradient>;
  17685. /** @hidden */
  17686. _currentSize1: number;
  17687. /** @hidden */
  17688. _currentSize2: number;
  17689. /** @hidden */
  17690. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17691. /** @hidden */
  17692. _currentAngularSpeed1: number;
  17693. /** @hidden */
  17694. _currentAngularSpeed2: number;
  17695. /** @hidden */
  17696. _currentVelocityGradient: Nullable<FactorGradient>;
  17697. /** @hidden */
  17698. _currentVelocity1: number;
  17699. /** @hidden */
  17700. _currentVelocity2: number;
  17701. /** @hidden */
  17702. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17703. /** @hidden */
  17704. _currentLimitVelocity1: number;
  17705. /** @hidden */
  17706. _currentLimitVelocity2: number;
  17707. /** @hidden */
  17708. _currentDragGradient: Nullable<FactorGradient>;
  17709. /** @hidden */
  17710. _currentDrag1: number;
  17711. /** @hidden */
  17712. _currentDrag2: number;
  17713. /** @hidden */
  17714. _randomNoiseCoordinates1: Vector3;
  17715. /** @hidden */
  17716. _randomNoiseCoordinates2: Vector3;
  17717. /**
  17718. * Creates a new instance Particle
  17719. * @param particleSystem the particle system the particle belongs to
  17720. */
  17721. constructor(
  17722. /**
  17723. * The particle system the particle belongs to.
  17724. */
  17725. particleSystem: ParticleSystem);
  17726. private updateCellInfoFromSystem;
  17727. /**
  17728. * Defines how the sprite cell index is updated for the particle
  17729. */
  17730. updateCellIndex(): void;
  17731. /** @hidden */
  17732. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17733. /** @hidden */
  17734. _inheritParticleInfoToSubEmitters(): void;
  17735. /** @hidden */
  17736. _reset(): void;
  17737. /**
  17738. * Copy the properties of particle to another one.
  17739. * @param other the particle to copy the information to.
  17740. */
  17741. copyTo(other: Particle): void;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17745. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17746. import { Effect } from "babylonjs/Materials/effect";
  17747. import { Particle } from "babylonjs/Particles/particle";
  17748. /**
  17749. * Particle emitter represents a volume emitting particles.
  17750. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17751. */
  17752. export interface IParticleEmitterType {
  17753. /**
  17754. * Called by the particle System when the direction is computed for the created particle.
  17755. * @param worldMatrix is the world matrix of the particle system
  17756. * @param directionToUpdate is the direction vector to update with the result
  17757. * @param particle is the particle we are computed the direction for
  17758. */
  17759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17760. /**
  17761. * Called by the particle System when the position is computed for the created particle.
  17762. * @param worldMatrix is the world matrix of the particle system
  17763. * @param positionToUpdate is the position vector to update with the result
  17764. * @param particle is the particle we are computed the position for
  17765. */
  17766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17767. /**
  17768. * Clones the current emitter and returns a copy of it
  17769. * @returns the new emitter
  17770. */
  17771. clone(): IParticleEmitterType;
  17772. /**
  17773. * Called by the GPUParticleSystem to setup the update shader
  17774. * @param effect defines the update shader
  17775. */
  17776. applyToShader(effect: Effect): void;
  17777. /**
  17778. * Returns a string to use to update the GPU particles update shader
  17779. * @returns the effect defines string
  17780. */
  17781. getEffectDefines(): string;
  17782. /**
  17783. * Returns a string representing the class name
  17784. * @returns a string containing the class name
  17785. */
  17786. getClassName(): string;
  17787. /**
  17788. * Serializes the particle system to a JSON object.
  17789. * @returns the JSON object
  17790. */
  17791. serialize(): any;
  17792. /**
  17793. * Parse properties from a JSON object
  17794. * @param serializationObject defines the JSON object
  17795. */
  17796. parse(serializationObject: any): void;
  17797. }
  17798. }
  17799. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17800. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17801. import { Effect } from "babylonjs/Materials/effect";
  17802. import { Particle } from "babylonjs/Particles/particle";
  17803. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17804. /**
  17805. * Particle emitter emitting particles from the inside of a box.
  17806. * It emits the particles randomly between 2 given directions.
  17807. */
  17808. export class BoxParticleEmitter implements IParticleEmitterType {
  17809. /**
  17810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17811. */
  17812. direction1: Vector3;
  17813. /**
  17814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17815. */
  17816. direction2: Vector3;
  17817. /**
  17818. * 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.
  17819. */
  17820. minEmitBox: Vector3;
  17821. /**
  17822. * 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.
  17823. */
  17824. maxEmitBox: Vector3;
  17825. /**
  17826. * Creates a new instance BoxParticleEmitter
  17827. */
  17828. constructor();
  17829. /**
  17830. * Called by the particle System when the direction is computed for the created particle.
  17831. * @param worldMatrix is the world matrix of the particle system
  17832. * @param directionToUpdate is the direction vector to update with the result
  17833. * @param particle is the particle we are computed the direction for
  17834. */
  17835. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17836. /**
  17837. * Called by the particle System when the position is computed for the created particle.
  17838. * @param worldMatrix is the world matrix of the particle system
  17839. * @param positionToUpdate is the position vector to update with the result
  17840. * @param particle is the particle we are computed the position for
  17841. */
  17842. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17843. /**
  17844. * Clones the current emitter and returns a copy of it
  17845. * @returns the new emitter
  17846. */
  17847. clone(): BoxParticleEmitter;
  17848. /**
  17849. * Called by the GPUParticleSystem to setup the update shader
  17850. * @param effect defines the update shader
  17851. */
  17852. applyToShader(effect: Effect): void;
  17853. /**
  17854. * Returns a string to use to update the GPU particles update shader
  17855. * @returns a string containng the defines string
  17856. */
  17857. getEffectDefines(): string;
  17858. /**
  17859. * Returns the string "BoxParticleEmitter"
  17860. * @returns a string containing the class name
  17861. */
  17862. getClassName(): string;
  17863. /**
  17864. * Serializes the particle system to a JSON object.
  17865. * @returns the JSON object
  17866. */
  17867. serialize(): any;
  17868. /**
  17869. * Parse properties from a JSON object
  17870. * @param serializationObject defines the JSON object
  17871. */
  17872. parse(serializationObject: any): void;
  17873. }
  17874. }
  17875. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17876. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17877. import { Effect } from "babylonjs/Materials/effect";
  17878. import { Particle } from "babylonjs/Particles/particle";
  17879. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17880. /**
  17881. * Particle emitter emitting particles from the inside of a cone.
  17882. * It emits the particles alongside the cone volume from the base to the particle.
  17883. * The emission direction might be randomized.
  17884. */
  17885. export class ConeParticleEmitter implements IParticleEmitterType {
  17886. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17887. directionRandomizer: number;
  17888. private _radius;
  17889. private _angle;
  17890. private _height;
  17891. /**
  17892. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17893. */
  17894. radiusRange: number;
  17895. /**
  17896. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17897. */
  17898. heightRange: number;
  17899. /**
  17900. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17901. */
  17902. emitFromSpawnPointOnly: boolean;
  17903. /**
  17904. * Gets or sets the radius of the emission cone
  17905. */
  17906. radius: number;
  17907. /**
  17908. * Gets or sets the angle of the emission cone
  17909. */
  17910. angle: number;
  17911. private _buildHeight;
  17912. /**
  17913. * Creates a new instance ConeParticleEmitter
  17914. * @param radius the radius of the emission cone (1 by default)
  17915. * @param angle the cone base angle (PI by default)
  17916. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17917. */
  17918. constructor(radius?: number, angle?: number,
  17919. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17920. directionRandomizer?: number);
  17921. /**
  17922. * Called by the particle System when the direction is computed for the created particle.
  17923. * @param worldMatrix is the world matrix of the particle system
  17924. * @param directionToUpdate is the direction vector to update with the result
  17925. * @param particle is the particle we are computed the direction for
  17926. */
  17927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17928. /**
  17929. * Called by the particle System when the position is computed for the created particle.
  17930. * @param worldMatrix is the world matrix of the particle system
  17931. * @param positionToUpdate is the position vector to update with the result
  17932. * @param particle is the particle we are computed the position for
  17933. */
  17934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17935. /**
  17936. * Clones the current emitter and returns a copy of it
  17937. * @returns the new emitter
  17938. */
  17939. clone(): ConeParticleEmitter;
  17940. /**
  17941. * Called by the GPUParticleSystem to setup the update shader
  17942. * @param effect defines the update shader
  17943. */
  17944. applyToShader(effect: Effect): void;
  17945. /**
  17946. * Returns a string to use to update the GPU particles update shader
  17947. * @returns a string containng the defines string
  17948. */
  17949. getEffectDefines(): string;
  17950. /**
  17951. * Returns the string "ConeParticleEmitter"
  17952. * @returns a string containing the class name
  17953. */
  17954. getClassName(): string;
  17955. /**
  17956. * Serializes the particle system to a JSON object.
  17957. * @returns the JSON object
  17958. */
  17959. serialize(): any;
  17960. /**
  17961. * Parse properties from a JSON object
  17962. * @param serializationObject defines the JSON object
  17963. */
  17964. parse(serializationObject: any): void;
  17965. }
  17966. }
  17967. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17968. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17969. import { Effect } from "babylonjs/Materials/effect";
  17970. import { Particle } from "babylonjs/Particles/particle";
  17971. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17972. /**
  17973. * Particle emitter emitting particles from the inside of a cylinder.
  17974. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17975. */
  17976. export class CylinderParticleEmitter implements IParticleEmitterType {
  17977. /**
  17978. * The radius of the emission cylinder.
  17979. */
  17980. radius: number;
  17981. /**
  17982. * The height of the emission cylinder.
  17983. */
  17984. height: number;
  17985. /**
  17986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17987. */
  17988. radiusRange: number;
  17989. /**
  17990. * How much to randomize the particle direction [0-1].
  17991. */
  17992. directionRandomizer: number;
  17993. /**
  17994. * Creates a new instance CylinderParticleEmitter
  17995. * @param radius the radius of the emission cylinder (1 by default)
  17996. * @param height the height of the emission cylinder (1 by default)
  17997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17999. */
  18000. constructor(
  18001. /**
  18002. * The radius of the emission cylinder.
  18003. */
  18004. radius?: number,
  18005. /**
  18006. * The height of the emission cylinder.
  18007. */
  18008. height?: number,
  18009. /**
  18010. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18011. */
  18012. radiusRange?: number,
  18013. /**
  18014. * How much to randomize the particle direction [0-1].
  18015. */
  18016. directionRandomizer?: number);
  18017. /**
  18018. * Called by the particle System when the direction is computed for the created particle.
  18019. * @param worldMatrix is the world matrix of the particle system
  18020. * @param directionToUpdate is the direction vector to update with the result
  18021. * @param particle is the particle we are computed the direction for
  18022. */
  18023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18024. /**
  18025. * Called by the particle System when the position is computed for the created particle.
  18026. * @param worldMatrix is the world matrix of the particle system
  18027. * @param positionToUpdate is the position vector to update with the result
  18028. * @param particle is the particle we are computed the position for
  18029. */
  18030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18031. /**
  18032. * Clones the current emitter and returns a copy of it
  18033. * @returns the new emitter
  18034. */
  18035. clone(): CylinderParticleEmitter;
  18036. /**
  18037. * Called by the GPUParticleSystem to setup the update shader
  18038. * @param effect defines the update shader
  18039. */
  18040. applyToShader(effect: Effect): void;
  18041. /**
  18042. * Returns a string to use to update the GPU particles update shader
  18043. * @returns a string containng the defines string
  18044. */
  18045. getEffectDefines(): string;
  18046. /**
  18047. * Returns the string "CylinderParticleEmitter"
  18048. * @returns a string containing the class name
  18049. */
  18050. getClassName(): string;
  18051. /**
  18052. * Serializes the particle system to a JSON object.
  18053. * @returns the JSON object
  18054. */
  18055. serialize(): any;
  18056. /**
  18057. * Parse properties from a JSON object
  18058. * @param serializationObject defines the JSON object
  18059. */
  18060. parse(serializationObject: any): void;
  18061. }
  18062. /**
  18063. * Particle emitter emitting particles from the inside of a cylinder.
  18064. * It emits the particles randomly between two vectors.
  18065. */
  18066. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18067. /**
  18068. * The min limit of the emission direction.
  18069. */
  18070. direction1: Vector3;
  18071. /**
  18072. * The max limit of the emission direction.
  18073. */
  18074. direction2: Vector3;
  18075. /**
  18076. * Creates a new instance CylinderDirectedParticleEmitter
  18077. * @param radius the radius of the emission cylinder (1 by default)
  18078. * @param height the height of the emission cylinder (1 by default)
  18079. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18080. * @param direction1 the min limit of the emission direction (up vector by default)
  18081. * @param direction2 the max limit of the emission direction (up vector by default)
  18082. */
  18083. constructor(radius?: number, height?: number, radiusRange?: number,
  18084. /**
  18085. * The min limit of the emission direction.
  18086. */
  18087. direction1?: Vector3,
  18088. /**
  18089. * The max limit of the emission direction.
  18090. */
  18091. direction2?: Vector3);
  18092. /**
  18093. * Called by the particle System when the direction is computed for the created particle.
  18094. * @param worldMatrix is the world matrix of the particle system
  18095. * @param directionToUpdate is the direction vector to update with the result
  18096. * @param particle is the particle we are computed the direction for
  18097. */
  18098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18099. /**
  18100. * Clones the current emitter and returns a copy of it
  18101. * @returns the new emitter
  18102. */
  18103. clone(): CylinderDirectedParticleEmitter;
  18104. /**
  18105. * Called by the GPUParticleSystem to setup the update shader
  18106. * @param effect defines the update shader
  18107. */
  18108. applyToShader(effect: Effect): void;
  18109. /**
  18110. * Returns a string to use to update the GPU particles update shader
  18111. * @returns a string containng the defines string
  18112. */
  18113. getEffectDefines(): string;
  18114. /**
  18115. * Returns the string "CylinderDirectedParticleEmitter"
  18116. * @returns a string containing the class name
  18117. */
  18118. getClassName(): string;
  18119. /**
  18120. * Serializes the particle system to a JSON object.
  18121. * @returns the JSON object
  18122. */
  18123. serialize(): any;
  18124. /**
  18125. * Parse properties from a JSON object
  18126. * @param serializationObject defines the JSON object
  18127. */
  18128. parse(serializationObject: any): void;
  18129. }
  18130. }
  18131. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18132. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18133. import { Effect } from "babylonjs/Materials/effect";
  18134. import { Particle } from "babylonjs/Particles/particle";
  18135. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18136. /**
  18137. * Particle emitter emitting particles from the inside of a hemisphere.
  18138. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18139. */
  18140. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18141. /**
  18142. * The radius of the emission hemisphere.
  18143. */
  18144. radius: number;
  18145. /**
  18146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18147. */
  18148. radiusRange: number;
  18149. /**
  18150. * How much to randomize the particle direction [0-1].
  18151. */
  18152. directionRandomizer: number;
  18153. /**
  18154. * Creates a new instance HemisphericParticleEmitter
  18155. * @param radius the radius of the emission hemisphere (1 by default)
  18156. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18157. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18158. */
  18159. constructor(
  18160. /**
  18161. * The radius of the emission hemisphere.
  18162. */
  18163. radius?: number,
  18164. /**
  18165. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18166. */
  18167. radiusRange?: number,
  18168. /**
  18169. * How much to randomize the particle direction [0-1].
  18170. */
  18171. directionRandomizer?: number);
  18172. /**
  18173. * Called by the particle System when the direction is computed for the created particle.
  18174. * @param worldMatrix is the world matrix of the particle system
  18175. * @param directionToUpdate is the direction vector to update with the result
  18176. * @param particle is the particle we are computed the direction for
  18177. */
  18178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18179. /**
  18180. * Called by the particle System when the position is computed for the created particle.
  18181. * @param worldMatrix is the world matrix of the particle system
  18182. * @param positionToUpdate is the position vector to update with the result
  18183. * @param particle is the particle we are computed the position for
  18184. */
  18185. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18186. /**
  18187. * Clones the current emitter and returns a copy of it
  18188. * @returns the new emitter
  18189. */
  18190. clone(): HemisphericParticleEmitter;
  18191. /**
  18192. * Called by the GPUParticleSystem to setup the update shader
  18193. * @param effect defines the update shader
  18194. */
  18195. applyToShader(effect: Effect): void;
  18196. /**
  18197. * Returns a string to use to update the GPU particles update shader
  18198. * @returns a string containng the defines string
  18199. */
  18200. getEffectDefines(): string;
  18201. /**
  18202. * Returns the string "HemisphericParticleEmitter"
  18203. * @returns a string containing the class name
  18204. */
  18205. getClassName(): string;
  18206. /**
  18207. * Serializes the particle system to a JSON object.
  18208. * @returns the JSON object
  18209. */
  18210. serialize(): any;
  18211. /**
  18212. * Parse properties from a JSON object
  18213. * @param serializationObject defines the JSON object
  18214. */
  18215. parse(serializationObject: any): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18223. /**
  18224. * Particle emitter emitting particles from a point.
  18225. * It emits the particles randomly between 2 given directions.
  18226. */
  18227. export class PointParticleEmitter implements IParticleEmitterType {
  18228. /**
  18229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18230. */
  18231. direction1: Vector3;
  18232. /**
  18233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18234. */
  18235. direction2: Vector3;
  18236. /**
  18237. * Creates a new instance PointParticleEmitter
  18238. */
  18239. constructor();
  18240. /**
  18241. * Called by the particle System when the direction is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param directionToUpdate is the direction vector to update with the result
  18244. * @param particle is the particle we are computed the direction for
  18245. */
  18246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Called by the particle System when the position is computed for the created particle.
  18249. * @param worldMatrix is the world matrix of the particle system
  18250. * @param positionToUpdate is the position vector to update with the result
  18251. * @param particle is the particle we are computed the position for
  18252. */
  18253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18254. /**
  18255. * Clones the current emitter and returns a copy of it
  18256. * @returns the new emitter
  18257. */
  18258. clone(): PointParticleEmitter;
  18259. /**
  18260. * Called by the GPUParticleSystem to setup the update shader
  18261. * @param effect defines the update shader
  18262. */
  18263. applyToShader(effect: Effect): void;
  18264. /**
  18265. * Returns a string to use to update the GPU particles update shader
  18266. * @returns a string containng the defines string
  18267. */
  18268. getEffectDefines(): string;
  18269. /**
  18270. * Returns the string "PointParticleEmitter"
  18271. * @returns a string containing the class name
  18272. */
  18273. getClassName(): string;
  18274. /**
  18275. * Serializes the particle system to a JSON object.
  18276. * @returns the JSON object
  18277. */
  18278. serialize(): any;
  18279. /**
  18280. * Parse properties from a JSON object
  18281. * @param serializationObject defines the JSON object
  18282. */
  18283. parse(serializationObject: any): void;
  18284. }
  18285. }
  18286. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18287. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18288. import { Effect } from "babylonjs/Materials/effect";
  18289. import { Particle } from "babylonjs/Particles/particle";
  18290. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18291. /**
  18292. * Particle emitter emitting particles from the inside of a sphere.
  18293. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18294. */
  18295. export class SphereParticleEmitter implements IParticleEmitterType {
  18296. /**
  18297. * The radius of the emission sphere.
  18298. */
  18299. radius: number;
  18300. /**
  18301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18302. */
  18303. radiusRange: number;
  18304. /**
  18305. * How much to randomize the particle direction [0-1].
  18306. */
  18307. directionRandomizer: number;
  18308. /**
  18309. * Creates a new instance SphereParticleEmitter
  18310. * @param radius the radius of the emission sphere (1 by default)
  18311. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18312. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18313. */
  18314. constructor(
  18315. /**
  18316. * The radius of the emission sphere.
  18317. */
  18318. radius?: number,
  18319. /**
  18320. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18321. */
  18322. radiusRange?: number,
  18323. /**
  18324. * How much to randomize the particle direction [0-1].
  18325. */
  18326. directionRandomizer?: number);
  18327. /**
  18328. * Called by the particle System when the direction is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param directionToUpdate is the direction vector to update with the result
  18331. * @param particle is the particle we are computed the direction for
  18332. */
  18333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Called by the particle System when the position is computed for the created particle.
  18336. * @param worldMatrix is the world matrix of the particle system
  18337. * @param positionToUpdate is the position vector to update with the result
  18338. * @param particle is the particle we are computed the position for
  18339. */
  18340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18341. /**
  18342. * Clones the current emitter and returns a copy of it
  18343. * @returns the new emitter
  18344. */
  18345. clone(): SphereParticleEmitter;
  18346. /**
  18347. * Called by the GPUParticleSystem to setup the update shader
  18348. * @param effect defines the update shader
  18349. */
  18350. applyToShader(effect: Effect): void;
  18351. /**
  18352. * Returns a string to use to update the GPU particles update shader
  18353. * @returns a string containng the defines string
  18354. */
  18355. getEffectDefines(): string;
  18356. /**
  18357. * Returns the string "SphereParticleEmitter"
  18358. * @returns a string containing the class name
  18359. */
  18360. getClassName(): string;
  18361. /**
  18362. * Serializes the particle system to a JSON object.
  18363. * @returns the JSON object
  18364. */
  18365. serialize(): any;
  18366. /**
  18367. * Parse properties from a JSON object
  18368. * @param serializationObject defines the JSON object
  18369. */
  18370. parse(serializationObject: any): void;
  18371. }
  18372. /**
  18373. * Particle emitter emitting particles from the inside of a sphere.
  18374. * It emits the particles randomly between two vectors.
  18375. */
  18376. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18377. /**
  18378. * The min limit of the emission direction.
  18379. */
  18380. direction1: Vector3;
  18381. /**
  18382. * The max limit of the emission direction.
  18383. */
  18384. direction2: Vector3;
  18385. /**
  18386. * Creates a new instance SphereDirectedParticleEmitter
  18387. * @param radius the radius of the emission sphere (1 by default)
  18388. * @param direction1 the min limit of the emission direction (up vector by default)
  18389. * @param direction2 the max limit of the emission direction (up vector by default)
  18390. */
  18391. constructor(radius?: number,
  18392. /**
  18393. * The min limit of the emission direction.
  18394. */
  18395. direction1?: Vector3,
  18396. /**
  18397. * The max limit of the emission direction.
  18398. */
  18399. direction2?: Vector3);
  18400. /**
  18401. * Called by the particle System when the direction is computed for the created particle.
  18402. * @param worldMatrix is the world matrix of the particle system
  18403. * @param directionToUpdate is the direction vector to update with the result
  18404. * @param particle is the particle we are computed the direction for
  18405. */
  18406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18407. /**
  18408. * Clones the current emitter and returns a copy of it
  18409. * @returns the new emitter
  18410. */
  18411. clone(): SphereDirectedParticleEmitter;
  18412. /**
  18413. * Called by the GPUParticleSystem to setup the update shader
  18414. * @param effect defines the update shader
  18415. */
  18416. applyToShader(effect: Effect): void;
  18417. /**
  18418. * Returns a string to use to update the GPU particles update shader
  18419. * @returns a string containng the defines string
  18420. */
  18421. getEffectDefines(): string;
  18422. /**
  18423. * Returns the string "SphereDirectedParticleEmitter"
  18424. * @returns a string containing the class name
  18425. */
  18426. getClassName(): string;
  18427. /**
  18428. * Serializes the particle system to a JSON object.
  18429. * @returns the JSON object
  18430. */
  18431. serialize(): any;
  18432. /**
  18433. * Parse properties from a JSON object
  18434. * @param serializationObject defines the JSON object
  18435. */
  18436. parse(serializationObject: any): void;
  18437. }
  18438. }
  18439. declare module "babylonjs/Particles/EmitterTypes/index" {
  18440. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18441. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18442. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18443. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18444. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18445. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18446. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18447. }
  18448. declare module "babylonjs/Particles/IParticleSystem" {
  18449. import { Nullable } from "babylonjs/types";
  18450. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18451. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18454. import { Texture } from "babylonjs/Materials/Textures/texture";
  18455. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18456. import { Scene } from "babylonjs/scene";
  18457. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18458. import { Animation } from "babylonjs/Animations/animation";
  18459. /**
  18460. * Interface representing a particle system in Babylon.js.
  18461. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18462. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18463. */
  18464. export interface IParticleSystem {
  18465. /**
  18466. * List of animations used by the particle system.
  18467. */
  18468. animations: Animation[];
  18469. /**
  18470. * The id of the Particle system.
  18471. */
  18472. id: string;
  18473. /**
  18474. * The name of the Particle system.
  18475. */
  18476. name: string;
  18477. /**
  18478. * The emitter represents the Mesh or position we are attaching the particle system to.
  18479. */
  18480. emitter: Nullable<AbstractMesh | Vector3>;
  18481. /**
  18482. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18483. */
  18484. isBillboardBased: boolean;
  18485. /**
  18486. * The rendering group used by the Particle system to chose when to render.
  18487. */
  18488. renderingGroupId: number;
  18489. /**
  18490. * The layer mask we are rendering the particles through.
  18491. */
  18492. layerMask: number;
  18493. /**
  18494. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18495. */
  18496. updateSpeed: number;
  18497. /**
  18498. * The amount of time the particle system is running (depends of the overall update speed).
  18499. */
  18500. targetStopDuration: number;
  18501. /**
  18502. * The texture used to render each particle. (this can be a spritesheet)
  18503. */
  18504. particleTexture: Nullable<Texture>;
  18505. /**
  18506. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18507. */
  18508. blendMode: number;
  18509. /**
  18510. * Minimum life time of emitting particles.
  18511. */
  18512. minLifeTime: number;
  18513. /**
  18514. * Maximum life time of emitting particles.
  18515. */
  18516. maxLifeTime: number;
  18517. /**
  18518. * Minimum Size of emitting particles.
  18519. */
  18520. minSize: number;
  18521. /**
  18522. * Maximum Size of emitting particles.
  18523. */
  18524. maxSize: number;
  18525. /**
  18526. * Minimum scale of emitting particles on X axis.
  18527. */
  18528. minScaleX: number;
  18529. /**
  18530. * Maximum scale of emitting particles on X axis.
  18531. */
  18532. maxScaleX: number;
  18533. /**
  18534. * Minimum scale of emitting particles on Y axis.
  18535. */
  18536. minScaleY: number;
  18537. /**
  18538. * Maximum scale of emitting particles on Y axis.
  18539. */
  18540. maxScaleY: number;
  18541. /**
  18542. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18543. */
  18544. color1: Color4;
  18545. /**
  18546. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18547. */
  18548. color2: Color4;
  18549. /**
  18550. * Color the particle will have at the end of its lifetime.
  18551. */
  18552. colorDead: Color4;
  18553. /**
  18554. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18555. */
  18556. emitRate: number;
  18557. /**
  18558. * You can use gravity if you want to give an orientation to your particles.
  18559. */
  18560. gravity: Vector3;
  18561. /**
  18562. * Minimum power of emitting particles.
  18563. */
  18564. minEmitPower: number;
  18565. /**
  18566. * Maximum power of emitting particles.
  18567. */
  18568. maxEmitPower: number;
  18569. /**
  18570. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18571. */
  18572. minAngularSpeed: number;
  18573. /**
  18574. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18575. */
  18576. maxAngularSpeed: number;
  18577. /**
  18578. * Gets or sets the minimal initial rotation in radians.
  18579. */
  18580. minInitialRotation: number;
  18581. /**
  18582. * Gets or sets the maximal initial rotation in radians.
  18583. */
  18584. maxInitialRotation: number;
  18585. /**
  18586. * The particle emitter type defines the emitter used by the particle system.
  18587. * It can be for example box, sphere, or cone...
  18588. */
  18589. particleEmitterType: Nullable<IParticleEmitterType>;
  18590. /**
  18591. * Defines the delay in milliseconds before starting the system (0 by default)
  18592. */
  18593. startDelay: number;
  18594. /**
  18595. * 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
  18596. */
  18597. preWarmCycles: number;
  18598. /**
  18599. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18600. */
  18601. preWarmStepOffset: number;
  18602. /**
  18603. * 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)
  18604. */
  18605. spriteCellChangeSpeed: number;
  18606. /**
  18607. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18608. */
  18609. startSpriteCellID: number;
  18610. /**
  18611. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18612. */
  18613. endSpriteCellID: number;
  18614. /**
  18615. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18616. */
  18617. spriteCellWidth: number;
  18618. /**
  18619. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18620. */
  18621. spriteCellHeight: number;
  18622. /**
  18623. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18624. */
  18625. spriteRandomStartCell: boolean;
  18626. /**
  18627. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18628. */
  18629. isAnimationSheetEnabled: boolean;
  18630. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18631. translationPivot: Vector2;
  18632. /**
  18633. * Gets or sets a texture used to add random noise to particle positions
  18634. */
  18635. noiseTexture: Nullable<BaseTexture>;
  18636. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18637. noiseStrength: Vector3;
  18638. /**
  18639. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18640. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18641. */
  18642. billboardMode: number;
  18643. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18644. limitVelocityDamping: number;
  18645. /**
  18646. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18647. */
  18648. beginAnimationOnStart: boolean;
  18649. /**
  18650. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18651. */
  18652. beginAnimationFrom: number;
  18653. /**
  18654. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18655. */
  18656. beginAnimationTo: number;
  18657. /**
  18658. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18659. */
  18660. beginAnimationLoop: boolean;
  18661. /**
  18662. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18663. */
  18664. disposeOnStop: boolean;
  18665. /**
  18666. * Gets the maximum number of particles active at the same time.
  18667. * @returns The max number of active particles.
  18668. */
  18669. getCapacity(): number;
  18670. /**
  18671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18672. * @returns True if it has been started, otherwise false.
  18673. */
  18674. isStarted(): boolean;
  18675. /**
  18676. * Animates the particle system for this frame.
  18677. */
  18678. animate(): void;
  18679. /**
  18680. * Renders the particle system in its current state.
  18681. * @returns the current number of particles
  18682. */
  18683. render(): number;
  18684. /**
  18685. * Dispose the particle system and frees its associated resources.
  18686. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18687. */
  18688. dispose(disposeTexture?: boolean): void;
  18689. /**
  18690. * Clones the particle system.
  18691. * @param name The name of the cloned object
  18692. * @param newEmitter The new emitter to use
  18693. * @returns the cloned particle system
  18694. */
  18695. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18696. /**
  18697. * Serializes the particle system to a JSON object.
  18698. * @returns the JSON object
  18699. */
  18700. serialize(): any;
  18701. /**
  18702. * Rebuild the particle system
  18703. */
  18704. rebuild(): void;
  18705. /**
  18706. * Starts the particle system and begins to emit
  18707. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18708. */
  18709. start(delay?: number): void;
  18710. /**
  18711. * Stops the particle system.
  18712. */
  18713. stop(): void;
  18714. /**
  18715. * Remove all active particles
  18716. */
  18717. reset(): void;
  18718. /**
  18719. * Is this system ready to be used/rendered
  18720. * @return true if the system is ready
  18721. */
  18722. isReady(): boolean;
  18723. /**
  18724. * Adds a new color gradient
  18725. * @param gradient defines the gradient to use (between 0 and 1)
  18726. * @param color1 defines the color to affect to the specified gradient
  18727. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18728. * @returns the current particle system
  18729. */
  18730. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18731. /**
  18732. * Remove a specific color gradient
  18733. * @param gradient defines the gradient to remove
  18734. * @returns the current particle system
  18735. */
  18736. removeColorGradient(gradient: number): IParticleSystem;
  18737. /**
  18738. * Adds a new size gradient
  18739. * @param gradient defines the gradient to use (between 0 and 1)
  18740. * @param factor defines the size factor to affect to the specified gradient
  18741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18742. * @returns the current particle system
  18743. */
  18744. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18745. /**
  18746. * Remove a specific size gradient
  18747. * @param gradient defines the gradient to remove
  18748. * @returns the current particle system
  18749. */
  18750. removeSizeGradient(gradient: number): IParticleSystem;
  18751. /**
  18752. * Gets the current list of color gradients.
  18753. * You must use addColorGradient and removeColorGradient to udpate this list
  18754. * @returns the list of color gradients
  18755. */
  18756. getColorGradients(): Nullable<Array<ColorGradient>>;
  18757. /**
  18758. * Gets the current list of size gradients.
  18759. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18760. * @returns the list of size gradients
  18761. */
  18762. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18763. /**
  18764. * Gets the current list of angular speed gradients.
  18765. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18766. * @returns the list of angular speed gradients
  18767. */
  18768. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18769. /**
  18770. * Adds a new angular speed gradient
  18771. * @param gradient defines the gradient to use (between 0 and 1)
  18772. * @param factor defines the angular speed to affect to the specified gradient
  18773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18774. * @returns the current particle system
  18775. */
  18776. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18777. /**
  18778. * Remove a specific angular speed gradient
  18779. * @param gradient defines the gradient to remove
  18780. * @returns the current particle system
  18781. */
  18782. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18783. /**
  18784. * Gets the current list of velocity gradients.
  18785. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18786. * @returns the list of velocity gradients
  18787. */
  18788. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18789. /**
  18790. * Adds a new velocity gradient
  18791. * @param gradient defines the gradient to use (between 0 and 1)
  18792. * @param factor defines the velocity to affect to the specified gradient
  18793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18794. * @returns the current particle system
  18795. */
  18796. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18797. /**
  18798. * Remove a specific velocity gradient
  18799. * @param gradient defines the gradient to remove
  18800. * @returns the current particle system
  18801. */
  18802. removeVelocityGradient(gradient: number): IParticleSystem;
  18803. /**
  18804. * Gets the current list of limit velocity gradients.
  18805. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18806. * @returns the list of limit velocity gradients
  18807. */
  18808. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18809. /**
  18810. * Adds a new limit velocity gradient
  18811. * @param gradient defines the gradient to use (between 0 and 1)
  18812. * @param factor defines the limit velocity to affect to the specified gradient
  18813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18814. * @returns the current particle system
  18815. */
  18816. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18817. /**
  18818. * Remove a specific limit velocity gradient
  18819. * @param gradient defines the gradient to remove
  18820. * @returns the current particle system
  18821. */
  18822. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18823. /**
  18824. * Adds a new drag gradient
  18825. * @param gradient defines the gradient to use (between 0 and 1)
  18826. * @param factor defines the drag to affect to the specified gradient
  18827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18828. * @returns the current particle system
  18829. */
  18830. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18831. /**
  18832. * Remove a specific drag gradient
  18833. * @param gradient defines the gradient to remove
  18834. * @returns the current particle system
  18835. */
  18836. removeDragGradient(gradient: number): IParticleSystem;
  18837. /**
  18838. * Gets the current list of drag gradients.
  18839. * You must use addDragGradient and removeDragGradient to udpate this list
  18840. * @returns the list of drag gradients
  18841. */
  18842. getDragGradients(): Nullable<Array<FactorGradient>>;
  18843. /**
  18844. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18845. * @param gradient defines the gradient to use (between 0 and 1)
  18846. * @param factor defines the emit rate to affect to the specified gradient
  18847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18848. * @returns the current particle system
  18849. */
  18850. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18851. /**
  18852. * Remove a specific emit rate gradient
  18853. * @param gradient defines the gradient to remove
  18854. * @returns the current particle system
  18855. */
  18856. removeEmitRateGradient(gradient: number): IParticleSystem;
  18857. /**
  18858. * Gets the current list of emit rate gradients.
  18859. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18860. * @returns the list of emit rate gradients
  18861. */
  18862. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18863. /**
  18864. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18865. * @param gradient defines the gradient to use (between 0 and 1)
  18866. * @param factor defines the start size to affect to the specified gradient
  18867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18868. * @returns the current particle system
  18869. */
  18870. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18871. /**
  18872. * Remove a specific start size gradient
  18873. * @param gradient defines the gradient to remove
  18874. * @returns the current particle system
  18875. */
  18876. removeStartSizeGradient(gradient: number): IParticleSystem;
  18877. /**
  18878. * Gets the current list of start size gradients.
  18879. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18880. * @returns the list of start size gradients
  18881. */
  18882. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18883. /**
  18884. * Adds a new life time gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the life time factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific life time gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of life time gradients.
  18899. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18900. * @returns the list of life time gradients
  18901. */
  18902. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18903. /**
  18904. * Gets the current list of color gradients.
  18905. * You must use addColorGradient and removeColorGradient to udpate this list
  18906. * @returns the list of color gradients
  18907. */
  18908. getColorGradients(): Nullable<Array<ColorGradient>>;
  18909. /**
  18910. * Adds a new ramp gradient used to remap particle colors
  18911. * @param gradient defines the gradient to use (between 0 and 1)
  18912. * @param color defines the color to affect to the specified gradient
  18913. * @returns the current particle system
  18914. */
  18915. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18916. /**
  18917. * Gets the current list of ramp gradients.
  18918. * You must use addRampGradient and removeRampGradient to udpate this list
  18919. * @returns the list of ramp gradients
  18920. */
  18921. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18922. /** Gets or sets a boolean indicating that ramp gradients must be used
  18923. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18924. */
  18925. useRampGradients: boolean;
  18926. /**
  18927. * Adds a new color remap gradient
  18928. * @param gradient defines the gradient to use (between 0 and 1)
  18929. * @param min defines the color remap minimal range
  18930. * @param max defines the color remap maximal range
  18931. * @returns the current particle system
  18932. */
  18933. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18934. /**
  18935. * Gets the current list of color remap gradients.
  18936. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18937. * @returns the list of color remap gradients
  18938. */
  18939. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18940. /**
  18941. * Adds a new alpha remap gradient
  18942. * @param gradient defines the gradient to use (between 0 and 1)
  18943. * @param min defines the alpha remap minimal range
  18944. * @param max defines the alpha remap maximal range
  18945. * @returns the current particle system
  18946. */
  18947. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18948. /**
  18949. * Gets the current list of alpha remap gradients.
  18950. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18951. * @returns the list of alpha remap gradients
  18952. */
  18953. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18958. * @returns the emitter
  18959. */
  18960. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18961. /**
  18962. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18963. * @param radius The radius of the hemisphere to emit from
  18964. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18965. * @returns the emitter
  18966. */
  18967. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18968. /**
  18969. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18970. * @param radius The radius of the sphere to emit from
  18971. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18972. * @returns the emitter
  18973. */
  18974. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18975. /**
  18976. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18977. * @param radius The radius of the sphere to emit from
  18978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18980. * @returns the emitter
  18981. */
  18982. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18983. /**
  18984. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18985. * @param radius The radius of the emission cylinder
  18986. * @param height The height of the emission cylinder
  18987. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18988. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18989. * @returns the emitter
  18990. */
  18991. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18992. /**
  18993. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18994. * @param radius The radius of the cylinder to emit from
  18995. * @param height The height of the emission cylinder
  18996. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18997. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18998. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18999. * @returns the emitter
  19000. */
  19001. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19002. /**
  19003. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19004. * @param radius The radius of the cone to emit from
  19005. * @param angle The base angle of the cone
  19006. * @returns the emitter
  19007. */
  19008. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19009. /**
  19010. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19013. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19014. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19015. * @returns the emitter
  19016. */
  19017. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19018. /**
  19019. * Get hosting scene
  19020. * @returns the scene
  19021. */
  19022. getScene(): Scene;
  19023. }
  19024. }
  19025. declare module "babylonjs/Meshes/instancedMesh" {
  19026. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19027. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19028. import { Camera } from "babylonjs/Cameras/camera";
  19029. import { Node } from "babylonjs/node";
  19030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19031. import { Mesh } from "babylonjs/Meshes/mesh";
  19032. import { Material } from "babylonjs/Materials/material";
  19033. import { Skeleton } from "babylonjs/Bones/skeleton";
  19034. import { Light } from "babylonjs/Lights/light";
  19035. /**
  19036. * Creates an instance based on a source mesh.
  19037. */
  19038. export class InstancedMesh extends AbstractMesh {
  19039. private _sourceMesh;
  19040. private _currentLOD;
  19041. /** @hidden */
  19042. _indexInSourceMeshInstanceArray: number;
  19043. constructor(name: string, source: Mesh);
  19044. /**
  19045. * Returns the string "InstancedMesh".
  19046. */
  19047. getClassName(): string;
  19048. /** Gets the list of lights affecting that mesh */
  19049. readonly lightSources: Light[];
  19050. _resyncLightSources(): void;
  19051. _resyncLighSource(light: Light): void;
  19052. _removeLightSource(light: Light): void;
  19053. /**
  19054. * If the source mesh receives shadows
  19055. */
  19056. readonly receiveShadows: boolean;
  19057. /**
  19058. * The material of the source mesh
  19059. */
  19060. readonly material: Nullable<Material>;
  19061. /**
  19062. * Visibility of the source mesh
  19063. */
  19064. readonly visibility: number;
  19065. /**
  19066. * Skeleton of the source mesh
  19067. */
  19068. readonly skeleton: Nullable<Skeleton>;
  19069. /**
  19070. * Rendering ground id of the source mesh
  19071. */
  19072. renderingGroupId: number;
  19073. /**
  19074. * Returns the total number of vertices (integer).
  19075. */
  19076. getTotalVertices(): number;
  19077. /**
  19078. * Returns a positive integer : the total number of indices in this mesh geometry.
  19079. * @returns the numner of indices or zero if the mesh has no geometry.
  19080. */
  19081. getTotalIndices(): number;
  19082. /**
  19083. * The source mesh of the instance
  19084. */
  19085. readonly sourceMesh: Mesh;
  19086. /**
  19087. * Is this node ready to be used/rendered
  19088. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19089. * @return {boolean} is it ready
  19090. */
  19091. isReady(completeCheck?: boolean): boolean;
  19092. /**
  19093. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19094. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19095. * @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.
  19096. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19097. */
  19098. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19099. /**
  19100. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19101. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19102. * The `data` are either a numeric array either a Float32Array.
  19103. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19104. * 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).
  19105. * Note that a new underlying VertexBuffer object is created each call.
  19106. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19107. *
  19108. * Possible `kind` values :
  19109. * - VertexBuffer.PositionKind
  19110. * - VertexBuffer.UVKind
  19111. * - VertexBuffer.UV2Kind
  19112. * - VertexBuffer.UV3Kind
  19113. * - VertexBuffer.UV4Kind
  19114. * - VertexBuffer.UV5Kind
  19115. * - VertexBuffer.UV6Kind
  19116. * - VertexBuffer.ColorKind
  19117. * - VertexBuffer.MatricesIndicesKind
  19118. * - VertexBuffer.MatricesIndicesExtraKind
  19119. * - VertexBuffer.MatricesWeightsKind
  19120. * - VertexBuffer.MatricesWeightsExtraKind
  19121. *
  19122. * Returns the Mesh.
  19123. */
  19124. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19125. /**
  19126. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19127. * If the mesh has no geometry, it is simply returned as it is.
  19128. * The `data` are either a numeric array either a Float32Array.
  19129. * No new underlying VertexBuffer object is created.
  19130. * 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.
  19131. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19132. *
  19133. * Possible `kind` values :
  19134. * - VertexBuffer.PositionKind
  19135. * - VertexBuffer.UVKind
  19136. * - VertexBuffer.UV2Kind
  19137. * - VertexBuffer.UV3Kind
  19138. * - VertexBuffer.UV4Kind
  19139. * - VertexBuffer.UV5Kind
  19140. * - VertexBuffer.UV6Kind
  19141. * - VertexBuffer.ColorKind
  19142. * - VertexBuffer.MatricesIndicesKind
  19143. * - VertexBuffer.MatricesIndicesExtraKind
  19144. * - VertexBuffer.MatricesWeightsKind
  19145. * - VertexBuffer.MatricesWeightsExtraKind
  19146. *
  19147. * Returns the Mesh.
  19148. */
  19149. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19150. /**
  19151. * Sets the mesh indices.
  19152. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19153. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19154. * This method creates a new index buffer each call.
  19155. * Returns the Mesh.
  19156. */
  19157. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19158. /**
  19159. * Boolean : True if the mesh owns the requested kind of data.
  19160. */
  19161. isVerticesDataPresent(kind: string): boolean;
  19162. /**
  19163. * Returns an array of indices (IndicesArray).
  19164. */
  19165. getIndices(): Nullable<IndicesArray>;
  19166. readonly _positions: Nullable<Vector3[]>;
  19167. /**
  19168. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19169. * This means the mesh underlying bounding box and sphere are recomputed.
  19170. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19171. * @returns the current mesh
  19172. */
  19173. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19174. /** @hidden */
  19175. _preActivate(): InstancedMesh;
  19176. /** @hidden */
  19177. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19178. /** @hidden */
  19179. _postActivate(): void;
  19180. getWorldMatrix(): Matrix;
  19181. readonly isAnInstance: boolean;
  19182. /**
  19183. * Returns the current associated LOD AbstractMesh.
  19184. */
  19185. getLOD(camera: Camera): AbstractMesh;
  19186. /** @hidden */
  19187. _syncSubMeshes(): InstancedMesh;
  19188. /** @hidden */
  19189. _generatePointsArray(): boolean;
  19190. /**
  19191. * Creates a new InstancedMesh from the current mesh.
  19192. * - name (string) : the cloned mesh name
  19193. * - newParent (optional Node) : the optional Node to parent the clone to.
  19194. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19195. *
  19196. * Returns the clone.
  19197. */
  19198. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19199. /**
  19200. * Disposes the InstancedMesh.
  19201. * Returns nothing.
  19202. */
  19203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19204. }
  19205. }
  19206. declare module "babylonjs/Materials/shaderMaterial" {
  19207. import { Scene } from "babylonjs/scene";
  19208. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19210. import { Mesh } from "babylonjs/Meshes/mesh";
  19211. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19213. import { Texture } from "babylonjs/Materials/Textures/texture";
  19214. import { Material } from "babylonjs/Materials/material";
  19215. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19216. /**
  19217. * Defines the options associated with the creation of a shader material.
  19218. */
  19219. export interface IShaderMaterialOptions {
  19220. /**
  19221. * Does the material work in alpha blend mode
  19222. */
  19223. needAlphaBlending: boolean;
  19224. /**
  19225. * Does the material work in alpha test mode
  19226. */
  19227. needAlphaTesting: boolean;
  19228. /**
  19229. * The list of attribute names used in the shader
  19230. */
  19231. attributes: string[];
  19232. /**
  19233. * The list of unifrom names used in the shader
  19234. */
  19235. uniforms: string[];
  19236. /**
  19237. * The list of UBO names used in the shader
  19238. */
  19239. uniformBuffers: string[];
  19240. /**
  19241. * The list of sampler names used in the shader
  19242. */
  19243. samplers: string[];
  19244. /**
  19245. * The list of defines used in the shader
  19246. */
  19247. defines: string[];
  19248. }
  19249. /**
  19250. * 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.
  19251. *
  19252. * This returned material effects how the mesh will look based on the code in the shaders.
  19253. *
  19254. * @see http://doc.babylonjs.com/how_to/shader_material
  19255. */
  19256. export class ShaderMaterial extends Material {
  19257. private _shaderPath;
  19258. private _options;
  19259. private _textures;
  19260. private _textureArrays;
  19261. private _floats;
  19262. private _ints;
  19263. private _floatsArrays;
  19264. private _colors3;
  19265. private _colors3Arrays;
  19266. private _colors4;
  19267. private _colors4Arrays;
  19268. private _vectors2;
  19269. private _vectors3;
  19270. private _vectors4;
  19271. private _matrices;
  19272. private _matrices3x3;
  19273. private _matrices2x2;
  19274. private _vectors2Arrays;
  19275. private _vectors3Arrays;
  19276. private _vectors4Arrays;
  19277. private _cachedWorldViewMatrix;
  19278. private _cachedWorldViewProjectionMatrix;
  19279. private _renderId;
  19280. /**
  19281. * Instantiate a new shader material.
  19282. * 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.
  19283. * This returned material effects how the mesh will look based on the code in the shaders.
  19284. * @see http://doc.babylonjs.com/how_to/shader_material
  19285. * @param name Define the name of the material in the scene
  19286. * @param scene Define the scene the material belongs to
  19287. * @param shaderPath Defines the route to the shader code in one of three ways:
  19288. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19289. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19290. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19291. * @param options Define the options used to create the shader
  19292. */
  19293. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19294. /**
  19295. * Gets the options used to compile the shader.
  19296. * They can be modified to trigger a new compilation
  19297. */
  19298. readonly options: IShaderMaterialOptions;
  19299. /**
  19300. * Gets the current class name of the material e.g. "ShaderMaterial"
  19301. * Mainly use in serialization.
  19302. * @returns the class name
  19303. */
  19304. getClassName(): string;
  19305. /**
  19306. * Specifies if the material will require alpha blending
  19307. * @returns a boolean specifying if alpha blending is needed
  19308. */
  19309. needAlphaBlending(): boolean;
  19310. /**
  19311. * Specifies if this material should be rendered in alpha test mode
  19312. * @returns a boolean specifying if an alpha test is needed.
  19313. */
  19314. needAlphaTesting(): boolean;
  19315. private _checkUniform;
  19316. /**
  19317. * Set a texture in the shader.
  19318. * @param name Define the name of the uniform samplers as defined in the shader
  19319. * @param texture Define the texture to bind to this sampler
  19320. * @return the material itself allowing "fluent" like uniform updates
  19321. */
  19322. setTexture(name: string, texture: Texture): ShaderMaterial;
  19323. /**
  19324. * Set a texture array in the shader.
  19325. * @param name Define the name of the uniform sampler array as defined in the shader
  19326. * @param textures Define the list of textures to bind to this sampler
  19327. * @return the material itself allowing "fluent" like uniform updates
  19328. */
  19329. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19330. /**
  19331. * Set a float in the shader.
  19332. * @param name Define the name of the uniform as defined in the shader
  19333. * @param value Define the value to give to the uniform
  19334. * @return the material itself allowing "fluent" like uniform updates
  19335. */
  19336. setFloat(name: string, value: number): ShaderMaterial;
  19337. /**
  19338. * Set a int in the shader.
  19339. * @param name Define the name of the uniform as defined in the shader
  19340. * @param value Define the value to give to the uniform
  19341. * @return the material itself allowing "fluent" like uniform updates
  19342. */
  19343. setInt(name: string, value: number): ShaderMaterial;
  19344. /**
  19345. * Set an array of floats in the shader.
  19346. * @param name Define the name of the uniform as defined in the shader
  19347. * @param value Define the value to give to the uniform
  19348. * @return the material itself allowing "fluent" like uniform updates
  19349. */
  19350. setFloats(name: string, value: number[]): ShaderMaterial;
  19351. /**
  19352. * Set a vec3 in the shader from a Color3.
  19353. * @param name Define the name of the uniform as defined in the shader
  19354. * @param value Define the value to give to the uniform
  19355. * @return the material itself allowing "fluent" like uniform updates
  19356. */
  19357. setColor3(name: string, value: Color3): ShaderMaterial;
  19358. /**
  19359. * Set a vec3 array in the shader from a Color3 array.
  19360. * @param name Define the name of the uniform as defined in the shader
  19361. * @param value Define the value to give to the uniform
  19362. * @return the material itself allowing "fluent" like uniform updates
  19363. */
  19364. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19365. /**
  19366. * Set a vec4 in the shader from a Color4.
  19367. * @param name Define the name of the uniform as defined in the shader
  19368. * @param value Define the value to give to the uniform
  19369. * @return the material itself allowing "fluent" like uniform updates
  19370. */
  19371. setColor4(name: string, value: Color4): ShaderMaterial;
  19372. /**
  19373. * Set a vec4 array in the shader from a Color4 array.
  19374. * @param name Define the name of the uniform as defined in the shader
  19375. * @param value Define the value to give to the uniform
  19376. * @return the material itself allowing "fluent" like uniform updates
  19377. */
  19378. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19379. /**
  19380. * Set a vec2 in the shader from a Vector2.
  19381. * @param name Define the name of the uniform as defined in the shader
  19382. * @param value Define the value to give to the uniform
  19383. * @return the material itself allowing "fluent" like uniform updates
  19384. */
  19385. setVector2(name: string, value: Vector2): ShaderMaterial;
  19386. /**
  19387. * Set a vec3 in the shader from a Vector3.
  19388. * @param name Define the name of the uniform as defined in the shader
  19389. * @param value Define the value to give to the uniform
  19390. * @return the material itself allowing "fluent" like uniform updates
  19391. */
  19392. setVector3(name: string, value: Vector3): ShaderMaterial;
  19393. /**
  19394. * Set a vec4 in the shader from a Vector4.
  19395. * @param name Define the name of the uniform as defined in the shader
  19396. * @param value Define the value to give to the uniform
  19397. * @return the material itself allowing "fluent" like uniform updates
  19398. */
  19399. setVector4(name: string, value: Vector4): ShaderMaterial;
  19400. /**
  19401. * Set a mat4 in the shader from a Matrix.
  19402. * @param name Define the name of the uniform as defined in the shader
  19403. * @param value Define the value to give to the uniform
  19404. * @return the material itself allowing "fluent" like uniform updates
  19405. */
  19406. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19407. /**
  19408. * Set a mat3 in the shader from a Float32Array.
  19409. * @param name Define the name of the uniform as defined in the shader
  19410. * @param value Define the value to give to the uniform
  19411. * @return the material itself allowing "fluent" like uniform updates
  19412. */
  19413. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19414. /**
  19415. * Set a mat2 in the shader from a Float32Array.
  19416. * @param name Define the name of the uniform as defined in the shader
  19417. * @param value Define the value to give to the uniform
  19418. * @return the material itself allowing "fluent" like uniform updates
  19419. */
  19420. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19421. /**
  19422. * Set a vec2 array in the shader from a number array.
  19423. * @param name Define the name of the uniform as defined in the shader
  19424. * @param value Define the value to give to the uniform
  19425. * @return the material itself allowing "fluent" like uniform updates
  19426. */
  19427. setArray2(name: string, value: number[]): ShaderMaterial;
  19428. /**
  19429. * Set a vec3 array in the shader from a number array.
  19430. * @param name Define the name of the uniform as defined in the shader
  19431. * @param value Define the value to give to the uniform
  19432. * @return the material itself allowing "fluent" like uniform updates
  19433. */
  19434. setArray3(name: string, value: number[]): ShaderMaterial;
  19435. /**
  19436. * Set a vec4 array in the shader from a number array.
  19437. * @param name Define the name of the uniform as defined in the shader
  19438. * @param value Define the value to give to the uniform
  19439. * @return the material itself allowing "fluent" like uniform updates
  19440. */
  19441. setArray4(name: string, value: number[]): ShaderMaterial;
  19442. private _checkCache;
  19443. /**
  19444. * Specifies that the submesh is ready to be used
  19445. * @param mesh defines the mesh to check
  19446. * @param subMesh defines which submesh to check
  19447. * @param useInstances specifies that instances should be used
  19448. * @returns a boolean indicating that the submesh is ready or not
  19449. */
  19450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19451. /**
  19452. * Checks if the material is ready to render the requested mesh
  19453. * @param mesh Define the mesh to render
  19454. * @param useInstances Define whether or not the material is used with instances
  19455. * @returns true if ready, otherwise false
  19456. */
  19457. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19458. /**
  19459. * Binds the world matrix to the material
  19460. * @param world defines the world transformation matrix
  19461. */
  19462. bindOnlyWorldMatrix(world: Matrix): void;
  19463. /**
  19464. * Binds the material to the mesh
  19465. * @param world defines the world transformation matrix
  19466. * @param mesh defines the mesh to bind the material to
  19467. */
  19468. bind(world: Matrix, mesh?: Mesh): void;
  19469. /**
  19470. * Gets the active textures from the material
  19471. * @returns an array of textures
  19472. */
  19473. getActiveTextures(): BaseTexture[];
  19474. /**
  19475. * Specifies if the material uses a texture
  19476. * @param texture defines the texture to check against the material
  19477. * @returns a boolean specifying if the material uses the texture
  19478. */
  19479. hasTexture(texture: BaseTexture): boolean;
  19480. /**
  19481. * Makes a duplicate of the material, and gives it a new name
  19482. * @param name defines the new name for the duplicated material
  19483. * @returns the cloned material
  19484. */
  19485. clone(name: string): ShaderMaterial;
  19486. /**
  19487. * Disposes the material
  19488. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19489. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19490. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19491. */
  19492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19493. /**
  19494. * Serializes this material in a JSON representation
  19495. * @returns the serialized material object
  19496. */
  19497. serialize(): any;
  19498. /**
  19499. * Creates a shader material from parsed shader material data
  19500. * @param source defines the JSON represnetation of the material
  19501. * @param scene defines the hosting scene
  19502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19503. * @returns a new material
  19504. */
  19505. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19506. }
  19507. }
  19508. declare module "babylonjs/Shaders/color.fragment" {
  19509. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19511. /** @hidden */
  19512. export var colorPixelShader: {
  19513. name: string;
  19514. shader: string;
  19515. };
  19516. }
  19517. declare module "babylonjs/Shaders/color.vertex" {
  19518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19519. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19520. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19521. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19522. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19523. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19524. /** @hidden */
  19525. export var colorVertexShader: {
  19526. name: string;
  19527. shader: string;
  19528. };
  19529. }
  19530. declare module "babylonjs/Meshes/linesMesh" {
  19531. import { Nullable } from "babylonjs/types";
  19532. import { Scene } from "babylonjs/scene";
  19533. import { Color3 } from "babylonjs/Maths/math.color";
  19534. import { Node } from "babylonjs/node";
  19535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19536. import { Mesh } from "babylonjs/Meshes/mesh";
  19537. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19538. import { Effect } from "babylonjs/Materials/effect";
  19539. import { Material } from "babylonjs/Materials/material";
  19540. import "babylonjs/Shaders/color.fragment";
  19541. import "babylonjs/Shaders/color.vertex";
  19542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19543. /**
  19544. * Line mesh
  19545. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19546. */
  19547. export class LinesMesh extends Mesh {
  19548. /**
  19549. * If vertex color should be applied to the mesh
  19550. */
  19551. readonly useVertexColor?: boolean | undefined;
  19552. /**
  19553. * If vertex alpha should be applied to the mesh
  19554. */
  19555. readonly useVertexAlpha?: boolean | undefined;
  19556. /**
  19557. * Color of the line (Default: White)
  19558. */
  19559. color: Color3;
  19560. /**
  19561. * Alpha of the line (Default: 1)
  19562. */
  19563. alpha: number;
  19564. /**
  19565. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19566. * This margin is expressed in world space coordinates, so its value may vary.
  19567. * Default value is 0.1
  19568. */
  19569. intersectionThreshold: number;
  19570. private _colorShader;
  19571. private color4;
  19572. /**
  19573. * Creates a new LinesMesh
  19574. * @param name defines the name
  19575. * @param scene defines the hosting scene
  19576. * @param parent defines the parent mesh if any
  19577. * @param source defines the optional source LinesMesh used to clone data from
  19578. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19579. * When false, achieved by calling a clone(), also passing False.
  19580. * This will make creation of children, recursive.
  19581. * @param useVertexColor defines if this LinesMesh supports vertex color
  19582. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19583. */
  19584. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19585. /**
  19586. * If vertex color should be applied to the mesh
  19587. */
  19588. useVertexColor?: boolean | undefined,
  19589. /**
  19590. * If vertex alpha should be applied to the mesh
  19591. */
  19592. useVertexAlpha?: boolean | undefined);
  19593. private _addClipPlaneDefine;
  19594. private _removeClipPlaneDefine;
  19595. isReady(): boolean;
  19596. /**
  19597. * Returns the string "LineMesh"
  19598. */
  19599. getClassName(): string;
  19600. /**
  19601. * @hidden
  19602. */
  19603. /**
  19604. * @hidden
  19605. */
  19606. material: Material;
  19607. /**
  19608. * @hidden
  19609. */
  19610. readonly checkCollisions: boolean;
  19611. /** @hidden */
  19612. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19613. /** @hidden */
  19614. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19615. /**
  19616. * Disposes of the line mesh
  19617. * @param doNotRecurse If children should be disposed
  19618. */
  19619. dispose(doNotRecurse?: boolean): void;
  19620. /**
  19621. * Returns a new LineMesh object cloned from the current one.
  19622. */
  19623. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19624. /**
  19625. * Creates a new InstancedLinesMesh object from the mesh model.
  19626. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19627. * @param name defines the name of the new instance
  19628. * @returns a new InstancedLinesMesh
  19629. */
  19630. createInstance(name: string): InstancedLinesMesh;
  19631. }
  19632. /**
  19633. * Creates an instance based on a source LinesMesh
  19634. */
  19635. export class InstancedLinesMesh extends InstancedMesh {
  19636. /**
  19637. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19638. * This margin is expressed in world space coordinates, so its value may vary.
  19639. * Initilized with the intersectionThreshold value of the source LinesMesh
  19640. */
  19641. intersectionThreshold: number;
  19642. constructor(name: string, source: LinesMesh);
  19643. /**
  19644. * Returns the string "InstancedLinesMesh".
  19645. */
  19646. getClassName(): string;
  19647. }
  19648. }
  19649. declare module "babylonjs/Shaders/line.fragment" {
  19650. /** @hidden */
  19651. export var linePixelShader: {
  19652. name: string;
  19653. shader: string;
  19654. };
  19655. }
  19656. declare module "babylonjs/Shaders/line.vertex" {
  19657. /** @hidden */
  19658. export var lineVertexShader: {
  19659. name: string;
  19660. shader: string;
  19661. };
  19662. }
  19663. declare module "babylonjs/Rendering/edgesRenderer" {
  19664. import { Nullable } from "babylonjs/types";
  19665. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19667. import { Vector3 } from "babylonjs/Maths/math.vector";
  19668. import { IDisposable } from "babylonjs/scene";
  19669. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19670. import "babylonjs/Shaders/line.fragment";
  19671. import "babylonjs/Shaders/line.vertex";
  19672. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19673. module "babylonjs/Meshes/abstractMesh" {
  19674. interface AbstractMesh {
  19675. /**
  19676. * Gets the edgesRenderer associated with the mesh
  19677. */
  19678. edgesRenderer: Nullable<EdgesRenderer>;
  19679. }
  19680. }
  19681. module "babylonjs/Meshes/linesMesh" {
  19682. interface LinesMesh {
  19683. /**
  19684. * Enables the edge rendering mode on the mesh.
  19685. * This mode makes the mesh edges visible
  19686. * @param epsilon defines the maximal distance between two angles to detect a face
  19687. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19688. * @returns the currentAbstractMesh
  19689. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19690. */
  19691. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19692. }
  19693. }
  19694. module "babylonjs/Meshes/linesMesh" {
  19695. interface InstancedLinesMesh {
  19696. /**
  19697. * Enables the edge rendering mode on the mesh.
  19698. * This mode makes the mesh edges visible
  19699. * @param epsilon defines the maximal distance between two angles to detect a face
  19700. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19701. * @returns the current InstancedLinesMesh
  19702. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19703. */
  19704. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19705. }
  19706. }
  19707. /**
  19708. * Defines the minimum contract an Edges renderer should follow.
  19709. */
  19710. export interface IEdgesRenderer extends IDisposable {
  19711. /**
  19712. * Gets or sets a boolean indicating if the edgesRenderer is active
  19713. */
  19714. isEnabled: boolean;
  19715. /**
  19716. * Renders the edges of the attached mesh,
  19717. */
  19718. render(): void;
  19719. /**
  19720. * Checks wether or not the edges renderer is ready to render.
  19721. * @return true if ready, otherwise false.
  19722. */
  19723. isReady(): boolean;
  19724. }
  19725. /**
  19726. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19727. */
  19728. export class EdgesRenderer implements IEdgesRenderer {
  19729. /**
  19730. * Define the size of the edges with an orthographic camera
  19731. */
  19732. edgesWidthScalerForOrthographic: number;
  19733. /**
  19734. * Define the size of the edges with a perspective camera
  19735. */
  19736. edgesWidthScalerForPerspective: number;
  19737. protected _source: AbstractMesh;
  19738. protected _linesPositions: number[];
  19739. protected _linesNormals: number[];
  19740. protected _linesIndices: number[];
  19741. protected _epsilon: number;
  19742. protected _indicesCount: number;
  19743. protected _lineShader: ShaderMaterial;
  19744. protected _ib: DataBuffer;
  19745. protected _buffers: {
  19746. [key: string]: Nullable<VertexBuffer>;
  19747. };
  19748. protected _checkVerticesInsteadOfIndices: boolean;
  19749. private _meshRebuildObserver;
  19750. private _meshDisposeObserver;
  19751. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19752. isEnabled: boolean;
  19753. /**
  19754. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19755. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19756. * @param source Mesh used to create edges
  19757. * @param epsilon sum of angles in adjacency to check for edge
  19758. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19759. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19760. */
  19761. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19762. protected _prepareRessources(): void;
  19763. /** @hidden */
  19764. _rebuild(): void;
  19765. /**
  19766. * Releases the required resources for the edges renderer
  19767. */
  19768. dispose(): void;
  19769. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19770. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19771. /**
  19772. * Checks if the pair of p0 and p1 is en edge
  19773. * @param faceIndex
  19774. * @param edge
  19775. * @param faceNormals
  19776. * @param p0
  19777. * @param p1
  19778. * @private
  19779. */
  19780. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19781. /**
  19782. * push line into the position, normal and index buffer
  19783. * @protected
  19784. */
  19785. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19786. /**
  19787. * Generates lines edges from adjacencjes
  19788. * @private
  19789. */
  19790. _generateEdgesLines(): void;
  19791. /**
  19792. * Checks wether or not the edges renderer is ready to render.
  19793. * @return true if ready, otherwise false.
  19794. */
  19795. isReady(): boolean;
  19796. /**
  19797. * Renders the edges of the attached mesh,
  19798. */
  19799. render(): void;
  19800. }
  19801. /**
  19802. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19803. */
  19804. export class LineEdgesRenderer extends EdgesRenderer {
  19805. /**
  19806. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19807. * @param source LineMesh used to generate edges
  19808. * @param epsilon not important (specified angle for edge detection)
  19809. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19810. */
  19811. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19812. /**
  19813. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19814. */
  19815. _generateEdgesLines(): void;
  19816. }
  19817. }
  19818. declare module "babylonjs/Rendering/renderingGroup" {
  19819. import { SmartArray } from "babylonjs/Misc/smartArray";
  19820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19822. import { Nullable } from "babylonjs/types";
  19823. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19824. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19825. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19826. import { Material } from "babylonjs/Materials/material";
  19827. import { Scene } from "babylonjs/scene";
  19828. /**
  19829. * This represents the object necessary to create a rendering group.
  19830. * This is exclusively used and created by the rendering manager.
  19831. * To modify the behavior, you use the available helpers in your scene or meshes.
  19832. * @hidden
  19833. */
  19834. export class RenderingGroup {
  19835. index: number;
  19836. private static _zeroVector;
  19837. private _scene;
  19838. private _opaqueSubMeshes;
  19839. private _transparentSubMeshes;
  19840. private _alphaTestSubMeshes;
  19841. private _depthOnlySubMeshes;
  19842. private _particleSystems;
  19843. private _spriteManagers;
  19844. private _opaqueSortCompareFn;
  19845. private _alphaTestSortCompareFn;
  19846. private _transparentSortCompareFn;
  19847. private _renderOpaque;
  19848. private _renderAlphaTest;
  19849. private _renderTransparent;
  19850. /** @hidden */
  19851. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19852. onBeforeTransparentRendering: () => void;
  19853. /**
  19854. * Set the opaque sort comparison function.
  19855. * If null the sub meshes will be render in the order they were created
  19856. */
  19857. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19858. /**
  19859. * Set the alpha test sort comparison function.
  19860. * If null the sub meshes will be render in the order they were created
  19861. */
  19862. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19863. /**
  19864. * Set the transparent sort comparison function.
  19865. * If null the sub meshes will be render in the order they were created
  19866. */
  19867. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19868. /**
  19869. * Creates a new rendering group.
  19870. * @param index The rendering group index
  19871. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19872. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19873. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19874. */
  19875. 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>);
  19876. /**
  19877. * Render all the sub meshes contained in the group.
  19878. * @param customRenderFunction Used to override the default render behaviour of the group.
  19879. * @returns true if rendered some submeshes.
  19880. */
  19881. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19882. /**
  19883. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19884. * @param subMeshes The submeshes to render
  19885. */
  19886. private renderOpaqueSorted;
  19887. /**
  19888. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19889. * @param subMeshes The submeshes to render
  19890. */
  19891. private renderAlphaTestSorted;
  19892. /**
  19893. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19894. * @param subMeshes The submeshes to render
  19895. */
  19896. private renderTransparentSorted;
  19897. /**
  19898. * Renders the submeshes in a specified order.
  19899. * @param subMeshes The submeshes to sort before render
  19900. * @param sortCompareFn The comparison function use to sort
  19901. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19902. * @param transparent Specifies to activate blending if true
  19903. */
  19904. private static renderSorted;
  19905. /**
  19906. * Renders the submeshes in the order they were dispatched (no sort applied).
  19907. * @param subMeshes The submeshes to render
  19908. */
  19909. private static renderUnsorted;
  19910. /**
  19911. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19912. * are rendered back to front if in the same alpha index.
  19913. *
  19914. * @param a The first submesh
  19915. * @param b The second submesh
  19916. * @returns The result of the comparison
  19917. */
  19918. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19919. /**
  19920. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19921. * are rendered back to front.
  19922. *
  19923. * @param a The first submesh
  19924. * @param b The second submesh
  19925. * @returns The result of the comparison
  19926. */
  19927. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19928. /**
  19929. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19930. * are rendered front to back (prevent overdraw).
  19931. *
  19932. * @param a The first submesh
  19933. * @param b The second submesh
  19934. * @returns The result of the comparison
  19935. */
  19936. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19937. /**
  19938. * Resets the different lists of submeshes to prepare a new frame.
  19939. */
  19940. prepare(): void;
  19941. dispose(): void;
  19942. /**
  19943. * Inserts the submesh in its correct queue depending on its material.
  19944. * @param subMesh The submesh to dispatch
  19945. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19946. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19947. */
  19948. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19949. dispatchSprites(spriteManager: ISpriteManager): void;
  19950. dispatchParticles(particleSystem: IParticleSystem): void;
  19951. private _renderParticles;
  19952. private _renderSprites;
  19953. }
  19954. }
  19955. declare module "babylonjs/Rendering/renderingManager" {
  19956. import { Nullable } from "babylonjs/types";
  19957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19959. import { SmartArray } from "babylonjs/Misc/smartArray";
  19960. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19962. import { Material } from "babylonjs/Materials/material";
  19963. import { Scene } from "babylonjs/scene";
  19964. import { Camera } from "babylonjs/Cameras/camera";
  19965. /**
  19966. * Interface describing the different options available in the rendering manager
  19967. * regarding Auto Clear between groups.
  19968. */
  19969. export interface IRenderingManagerAutoClearSetup {
  19970. /**
  19971. * Defines whether or not autoclear is enable.
  19972. */
  19973. autoClear: boolean;
  19974. /**
  19975. * Defines whether or not to autoclear the depth buffer.
  19976. */
  19977. depth: boolean;
  19978. /**
  19979. * Defines whether or not to autoclear the stencil buffer.
  19980. */
  19981. stencil: boolean;
  19982. }
  19983. /**
  19984. * This class is used by the onRenderingGroupObservable
  19985. */
  19986. export class RenderingGroupInfo {
  19987. /**
  19988. * The Scene that being rendered
  19989. */
  19990. scene: Scene;
  19991. /**
  19992. * The camera currently used for the rendering pass
  19993. */
  19994. camera: Nullable<Camera>;
  19995. /**
  19996. * The ID of the renderingGroup being processed
  19997. */
  19998. renderingGroupId: number;
  19999. }
  20000. /**
  20001. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20002. * It is enable to manage the different groups as well as the different necessary sort functions.
  20003. * This should not be used directly aside of the few static configurations
  20004. */
  20005. export class RenderingManager {
  20006. /**
  20007. * The max id used for rendering groups (not included)
  20008. */
  20009. static MAX_RENDERINGGROUPS: number;
  20010. /**
  20011. * The min id used for rendering groups (included)
  20012. */
  20013. static MIN_RENDERINGGROUPS: number;
  20014. /**
  20015. * Used to globally prevent autoclearing scenes.
  20016. */
  20017. static AUTOCLEAR: boolean;
  20018. /**
  20019. * @hidden
  20020. */
  20021. _useSceneAutoClearSetup: boolean;
  20022. private _scene;
  20023. private _renderingGroups;
  20024. private _depthStencilBufferAlreadyCleaned;
  20025. private _autoClearDepthStencil;
  20026. private _customOpaqueSortCompareFn;
  20027. private _customAlphaTestSortCompareFn;
  20028. private _customTransparentSortCompareFn;
  20029. private _renderingGroupInfo;
  20030. /**
  20031. * Instantiates a new rendering group for a particular scene
  20032. * @param scene Defines the scene the groups belongs to
  20033. */
  20034. constructor(scene: Scene);
  20035. private _clearDepthStencilBuffer;
  20036. /**
  20037. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20038. * @hidden
  20039. */
  20040. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20041. /**
  20042. * Resets the different information of the group to prepare a new frame
  20043. * @hidden
  20044. */
  20045. reset(): void;
  20046. /**
  20047. * Dispose and release the group and its associated resources.
  20048. * @hidden
  20049. */
  20050. dispose(): void;
  20051. /**
  20052. * Clear the info related to rendering groups preventing retention points during dispose.
  20053. */
  20054. freeRenderingGroups(): void;
  20055. private _prepareRenderingGroup;
  20056. /**
  20057. * Add a sprite manager to the rendering manager in order to render it this frame.
  20058. * @param spriteManager Define the sprite manager to render
  20059. */
  20060. dispatchSprites(spriteManager: ISpriteManager): void;
  20061. /**
  20062. * Add a particle system to the rendering manager in order to render it this frame.
  20063. * @param particleSystem Define the particle system to render
  20064. */
  20065. dispatchParticles(particleSystem: IParticleSystem): void;
  20066. /**
  20067. * Add a submesh to the manager in order to render it this frame
  20068. * @param subMesh The submesh to dispatch
  20069. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20070. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20071. */
  20072. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20073. /**
  20074. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20075. * This allowed control for front to back rendering or reversly depending of the special needs.
  20076. *
  20077. * @param renderingGroupId The rendering group id corresponding to its index
  20078. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20079. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20080. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20081. */
  20082. 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;
  20083. /**
  20084. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20085. *
  20086. * @param renderingGroupId The rendering group id corresponding to its index
  20087. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20088. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20089. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20090. */
  20091. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20092. /**
  20093. * Gets the current auto clear configuration for one rendering group of the rendering
  20094. * manager.
  20095. * @param index the rendering group index to get the information for
  20096. * @returns The auto clear setup for the requested rendering group
  20097. */
  20098. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20099. }
  20100. }
  20101. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20102. import { Observable } from "babylonjs/Misc/observable";
  20103. import { SmartArray } from "babylonjs/Misc/smartArray";
  20104. import { Nullable } from "babylonjs/types";
  20105. import { Camera } from "babylonjs/Cameras/camera";
  20106. import { Scene } from "babylonjs/scene";
  20107. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20108. import { Color4 } from "babylonjs/Maths/math.color";
  20109. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20111. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20113. import { Texture } from "babylonjs/Materials/Textures/texture";
  20114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20115. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20116. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20117. import { Engine } from "babylonjs/Engines/engine";
  20118. /**
  20119. * This Helps creating a texture that will be created from a camera in your scene.
  20120. * It is basically a dynamic texture that could be used to create special effects for instance.
  20121. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20122. */
  20123. export class RenderTargetTexture extends Texture {
  20124. isCube: boolean;
  20125. /**
  20126. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20127. */
  20128. static readonly REFRESHRATE_RENDER_ONCE: number;
  20129. /**
  20130. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20131. */
  20132. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20133. /**
  20134. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20135. * the central point of your effect and can save a lot of performances.
  20136. */
  20137. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20138. /**
  20139. * Use this predicate to dynamically define the list of mesh you want to render.
  20140. * If set, the renderList property will be overwritten.
  20141. */
  20142. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20143. private _renderList;
  20144. /**
  20145. * Use this list to define the list of mesh you want to render.
  20146. */
  20147. renderList: Nullable<Array<AbstractMesh>>;
  20148. private _hookArray;
  20149. /**
  20150. * Define if particles should be rendered in your texture.
  20151. */
  20152. renderParticles: boolean;
  20153. /**
  20154. * Define if sprites should be rendered in your texture.
  20155. */
  20156. renderSprites: boolean;
  20157. /**
  20158. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20159. */
  20160. coordinatesMode: number;
  20161. /**
  20162. * Define the camera used to render the texture.
  20163. */
  20164. activeCamera: Nullable<Camera>;
  20165. /**
  20166. * Override the render function of the texture with your own one.
  20167. */
  20168. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20169. /**
  20170. * Define if camera post processes should be use while rendering the texture.
  20171. */
  20172. useCameraPostProcesses: boolean;
  20173. /**
  20174. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20175. */
  20176. ignoreCameraViewport: boolean;
  20177. private _postProcessManager;
  20178. private _postProcesses;
  20179. private _resizeObserver;
  20180. /**
  20181. * An event triggered when the texture is unbind.
  20182. */
  20183. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20184. /**
  20185. * An event triggered when the texture is unbind.
  20186. */
  20187. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20188. private _onAfterUnbindObserver;
  20189. /**
  20190. * Set a after unbind callback in the texture.
  20191. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20192. */
  20193. onAfterUnbind: () => void;
  20194. /**
  20195. * An event triggered before rendering the texture
  20196. */
  20197. onBeforeRenderObservable: Observable<number>;
  20198. private _onBeforeRenderObserver;
  20199. /**
  20200. * Set a before render callback in the texture.
  20201. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20202. */
  20203. onBeforeRender: (faceIndex: number) => void;
  20204. /**
  20205. * An event triggered after rendering the texture
  20206. */
  20207. onAfterRenderObservable: Observable<number>;
  20208. private _onAfterRenderObserver;
  20209. /**
  20210. * Set a after render callback in the texture.
  20211. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20212. */
  20213. onAfterRender: (faceIndex: number) => void;
  20214. /**
  20215. * An event triggered after the texture clear
  20216. */
  20217. onClearObservable: Observable<Engine>;
  20218. private _onClearObserver;
  20219. /**
  20220. * Set a clear callback in the texture.
  20221. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20222. */
  20223. onClear: (Engine: Engine) => void;
  20224. /**
  20225. * An event triggered when the texture is resized.
  20226. */
  20227. onResizeObservable: Observable<RenderTargetTexture>;
  20228. /**
  20229. * Define the clear color of the Render Target if it should be different from the scene.
  20230. */
  20231. clearColor: Color4;
  20232. protected _size: number | {
  20233. width: number;
  20234. height: number;
  20235. };
  20236. protected _initialSizeParameter: number | {
  20237. width: number;
  20238. height: number;
  20239. } | {
  20240. ratio: number;
  20241. };
  20242. protected _sizeRatio: Nullable<number>;
  20243. /** @hidden */
  20244. _generateMipMaps: boolean;
  20245. protected _renderingManager: RenderingManager;
  20246. /** @hidden */
  20247. _waitingRenderList: string[];
  20248. protected _doNotChangeAspectRatio: boolean;
  20249. protected _currentRefreshId: number;
  20250. protected _refreshRate: number;
  20251. protected _textureMatrix: Matrix;
  20252. protected _samples: number;
  20253. protected _renderTargetOptions: RenderTargetCreationOptions;
  20254. /**
  20255. * Gets render target creation options that were used.
  20256. */
  20257. readonly renderTargetOptions: RenderTargetCreationOptions;
  20258. protected _engine: Engine;
  20259. protected _onRatioRescale(): void;
  20260. /**
  20261. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20262. * It must define where the camera used to render the texture is set
  20263. */
  20264. boundingBoxPosition: Vector3;
  20265. private _boundingBoxSize;
  20266. /**
  20267. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20268. * When defined, the cubemap will switch to local mode
  20269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20270. * @example https://www.babylonjs-playground.com/#RNASML
  20271. */
  20272. boundingBoxSize: Vector3;
  20273. /**
  20274. * In case the RTT has been created with a depth texture, get the associated
  20275. * depth texture.
  20276. * Otherwise, return null.
  20277. */
  20278. depthStencilTexture: Nullable<InternalTexture>;
  20279. /**
  20280. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20281. * or used a shadow, depth texture...
  20282. * @param name The friendly name of the texture
  20283. * @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)
  20284. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20285. * @param generateMipMaps True if mip maps need to be generated after render.
  20286. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20287. * @param type The type of the buffer in the RTT (int, half float, float...)
  20288. * @param isCube True if a cube texture needs to be created
  20289. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20290. * @param generateDepthBuffer True to generate a depth buffer
  20291. * @param generateStencilBuffer True to generate a stencil buffer
  20292. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20293. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20294. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20295. */
  20296. constructor(name: string, size: number | {
  20297. width: number;
  20298. height: number;
  20299. } | {
  20300. ratio: number;
  20301. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20302. /**
  20303. * Creates a depth stencil texture.
  20304. * This is only available in WebGL 2 or with the depth texture extension available.
  20305. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20306. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20307. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20308. */
  20309. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20310. private _processSizeParameter;
  20311. /**
  20312. * Define the number of samples to use in case of MSAA.
  20313. * It defaults to one meaning no MSAA has been enabled.
  20314. */
  20315. samples: number;
  20316. /**
  20317. * Resets the refresh counter of the texture and start bak from scratch.
  20318. * Could be useful to regenerate the texture if it is setup to render only once.
  20319. */
  20320. resetRefreshCounter(): void;
  20321. /**
  20322. * Define the refresh rate of the texture or the rendering frequency.
  20323. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20324. */
  20325. refreshRate: number;
  20326. /**
  20327. * Adds a post process to the render target rendering passes.
  20328. * @param postProcess define the post process to add
  20329. */
  20330. addPostProcess(postProcess: PostProcess): void;
  20331. /**
  20332. * Clear all the post processes attached to the render target
  20333. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20334. */
  20335. clearPostProcesses(dispose?: boolean): void;
  20336. /**
  20337. * Remove one of the post process from the list of attached post processes to the texture
  20338. * @param postProcess define the post process to remove from the list
  20339. */
  20340. removePostProcess(postProcess: PostProcess): void;
  20341. /** @hidden */
  20342. _shouldRender(): boolean;
  20343. /**
  20344. * Gets the actual render size of the texture.
  20345. * @returns the width of the render size
  20346. */
  20347. getRenderSize(): number;
  20348. /**
  20349. * Gets the actual render width of the texture.
  20350. * @returns the width of the render size
  20351. */
  20352. getRenderWidth(): number;
  20353. /**
  20354. * Gets the actual render height of the texture.
  20355. * @returns the height of the render size
  20356. */
  20357. getRenderHeight(): number;
  20358. /**
  20359. * Get if the texture can be rescaled or not.
  20360. */
  20361. readonly canRescale: boolean;
  20362. /**
  20363. * Resize the texture using a ratio.
  20364. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20365. */
  20366. scale(ratio: number): void;
  20367. /**
  20368. * Get the texture reflection matrix used to rotate/transform the reflection.
  20369. * @returns the reflection matrix
  20370. */
  20371. getReflectionTextureMatrix(): Matrix;
  20372. /**
  20373. * Resize the texture to a new desired size.
  20374. * Be carrefull as it will recreate all the data in the new texture.
  20375. * @param size Define the new size. It can be:
  20376. * - a number for squared texture,
  20377. * - an object containing { width: number, height: number }
  20378. * - or an object containing a ratio { ratio: number }
  20379. */
  20380. resize(size: number | {
  20381. width: number;
  20382. height: number;
  20383. } | {
  20384. ratio: number;
  20385. }): void;
  20386. /**
  20387. * Renders all the objects from the render list into the texture.
  20388. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20389. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20390. */
  20391. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20392. private _bestReflectionRenderTargetDimension;
  20393. /**
  20394. * @hidden
  20395. * @param faceIndex face index to bind to if this is a cubetexture
  20396. */
  20397. _bindFrameBuffer(faceIndex?: number): void;
  20398. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20399. private renderToTarget;
  20400. /**
  20401. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20402. * This allowed control for front to back rendering or reversly depending of the special needs.
  20403. *
  20404. * @param renderingGroupId The rendering group id corresponding to its index
  20405. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20406. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20407. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20408. */
  20409. 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;
  20410. /**
  20411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20412. *
  20413. * @param renderingGroupId The rendering group id corresponding to its index
  20414. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20415. */
  20416. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20417. /**
  20418. * Clones the texture.
  20419. * @returns the cloned texture
  20420. */
  20421. clone(): RenderTargetTexture;
  20422. /**
  20423. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20424. * @returns The JSON representation of the texture
  20425. */
  20426. serialize(): any;
  20427. /**
  20428. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20429. */
  20430. disposeFramebufferObjects(): void;
  20431. /**
  20432. * Dispose the texture and release its associated resources.
  20433. */
  20434. dispose(): void;
  20435. /** @hidden */
  20436. _rebuild(): void;
  20437. /**
  20438. * Clear the info related to rendering groups preventing retention point in material dispose.
  20439. */
  20440. freeRenderingGroups(): void;
  20441. /**
  20442. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20443. * @returns the view count
  20444. */
  20445. getViewCount(): number;
  20446. }
  20447. }
  20448. declare module "babylonjs/Materials/material" {
  20449. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20450. import { SmartArray } from "babylonjs/Misc/smartArray";
  20451. import { Observable } from "babylonjs/Misc/observable";
  20452. import { Nullable } from "babylonjs/types";
  20453. import { Scene } from "babylonjs/scene";
  20454. import { Matrix } from "babylonjs/Maths/math.vector";
  20455. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20457. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20458. import { Effect } from "babylonjs/Materials/effect";
  20459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20461. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20462. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20463. import { Mesh } from "babylonjs/Meshes/mesh";
  20464. import { Animation } from "babylonjs/Animations/animation";
  20465. /**
  20466. * Base class for the main features of a material in Babylon.js
  20467. */
  20468. export class Material implements IAnimatable {
  20469. /**
  20470. * Returns the triangle fill mode
  20471. */
  20472. static readonly TriangleFillMode: number;
  20473. /**
  20474. * Returns the wireframe mode
  20475. */
  20476. static readonly WireFrameFillMode: number;
  20477. /**
  20478. * Returns the point fill mode
  20479. */
  20480. static readonly PointFillMode: number;
  20481. /**
  20482. * Returns the point list draw mode
  20483. */
  20484. static readonly PointListDrawMode: number;
  20485. /**
  20486. * Returns the line list draw mode
  20487. */
  20488. static readonly LineListDrawMode: number;
  20489. /**
  20490. * Returns the line loop draw mode
  20491. */
  20492. static readonly LineLoopDrawMode: number;
  20493. /**
  20494. * Returns the line strip draw mode
  20495. */
  20496. static readonly LineStripDrawMode: number;
  20497. /**
  20498. * Returns the triangle strip draw mode
  20499. */
  20500. static readonly TriangleStripDrawMode: number;
  20501. /**
  20502. * Returns the triangle fan draw mode
  20503. */
  20504. static readonly TriangleFanDrawMode: number;
  20505. /**
  20506. * Stores the clock-wise side orientation
  20507. */
  20508. static readonly ClockWiseSideOrientation: number;
  20509. /**
  20510. * Stores the counter clock-wise side orientation
  20511. */
  20512. static readonly CounterClockWiseSideOrientation: number;
  20513. /**
  20514. * The dirty texture flag value
  20515. */
  20516. static readonly TextureDirtyFlag: number;
  20517. /**
  20518. * The dirty light flag value
  20519. */
  20520. static readonly LightDirtyFlag: number;
  20521. /**
  20522. * The dirty fresnel flag value
  20523. */
  20524. static readonly FresnelDirtyFlag: number;
  20525. /**
  20526. * The dirty attribute flag value
  20527. */
  20528. static readonly AttributesDirtyFlag: number;
  20529. /**
  20530. * The dirty misc flag value
  20531. */
  20532. static readonly MiscDirtyFlag: number;
  20533. /**
  20534. * The all dirty flag value
  20535. */
  20536. static readonly AllDirtyFlag: number;
  20537. /**
  20538. * The ID of the material
  20539. */
  20540. id: string;
  20541. /**
  20542. * Gets or sets the unique id of the material
  20543. */
  20544. uniqueId: number;
  20545. /**
  20546. * The name of the material
  20547. */
  20548. name: string;
  20549. /**
  20550. * Gets or sets user defined metadata
  20551. */
  20552. metadata: any;
  20553. /**
  20554. * For internal use only. Please do not use.
  20555. */
  20556. reservedDataStore: any;
  20557. /**
  20558. * Specifies if the ready state should be checked on each call
  20559. */
  20560. checkReadyOnEveryCall: boolean;
  20561. /**
  20562. * Specifies if the ready state should be checked once
  20563. */
  20564. checkReadyOnlyOnce: boolean;
  20565. /**
  20566. * The state of the material
  20567. */
  20568. state: string;
  20569. /**
  20570. * The alpha value of the material
  20571. */
  20572. protected _alpha: number;
  20573. /**
  20574. * List of inspectable custom properties (used by the Inspector)
  20575. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20576. */
  20577. inspectableCustomProperties: IInspectable[];
  20578. /**
  20579. * Sets the alpha value of the material
  20580. */
  20581. /**
  20582. * Gets the alpha value of the material
  20583. */
  20584. alpha: number;
  20585. /**
  20586. * Specifies if back face culling is enabled
  20587. */
  20588. protected _backFaceCulling: boolean;
  20589. /**
  20590. * Sets the back-face culling state
  20591. */
  20592. /**
  20593. * Gets the back-face culling state
  20594. */
  20595. backFaceCulling: boolean;
  20596. /**
  20597. * Stores the value for side orientation
  20598. */
  20599. sideOrientation: number;
  20600. /**
  20601. * Callback triggered when the material is compiled
  20602. */
  20603. onCompiled: Nullable<(effect: Effect) => void>;
  20604. /**
  20605. * Callback triggered when an error occurs
  20606. */
  20607. onError: Nullable<(effect: Effect, errors: string) => void>;
  20608. /**
  20609. * Callback triggered to get the render target textures
  20610. */
  20611. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20612. /**
  20613. * Gets a boolean indicating that current material needs to register RTT
  20614. */
  20615. readonly hasRenderTargetTextures: boolean;
  20616. /**
  20617. * Specifies if the material should be serialized
  20618. */
  20619. doNotSerialize: boolean;
  20620. /**
  20621. * @hidden
  20622. */
  20623. _storeEffectOnSubMeshes: boolean;
  20624. /**
  20625. * Stores the animations for the material
  20626. */
  20627. animations: Nullable<Array<Animation>>;
  20628. /**
  20629. * An event triggered when the material is disposed
  20630. */
  20631. onDisposeObservable: Observable<Material>;
  20632. /**
  20633. * An observer which watches for dispose events
  20634. */
  20635. private _onDisposeObserver;
  20636. private _onUnBindObservable;
  20637. /**
  20638. * Called during a dispose event
  20639. */
  20640. onDispose: () => void;
  20641. private _onBindObservable;
  20642. /**
  20643. * An event triggered when the material is bound
  20644. */
  20645. readonly onBindObservable: Observable<AbstractMesh>;
  20646. /**
  20647. * An observer which watches for bind events
  20648. */
  20649. private _onBindObserver;
  20650. /**
  20651. * Called during a bind event
  20652. */
  20653. onBind: (Mesh: AbstractMesh) => void;
  20654. /**
  20655. * An event triggered when the material is unbound
  20656. */
  20657. readonly onUnBindObservable: Observable<Material>;
  20658. /**
  20659. * Stores the value of the alpha mode
  20660. */
  20661. private _alphaMode;
  20662. /**
  20663. * Sets the value of the alpha mode.
  20664. *
  20665. * | Value | Type | Description |
  20666. * | --- | --- | --- |
  20667. * | 0 | ALPHA_DISABLE | |
  20668. * | 1 | ALPHA_ADD | |
  20669. * | 2 | ALPHA_COMBINE | |
  20670. * | 3 | ALPHA_SUBTRACT | |
  20671. * | 4 | ALPHA_MULTIPLY | |
  20672. * | 5 | ALPHA_MAXIMIZED | |
  20673. * | 6 | ALPHA_ONEONE | |
  20674. * | 7 | ALPHA_PREMULTIPLIED | |
  20675. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20676. * | 9 | ALPHA_INTERPOLATE | |
  20677. * | 10 | ALPHA_SCREENMODE | |
  20678. *
  20679. */
  20680. /**
  20681. * Gets the value of the alpha mode
  20682. */
  20683. alphaMode: number;
  20684. /**
  20685. * Stores the state of the need depth pre-pass value
  20686. */
  20687. private _needDepthPrePass;
  20688. /**
  20689. * Sets the need depth pre-pass value
  20690. */
  20691. /**
  20692. * Gets the depth pre-pass value
  20693. */
  20694. needDepthPrePass: boolean;
  20695. /**
  20696. * Specifies if depth writing should be disabled
  20697. */
  20698. disableDepthWrite: boolean;
  20699. /**
  20700. * Specifies if depth writing should be forced
  20701. */
  20702. forceDepthWrite: boolean;
  20703. /**
  20704. * Specifies if there should be a separate pass for culling
  20705. */
  20706. separateCullingPass: boolean;
  20707. /**
  20708. * Stores the state specifing if fog should be enabled
  20709. */
  20710. private _fogEnabled;
  20711. /**
  20712. * Sets the state for enabling fog
  20713. */
  20714. /**
  20715. * Gets the value of the fog enabled state
  20716. */
  20717. fogEnabled: boolean;
  20718. /**
  20719. * Stores the size of points
  20720. */
  20721. pointSize: number;
  20722. /**
  20723. * Stores the z offset value
  20724. */
  20725. zOffset: number;
  20726. /**
  20727. * Gets a value specifying if wireframe mode is enabled
  20728. */
  20729. /**
  20730. * Sets the state of wireframe mode
  20731. */
  20732. wireframe: boolean;
  20733. /**
  20734. * Gets the value specifying if point clouds are enabled
  20735. */
  20736. /**
  20737. * Sets the state of point cloud mode
  20738. */
  20739. pointsCloud: boolean;
  20740. /**
  20741. * Gets the material fill mode
  20742. */
  20743. /**
  20744. * Sets the material fill mode
  20745. */
  20746. fillMode: number;
  20747. /**
  20748. * @hidden
  20749. * Stores the effects for the material
  20750. */
  20751. _effect: Nullable<Effect>;
  20752. /**
  20753. * @hidden
  20754. * Specifies if the material was previously ready
  20755. */
  20756. _wasPreviouslyReady: boolean;
  20757. /**
  20758. * Specifies if uniform buffers should be used
  20759. */
  20760. private _useUBO;
  20761. /**
  20762. * Stores a reference to the scene
  20763. */
  20764. private _scene;
  20765. /**
  20766. * Stores the fill mode state
  20767. */
  20768. private _fillMode;
  20769. /**
  20770. * Specifies if the depth write state should be cached
  20771. */
  20772. private _cachedDepthWriteState;
  20773. /**
  20774. * Stores the uniform buffer
  20775. */
  20776. protected _uniformBuffer: UniformBuffer;
  20777. /** @hidden */
  20778. _indexInSceneMaterialArray: number;
  20779. /** @hidden */
  20780. meshMap: Nullable<{
  20781. [id: string]: AbstractMesh | undefined;
  20782. }>;
  20783. /**
  20784. * Creates a material instance
  20785. * @param name defines the name of the material
  20786. * @param scene defines the scene to reference
  20787. * @param doNotAdd specifies if the material should be added to the scene
  20788. */
  20789. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20790. /**
  20791. * Returns a string representation of the current material
  20792. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20793. * @returns a string with material information
  20794. */
  20795. toString(fullDetails?: boolean): string;
  20796. /**
  20797. * Gets the class name of the material
  20798. * @returns a string with the class name of the material
  20799. */
  20800. getClassName(): string;
  20801. /**
  20802. * Specifies if updates for the material been locked
  20803. */
  20804. readonly isFrozen: boolean;
  20805. /**
  20806. * Locks updates for the material
  20807. */
  20808. freeze(): void;
  20809. /**
  20810. * Unlocks updates for the material
  20811. */
  20812. unfreeze(): void;
  20813. /**
  20814. * Specifies if the material is ready to be used
  20815. * @param mesh defines the mesh to check
  20816. * @param useInstances specifies if instances should be used
  20817. * @returns a boolean indicating if the material is ready to be used
  20818. */
  20819. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20820. /**
  20821. * Specifies that the submesh is ready to be used
  20822. * @param mesh defines the mesh to check
  20823. * @param subMesh defines which submesh to check
  20824. * @param useInstances specifies that instances should be used
  20825. * @returns a boolean indicating that the submesh is ready or not
  20826. */
  20827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20828. /**
  20829. * Returns the material effect
  20830. * @returns the effect associated with the material
  20831. */
  20832. getEffect(): Nullable<Effect>;
  20833. /**
  20834. * Returns the current scene
  20835. * @returns a Scene
  20836. */
  20837. getScene(): Scene;
  20838. /**
  20839. * Specifies if the material will require alpha blending
  20840. * @returns a boolean specifying if alpha blending is needed
  20841. */
  20842. needAlphaBlending(): boolean;
  20843. /**
  20844. * Specifies if the mesh will require alpha blending
  20845. * @param mesh defines the mesh to check
  20846. * @returns a boolean specifying if alpha blending is needed for the mesh
  20847. */
  20848. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20849. /**
  20850. * Specifies if this material should be rendered in alpha test mode
  20851. * @returns a boolean specifying if an alpha test is needed.
  20852. */
  20853. needAlphaTesting(): boolean;
  20854. /**
  20855. * Gets the texture used for the alpha test
  20856. * @returns the texture to use for alpha testing
  20857. */
  20858. getAlphaTestTexture(): Nullable<BaseTexture>;
  20859. /**
  20860. * Marks the material to indicate that it needs to be re-calculated
  20861. */
  20862. markDirty(): void;
  20863. /** @hidden */
  20864. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20865. /**
  20866. * Binds the material to the mesh
  20867. * @param world defines the world transformation matrix
  20868. * @param mesh defines the mesh to bind the material to
  20869. */
  20870. bind(world: Matrix, mesh?: Mesh): void;
  20871. /**
  20872. * Binds the submesh to the material
  20873. * @param world defines the world transformation matrix
  20874. * @param mesh defines the mesh containing the submesh
  20875. * @param subMesh defines the submesh to bind the material to
  20876. */
  20877. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20878. /**
  20879. * Binds the world matrix to the material
  20880. * @param world defines the world transformation matrix
  20881. */
  20882. bindOnlyWorldMatrix(world: Matrix): void;
  20883. /**
  20884. * Binds the scene's uniform buffer to the effect.
  20885. * @param effect defines the effect to bind to the scene uniform buffer
  20886. * @param sceneUbo defines the uniform buffer storing scene data
  20887. */
  20888. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20889. /**
  20890. * Binds the view matrix to the effect
  20891. * @param effect defines the effect to bind the view matrix to
  20892. */
  20893. bindView(effect: Effect): void;
  20894. /**
  20895. * Binds the view projection matrix to the effect
  20896. * @param effect defines the effect to bind the view projection matrix to
  20897. */
  20898. bindViewProjection(effect: Effect): void;
  20899. /**
  20900. * Specifies if material alpha testing should be turned on for the mesh
  20901. * @param mesh defines the mesh to check
  20902. */
  20903. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20904. /**
  20905. * Processes to execute after binding the material to a mesh
  20906. * @param mesh defines the rendered mesh
  20907. */
  20908. protected _afterBind(mesh?: Mesh): void;
  20909. /**
  20910. * Unbinds the material from the mesh
  20911. */
  20912. unbind(): void;
  20913. /**
  20914. * Gets the active textures from the material
  20915. * @returns an array of textures
  20916. */
  20917. getActiveTextures(): BaseTexture[];
  20918. /**
  20919. * Specifies if the material uses a texture
  20920. * @param texture defines the texture to check against the material
  20921. * @returns a boolean specifying if the material uses the texture
  20922. */
  20923. hasTexture(texture: BaseTexture): boolean;
  20924. /**
  20925. * Makes a duplicate of the material, and gives it a new name
  20926. * @param name defines the new name for the duplicated material
  20927. * @returns the cloned material
  20928. */
  20929. clone(name: string): Nullable<Material>;
  20930. /**
  20931. * Gets the meshes bound to the material
  20932. * @returns an array of meshes bound to the material
  20933. */
  20934. getBindedMeshes(): AbstractMesh[];
  20935. /**
  20936. * Force shader compilation
  20937. * @param mesh defines the mesh associated with this material
  20938. * @param onCompiled defines a function to execute once the material is compiled
  20939. * @param options defines the options to configure the compilation
  20940. */
  20941. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20942. clipPlane: boolean;
  20943. }>): void;
  20944. /**
  20945. * Force shader compilation
  20946. * @param mesh defines the mesh that will use this material
  20947. * @param options defines additional options for compiling the shaders
  20948. * @returns a promise that resolves when the compilation completes
  20949. */
  20950. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20951. clipPlane: boolean;
  20952. }>): Promise<void>;
  20953. private static readonly _AllDirtyCallBack;
  20954. private static readonly _ImageProcessingDirtyCallBack;
  20955. private static readonly _TextureDirtyCallBack;
  20956. private static readonly _FresnelDirtyCallBack;
  20957. private static readonly _MiscDirtyCallBack;
  20958. private static readonly _LightsDirtyCallBack;
  20959. private static readonly _AttributeDirtyCallBack;
  20960. private static _FresnelAndMiscDirtyCallBack;
  20961. private static _TextureAndMiscDirtyCallBack;
  20962. private static readonly _DirtyCallbackArray;
  20963. private static readonly _RunDirtyCallBacks;
  20964. /**
  20965. * Marks a define in the material to indicate that it needs to be re-computed
  20966. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20967. */
  20968. markAsDirty(flag: number): void;
  20969. /**
  20970. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20971. * @param func defines a function which checks material defines against the submeshes
  20972. */
  20973. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20974. /**
  20975. * Indicates that we need to re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsAllDirty(): void;
  20978. /**
  20979. * Indicates that image processing needs to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20982. /**
  20983. * Indicates that textures need to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsTexturesDirty(): void;
  20986. /**
  20987. * Indicates that fresnel needs to be re-calculated for all submeshes
  20988. */
  20989. protected _markAllSubMeshesAsFresnelDirty(): void;
  20990. /**
  20991. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20992. */
  20993. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20994. /**
  20995. * Indicates that lights need to be re-calculated for all submeshes
  20996. */
  20997. protected _markAllSubMeshesAsLightsDirty(): void;
  20998. /**
  20999. * Indicates that attributes need to be re-calculated for all submeshes
  21000. */
  21001. protected _markAllSubMeshesAsAttributesDirty(): void;
  21002. /**
  21003. * Indicates that misc needs to be re-calculated for all submeshes
  21004. */
  21005. protected _markAllSubMeshesAsMiscDirty(): void;
  21006. /**
  21007. * Indicates that textures and misc need to be re-calculated for all submeshes
  21008. */
  21009. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21010. /**
  21011. * Disposes the material
  21012. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21013. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21014. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21015. */
  21016. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21017. /** @hidden */
  21018. private releaseVertexArrayObject;
  21019. /**
  21020. * Serializes this material
  21021. * @returns the serialized material object
  21022. */
  21023. serialize(): any;
  21024. /**
  21025. * Creates a material from parsed material data
  21026. * @param parsedMaterial defines parsed material data
  21027. * @param scene defines the hosting scene
  21028. * @param rootUrl defines the root URL to use to load textures
  21029. * @returns a new material
  21030. */
  21031. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21032. }
  21033. }
  21034. declare module "babylonjs/Materials/multiMaterial" {
  21035. import { Nullable } from "babylonjs/types";
  21036. import { Scene } from "babylonjs/scene";
  21037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21038. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21040. import { Material } from "babylonjs/Materials/material";
  21041. /**
  21042. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21043. * separate meshes. This can be use to improve performances.
  21044. * @see http://doc.babylonjs.com/how_to/multi_materials
  21045. */
  21046. export class MultiMaterial extends Material {
  21047. private _subMaterials;
  21048. /**
  21049. * Gets or Sets the list of Materials used within the multi material.
  21050. * They need to be ordered according to the submeshes order in the associated mesh
  21051. */
  21052. subMaterials: Nullable<Material>[];
  21053. /**
  21054. * Function used to align with Node.getChildren()
  21055. * @returns the list of Materials used within the multi material
  21056. */
  21057. getChildren(): Nullable<Material>[];
  21058. /**
  21059. * Instantiates a new Multi Material
  21060. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21061. * separate meshes. This can be use to improve performances.
  21062. * @see http://doc.babylonjs.com/how_to/multi_materials
  21063. * @param name Define the name in the scene
  21064. * @param scene Define the scene the material belongs to
  21065. */
  21066. constructor(name: string, scene: Scene);
  21067. private _hookArray;
  21068. /**
  21069. * Get one of the submaterial by its index in the submaterials array
  21070. * @param index The index to look the sub material at
  21071. * @returns The Material if the index has been defined
  21072. */
  21073. getSubMaterial(index: number): Nullable<Material>;
  21074. /**
  21075. * Get the list of active textures for the whole sub materials list.
  21076. * @returns All the textures that will be used during the rendering
  21077. */
  21078. getActiveTextures(): BaseTexture[];
  21079. /**
  21080. * Gets the current class name of the material e.g. "MultiMaterial"
  21081. * Mainly use in serialization.
  21082. * @returns the class name
  21083. */
  21084. getClassName(): string;
  21085. /**
  21086. * Checks if the material is ready to render the requested sub mesh
  21087. * @param mesh Define the mesh the submesh belongs to
  21088. * @param subMesh Define the sub mesh to look readyness for
  21089. * @param useInstances Define whether or not the material is used with instances
  21090. * @returns true if ready, otherwise false
  21091. */
  21092. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21093. /**
  21094. * Clones the current material and its related sub materials
  21095. * @param name Define the name of the newly cloned material
  21096. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21097. * @returns the cloned material
  21098. */
  21099. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21100. /**
  21101. * Serializes the materials into a JSON representation.
  21102. * @returns the JSON representation
  21103. */
  21104. serialize(): any;
  21105. /**
  21106. * Dispose the material and release its associated resources
  21107. * @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)
  21108. * @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)
  21109. * @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)
  21110. */
  21111. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21112. /**
  21113. * Creates a MultiMaterial from parsed MultiMaterial data.
  21114. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21115. * @param scene defines the hosting scene
  21116. * @returns a new MultiMaterial
  21117. */
  21118. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21119. }
  21120. }
  21121. declare module "babylonjs/Meshes/subMesh" {
  21122. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21123. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21124. import { Engine } from "babylonjs/Engines/engine";
  21125. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21126. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21127. import { Effect } from "babylonjs/Materials/effect";
  21128. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21129. import { Plane } from "babylonjs/Maths/math.plane";
  21130. import { Collider } from "babylonjs/Collisions/collider";
  21131. import { Material } from "babylonjs/Materials/material";
  21132. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21134. import { Mesh } from "babylonjs/Meshes/mesh";
  21135. import { Ray } from "babylonjs/Culling/ray";
  21136. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21137. /**
  21138. * Base class for submeshes
  21139. */
  21140. export class BaseSubMesh {
  21141. /** @hidden */
  21142. _materialDefines: Nullable<MaterialDefines>;
  21143. /** @hidden */
  21144. _materialEffect: Nullable<Effect>;
  21145. /**
  21146. * Gets associated effect
  21147. */
  21148. readonly effect: Nullable<Effect>;
  21149. /**
  21150. * Sets associated effect (effect used to render this submesh)
  21151. * @param effect defines the effect to associate with
  21152. * @param defines defines the set of defines used to compile this effect
  21153. */
  21154. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21155. }
  21156. /**
  21157. * Defines a subdivision inside a mesh
  21158. */
  21159. export class SubMesh extends BaseSubMesh implements ICullable {
  21160. /** the material index to use */
  21161. materialIndex: number;
  21162. /** vertex index start */
  21163. verticesStart: number;
  21164. /** vertices count */
  21165. verticesCount: number;
  21166. /** index start */
  21167. indexStart: number;
  21168. /** indices count */
  21169. indexCount: number;
  21170. /** @hidden */
  21171. _linesIndexCount: number;
  21172. private _mesh;
  21173. private _renderingMesh;
  21174. private _boundingInfo;
  21175. private _linesIndexBuffer;
  21176. /** @hidden */
  21177. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21178. /** @hidden */
  21179. _trianglePlanes: Plane[];
  21180. /** @hidden */
  21181. _lastColliderTransformMatrix: Nullable<Matrix>;
  21182. /** @hidden */
  21183. _renderId: number;
  21184. /** @hidden */
  21185. _alphaIndex: number;
  21186. /** @hidden */
  21187. _distanceToCamera: number;
  21188. /** @hidden */
  21189. _id: number;
  21190. private _currentMaterial;
  21191. /**
  21192. * Add a new submesh to a mesh
  21193. * @param materialIndex defines the material index to use
  21194. * @param verticesStart defines vertex index start
  21195. * @param verticesCount defines vertices count
  21196. * @param indexStart defines index start
  21197. * @param indexCount defines indices count
  21198. * @param mesh defines the parent mesh
  21199. * @param renderingMesh defines an optional rendering mesh
  21200. * @param createBoundingBox defines if bounding box should be created for this submesh
  21201. * @returns the new submesh
  21202. */
  21203. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21204. /**
  21205. * Creates a new submesh
  21206. * @param materialIndex defines the material index to use
  21207. * @param verticesStart defines vertex index start
  21208. * @param verticesCount defines vertices count
  21209. * @param indexStart defines index start
  21210. * @param indexCount defines indices count
  21211. * @param mesh defines the parent mesh
  21212. * @param renderingMesh defines an optional rendering mesh
  21213. * @param createBoundingBox defines if bounding box should be created for this submesh
  21214. */
  21215. constructor(
  21216. /** the material index to use */
  21217. materialIndex: number,
  21218. /** vertex index start */
  21219. verticesStart: number,
  21220. /** vertices count */
  21221. verticesCount: number,
  21222. /** index start */
  21223. indexStart: number,
  21224. /** indices count */
  21225. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21226. /**
  21227. * Returns true if this submesh covers the entire parent mesh
  21228. * @ignorenaming
  21229. */
  21230. readonly IsGlobal: boolean;
  21231. /**
  21232. * Returns the submesh BoudingInfo object
  21233. * @returns current bounding info (or mesh's one if the submesh is global)
  21234. */
  21235. getBoundingInfo(): BoundingInfo;
  21236. /**
  21237. * Sets the submesh BoundingInfo
  21238. * @param boundingInfo defines the new bounding info to use
  21239. * @returns the SubMesh
  21240. */
  21241. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21242. /**
  21243. * Returns the mesh of the current submesh
  21244. * @return the parent mesh
  21245. */
  21246. getMesh(): AbstractMesh;
  21247. /**
  21248. * Returns the rendering mesh of the submesh
  21249. * @returns the rendering mesh (could be different from parent mesh)
  21250. */
  21251. getRenderingMesh(): Mesh;
  21252. /**
  21253. * Returns the submesh material
  21254. * @returns null or the current material
  21255. */
  21256. getMaterial(): Nullable<Material>;
  21257. /**
  21258. * Sets a new updated BoundingInfo object to the submesh
  21259. * @param data defines an optional position array to use to determine the bounding info
  21260. * @returns the SubMesh
  21261. */
  21262. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21263. /** @hidden */
  21264. _checkCollision(collider: Collider): boolean;
  21265. /**
  21266. * Updates the submesh BoundingInfo
  21267. * @param world defines the world matrix to use to update the bounding info
  21268. * @returns the submesh
  21269. */
  21270. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21271. /**
  21272. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21273. * @param frustumPlanes defines the frustum planes
  21274. * @returns true if the submesh is intersecting with the frustum
  21275. */
  21276. isInFrustum(frustumPlanes: Plane[]): boolean;
  21277. /**
  21278. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21279. * @param frustumPlanes defines the frustum planes
  21280. * @returns true if the submesh is inside the frustum
  21281. */
  21282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21283. /**
  21284. * Renders the submesh
  21285. * @param enableAlphaMode defines if alpha needs to be used
  21286. * @returns the submesh
  21287. */
  21288. render(enableAlphaMode: boolean): SubMesh;
  21289. /**
  21290. * @hidden
  21291. */
  21292. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21293. /**
  21294. * Checks if the submesh intersects with a ray
  21295. * @param ray defines the ray to test
  21296. * @returns true is the passed ray intersects the submesh bounding box
  21297. */
  21298. canIntersects(ray: Ray): boolean;
  21299. /**
  21300. * Intersects current submesh with a ray
  21301. * @param ray defines the ray to test
  21302. * @param positions defines mesh's positions array
  21303. * @param indices defines mesh's indices array
  21304. * @param fastCheck defines if only bounding info should be used
  21305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21306. * @returns intersection info or null if no intersection
  21307. */
  21308. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21309. /** @hidden */
  21310. private _intersectLines;
  21311. /** @hidden */
  21312. private _intersectUnIndexedLines;
  21313. /** @hidden */
  21314. private _intersectTriangles;
  21315. /** @hidden */
  21316. private _intersectUnIndexedTriangles;
  21317. /** @hidden */
  21318. _rebuild(): void;
  21319. /**
  21320. * Creates a new submesh from the passed mesh
  21321. * @param newMesh defines the new hosting mesh
  21322. * @param newRenderingMesh defines an optional rendering mesh
  21323. * @returns the new submesh
  21324. */
  21325. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21326. /**
  21327. * Release associated resources
  21328. */
  21329. dispose(): void;
  21330. /**
  21331. * Gets the class name
  21332. * @returns the string "SubMesh".
  21333. */
  21334. getClassName(): string;
  21335. /**
  21336. * Creates a new submesh from indices data
  21337. * @param materialIndex the index of the main mesh material
  21338. * @param startIndex the index where to start the copy in the mesh indices array
  21339. * @param indexCount the number of indices to copy then from the startIndex
  21340. * @param mesh the main mesh to create the submesh from
  21341. * @param renderingMesh the optional rendering mesh
  21342. * @returns a new submesh
  21343. */
  21344. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21345. }
  21346. }
  21347. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21348. /**
  21349. * Class used to represent data loading progression
  21350. */
  21351. export class SceneLoaderFlags {
  21352. private static _ForceFullSceneLoadingForIncremental;
  21353. private static _ShowLoadingScreen;
  21354. private static _CleanBoneMatrixWeights;
  21355. private static _loggingLevel;
  21356. /**
  21357. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21358. */
  21359. static ForceFullSceneLoadingForIncremental: boolean;
  21360. /**
  21361. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21362. */
  21363. static ShowLoadingScreen: boolean;
  21364. /**
  21365. * Defines the current logging level (while loading the scene)
  21366. * @ignorenaming
  21367. */
  21368. static loggingLevel: number;
  21369. /**
  21370. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21371. */
  21372. static CleanBoneMatrixWeights: boolean;
  21373. }
  21374. }
  21375. declare module "babylonjs/Meshes/geometry" {
  21376. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21377. import { Scene } from "babylonjs/scene";
  21378. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21379. import { Engine } from "babylonjs/Engines/engine";
  21380. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21382. import { Effect } from "babylonjs/Materials/effect";
  21383. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21385. import { Mesh } from "babylonjs/Meshes/mesh";
  21386. /**
  21387. * Class used to store geometry data (vertex buffers + index buffer)
  21388. */
  21389. export class Geometry implements IGetSetVerticesData {
  21390. /**
  21391. * Gets or sets the ID of the geometry
  21392. */
  21393. id: string;
  21394. /**
  21395. * Gets or sets the unique ID of the geometry
  21396. */
  21397. uniqueId: number;
  21398. /**
  21399. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21400. */
  21401. delayLoadState: number;
  21402. /**
  21403. * Gets the file containing the data to load when running in delay load state
  21404. */
  21405. delayLoadingFile: Nullable<string>;
  21406. /**
  21407. * Callback called when the geometry is updated
  21408. */
  21409. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21410. private _scene;
  21411. private _engine;
  21412. private _meshes;
  21413. private _totalVertices;
  21414. /** @hidden */
  21415. _indices: IndicesArray;
  21416. /** @hidden */
  21417. _vertexBuffers: {
  21418. [key: string]: VertexBuffer;
  21419. };
  21420. private _isDisposed;
  21421. private _extend;
  21422. private _boundingBias;
  21423. /** @hidden */
  21424. _delayInfo: Array<string>;
  21425. private _indexBuffer;
  21426. private _indexBufferIsUpdatable;
  21427. /** @hidden */
  21428. _boundingInfo: Nullable<BoundingInfo>;
  21429. /** @hidden */
  21430. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21431. /** @hidden */
  21432. _softwareSkinningFrameId: number;
  21433. private _vertexArrayObjects;
  21434. private _updatable;
  21435. /** @hidden */
  21436. _positions: Nullable<Vector3[]>;
  21437. /**
  21438. * 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
  21439. */
  21440. /**
  21441. * 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
  21442. */
  21443. boundingBias: Vector2;
  21444. /**
  21445. * Static function used to attach a new empty geometry to a mesh
  21446. * @param mesh defines the mesh to attach the geometry to
  21447. * @returns the new Geometry
  21448. */
  21449. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21450. /**
  21451. * Creates a new geometry
  21452. * @param id defines the unique ID
  21453. * @param scene defines the hosting scene
  21454. * @param vertexData defines the VertexData used to get geometry data
  21455. * @param updatable defines if geometry must be updatable (false by default)
  21456. * @param mesh defines the mesh that will be associated with the geometry
  21457. */
  21458. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21459. /**
  21460. * Gets the current extend of the geometry
  21461. */
  21462. readonly extend: {
  21463. minimum: Vector3;
  21464. maximum: Vector3;
  21465. };
  21466. /**
  21467. * Gets the hosting scene
  21468. * @returns the hosting Scene
  21469. */
  21470. getScene(): Scene;
  21471. /**
  21472. * Gets the hosting engine
  21473. * @returns the hosting Engine
  21474. */
  21475. getEngine(): Engine;
  21476. /**
  21477. * Defines if the geometry is ready to use
  21478. * @returns true if the geometry is ready to be used
  21479. */
  21480. isReady(): boolean;
  21481. /**
  21482. * Gets a value indicating that the geometry should not be serialized
  21483. */
  21484. readonly doNotSerialize: boolean;
  21485. /** @hidden */
  21486. _rebuild(): void;
  21487. /**
  21488. * Affects all geometry data in one call
  21489. * @param vertexData defines the geometry data
  21490. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21491. */
  21492. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21493. /**
  21494. * Set specific vertex data
  21495. * @param kind defines the data kind (Position, normal, etc...)
  21496. * @param data defines the vertex data to use
  21497. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21498. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21499. */
  21500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21501. /**
  21502. * Removes a specific vertex data
  21503. * @param kind defines the data kind (Position, normal, etc...)
  21504. */
  21505. removeVerticesData(kind: string): void;
  21506. /**
  21507. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21508. * @param buffer defines the vertex buffer to use
  21509. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21510. */
  21511. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21512. /**
  21513. * Update a specific vertex buffer
  21514. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21515. * It will do nothing if the buffer is not updatable
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @param data defines the data to use
  21518. * @param offset defines the offset in the target buffer where to store the data
  21519. * @param useBytes set to true if the offset is in bytes
  21520. */
  21521. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21522. /**
  21523. * Update a specific vertex buffer
  21524. * This function will create a new buffer if the current one is not updatable
  21525. * @param kind defines the data kind (Position, normal, etc...)
  21526. * @param data defines the data to use
  21527. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21528. */
  21529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21530. private _updateBoundingInfo;
  21531. /** @hidden */
  21532. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21533. /**
  21534. * Gets total number of vertices
  21535. * @returns the total number of vertices
  21536. */
  21537. getTotalVertices(): number;
  21538. /**
  21539. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21540. * @param kind defines the data kind (Position, normal, etc...)
  21541. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21542. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21543. * @returns a float array containing vertex data
  21544. */
  21545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21546. /**
  21547. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21548. * @param kind defines the data kind (Position, normal, etc...)
  21549. * @returns true if the vertex buffer with the specified kind is updatable
  21550. */
  21551. isVertexBufferUpdatable(kind: string): boolean;
  21552. /**
  21553. * Gets a specific vertex buffer
  21554. * @param kind defines the data kind (Position, normal, etc...)
  21555. * @returns a VertexBuffer
  21556. */
  21557. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21558. /**
  21559. * Returns all vertex buffers
  21560. * @return an object holding all vertex buffers indexed by kind
  21561. */
  21562. getVertexBuffers(): Nullable<{
  21563. [key: string]: VertexBuffer;
  21564. }>;
  21565. /**
  21566. * Gets a boolean indicating if specific vertex buffer is present
  21567. * @param kind defines the data kind (Position, normal, etc...)
  21568. * @returns true if data is present
  21569. */
  21570. isVerticesDataPresent(kind: string): boolean;
  21571. /**
  21572. * Gets a list of all attached data kinds (Position, normal, etc...)
  21573. * @returns a list of string containing all kinds
  21574. */
  21575. getVerticesDataKinds(): string[];
  21576. /**
  21577. * Update index buffer
  21578. * @param indices defines the indices to store in the index buffer
  21579. * @param offset defines the offset in the target buffer where to store the data
  21580. * @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)
  21581. */
  21582. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21583. /**
  21584. * Creates a new index buffer
  21585. * @param indices defines the indices to store in the index buffer
  21586. * @param totalVertices defines the total number of vertices (could be null)
  21587. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21588. */
  21589. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21590. /**
  21591. * Return the total number of indices
  21592. * @returns the total number of indices
  21593. */
  21594. getTotalIndices(): number;
  21595. /**
  21596. * Gets the index buffer array
  21597. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21599. * @returns the index buffer array
  21600. */
  21601. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21602. /**
  21603. * Gets the index buffer
  21604. * @return the index buffer
  21605. */
  21606. getIndexBuffer(): Nullable<DataBuffer>;
  21607. /** @hidden */
  21608. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21609. /**
  21610. * Release the associated resources for a specific mesh
  21611. * @param mesh defines the source mesh
  21612. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21613. */
  21614. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21615. /**
  21616. * Apply current geometry to a given mesh
  21617. * @param mesh defines the mesh to apply geometry to
  21618. */
  21619. applyToMesh(mesh: Mesh): void;
  21620. private _updateExtend;
  21621. private _applyToMesh;
  21622. private notifyUpdate;
  21623. /**
  21624. * Load the geometry if it was flagged as delay loaded
  21625. * @param scene defines the hosting scene
  21626. * @param onLoaded defines a callback called when the geometry is loaded
  21627. */
  21628. load(scene: Scene, onLoaded?: () => void): void;
  21629. private _queueLoad;
  21630. /**
  21631. * Invert the geometry to move from a right handed system to a left handed one.
  21632. */
  21633. toLeftHanded(): void;
  21634. /** @hidden */
  21635. _resetPointsArrayCache(): void;
  21636. /** @hidden */
  21637. _generatePointsArray(): boolean;
  21638. /**
  21639. * Gets a value indicating if the geometry is disposed
  21640. * @returns true if the geometry was disposed
  21641. */
  21642. isDisposed(): boolean;
  21643. private _disposeVertexArrayObjects;
  21644. /**
  21645. * Free all associated resources
  21646. */
  21647. dispose(): void;
  21648. /**
  21649. * Clone the current geometry into a new geometry
  21650. * @param id defines the unique ID of the new geometry
  21651. * @returns a new geometry object
  21652. */
  21653. copy(id: string): Geometry;
  21654. /**
  21655. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21656. * @return a JSON representation of the current geometry data (without the vertices data)
  21657. */
  21658. serialize(): any;
  21659. private toNumberArray;
  21660. /**
  21661. * Serialize all vertices data into a JSON oject
  21662. * @returns a JSON representation of the current geometry data
  21663. */
  21664. serializeVerticeData(): any;
  21665. /**
  21666. * Extracts a clone of a mesh geometry
  21667. * @param mesh defines the source mesh
  21668. * @param id defines the unique ID of the new geometry object
  21669. * @returns the new geometry object
  21670. */
  21671. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21672. /**
  21673. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21674. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21675. * Be aware Math.random() could cause collisions, but:
  21676. * "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"
  21677. * @returns a string containing a new GUID
  21678. */
  21679. static RandomId(): string;
  21680. /** @hidden */
  21681. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21682. private static _CleanMatricesWeights;
  21683. /**
  21684. * Create a new geometry from persisted data (Using .babylon file format)
  21685. * @param parsedVertexData defines the persisted data
  21686. * @param scene defines the hosting scene
  21687. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21688. * @returns the new geometry object
  21689. */
  21690. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21691. }
  21692. }
  21693. declare module "babylonjs/Meshes/mesh.vertexData" {
  21694. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21695. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21696. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21697. import { Geometry } from "babylonjs/Meshes/geometry";
  21698. import { Mesh } from "babylonjs/Meshes/mesh";
  21699. /**
  21700. * Define an interface for all classes that will get and set the data on vertices
  21701. */
  21702. export interface IGetSetVerticesData {
  21703. /**
  21704. * Gets a boolean indicating if specific vertex data is present
  21705. * @param kind defines the vertex data kind to use
  21706. * @returns true is data kind is present
  21707. */
  21708. isVerticesDataPresent(kind: string): boolean;
  21709. /**
  21710. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21711. * @param kind defines the data kind (Position, normal, etc...)
  21712. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21714. * @returns a float array containing vertex data
  21715. */
  21716. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21717. /**
  21718. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21719. * @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.
  21720. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21721. * @returns the indices array or an empty array if the mesh has no geometry
  21722. */
  21723. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21724. /**
  21725. * Set specific vertex data
  21726. * @param kind defines the data kind (Position, normal, etc...)
  21727. * @param data defines the vertex data to use
  21728. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21729. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21730. */
  21731. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21732. /**
  21733. * Update a specific associated vertex buffer
  21734. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21735. * - VertexBuffer.PositionKind
  21736. * - VertexBuffer.UVKind
  21737. * - VertexBuffer.UV2Kind
  21738. * - VertexBuffer.UV3Kind
  21739. * - VertexBuffer.UV4Kind
  21740. * - VertexBuffer.UV5Kind
  21741. * - VertexBuffer.UV6Kind
  21742. * - VertexBuffer.ColorKind
  21743. * - VertexBuffer.MatricesIndicesKind
  21744. * - VertexBuffer.MatricesIndicesExtraKind
  21745. * - VertexBuffer.MatricesWeightsKind
  21746. * - VertexBuffer.MatricesWeightsExtraKind
  21747. * @param data defines the data source
  21748. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21749. * @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)
  21750. */
  21751. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21752. /**
  21753. * Creates a new index buffer
  21754. * @param indices defines the indices to store in the index buffer
  21755. * @param totalVertices defines the total number of vertices (could be null)
  21756. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21757. */
  21758. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21759. }
  21760. /**
  21761. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21762. */
  21763. export class VertexData {
  21764. /**
  21765. * Mesh side orientation : usually the external or front surface
  21766. */
  21767. static readonly FRONTSIDE: number;
  21768. /**
  21769. * Mesh side orientation : usually the internal or back surface
  21770. */
  21771. static readonly BACKSIDE: number;
  21772. /**
  21773. * Mesh side orientation : both internal and external or front and back surfaces
  21774. */
  21775. static readonly DOUBLESIDE: number;
  21776. /**
  21777. * Mesh side orientation : by default, `FRONTSIDE`
  21778. */
  21779. static readonly DEFAULTSIDE: number;
  21780. /**
  21781. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21782. */
  21783. positions: Nullable<FloatArray>;
  21784. /**
  21785. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21786. */
  21787. normals: Nullable<FloatArray>;
  21788. /**
  21789. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21790. */
  21791. tangents: Nullable<FloatArray>;
  21792. /**
  21793. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21794. */
  21795. uvs: Nullable<FloatArray>;
  21796. /**
  21797. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21798. */
  21799. uvs2: Nullable<FloatArray>;
  21800. /**
  21801. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21802. */
  21803. uvs3: Nullable<FloatArray>;
  21804. /**
  21805. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21806. */
  21807. uvs4: Nullable<FloatArray>;
  21808. /**
  21809. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21810. */
  21811. uvs5: Nullable<FloatArray>;
  21812. /**
  21813. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21814. */
  21815. uvs6: Nullable<FloatArray>;
  21816. /**
  21817. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21818. */
  21819. colors: Nullable<FloatArray>;
  21820. /**
  21821. * 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).
  21822. */
  21823. matricesIndices: Nullable<FloatArray>;
  21824. /**
  21825. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21826. */
  21827. matricesWeights: Nullable<FloatArray>;
  21828. /**
  21829. * An array extending the number of possible indices
  21830. */
  21831. matricesIndicesExtra: Nullable<FloatArray>;
  21832. /**
  21833. * An array extending the number of possible weights when the number of indices is extended
  21834. */
  21835. matricesWeightsExtra: Nullable<FloatArray>;
  21836. /**
  21837. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21838. */
  21839. indices: Nullable<IndicesArray>;
  21840. /**
  21841. * Uses the passed data array to set the set the values for the specified kind of data
  21842. * @param data a linear array of floating numbers
  21843. * @param kind the type of data that is being set, eg positions, colors etc
  21844. */
  21845. set(data: FloatArray, kind: string): void;
  21846. /**
  21847. * Associates the vertexData to the passed Mesh.
  21848. * Sets it as updatable or not (default `false`)
  21849. * @param mesh the mesh the vertexData is applied to
  21850. * @param updatable when used and having the value true allows new data to update the vertexData
  21851. * @returns the VertexData
  21852. */
  21853. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21854. /**
  21855. * Associates the vertexData to the passed Geometry.
  21856. * Sets it as updatable or not (default `false`)
  21857. * @param geometry the geometry the vertexData is applied to
  21858. * @param updatable when used and having the value true allows new data to update the vertexData
  21859. * @returns VertexData
  21860. */
  21861. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21862. /**
  21863. * Updates the associated mesh
  21864. * @param mesh the mesh to be updated
  21865. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21866. * @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
  21867. * @returns VertexData
  21868. */
  21869. updateMesh(mesh: Mesh): VertexData;
  21870. /**
  21871. * Updates the associated geometry
  21872. * @param geometry the geometry to be updated
  21873. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21874. * @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
  21875. * @returns VertexData.
  21876. */
  21877. updateGeometry(geometry: Geometry): VertexData;
  21878. private _applyTo;
  21879. private _update;
  21880. /**
  21881. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21882. * @param matrix the transforming matrix
  21883. * @returns the VertexData
  21884. */
  21885. transform(matrix: Matrix): VertexData;
  21886. /**
  21887. * Merges the passed VertexData into the current one
  21888. * @param other the VertexData to be merged into the current one
  21889. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21890. * @returns the modified VertexData
  21891. */
  21892. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21893. private _mergeElement;
  21894. private _validate;
  21895. /**
  21896. * Serializes the VertexData
  21897. * @returns a serialized object
  21898. */
  21899. serialize(): any;
  21900. /**
  21901. * Extracts the vertexData from a mesh
  21902. * @param mesh the mesh from which to extract the VertexData
  21903. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21905. * @returns the object VertexData associated to the passed mesh
  21906. */
  21907. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21908. /**
  21909. * Extracts the vertexData from the geometry
  21910. * @param geometry the geometry from which to extract the VertexData
  21911. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21912. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21913. * @returns the object VertexData associated to the passed mesh
  21914. */
  21915. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21916. private static _ExtractFrom;
  21917. /**
  21918. * Creates the VertexData for a Ribbon
  21919. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21920. * * pathArray array of paths, each of which an array of successive Vector3
  21921. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21922. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21923. * * 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
  21924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21925. * * 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)
  21926. * * 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)
  21927. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21928. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21929. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21930. * @returns the VertexData of the ribbon
  21931. */
  21932. static CreateRibbon(options: {
  21933. pathArray: Vector3[][];
  21934. closeArray?: boolean;
  21935. closePath?: boolean;
  21936. offset?: number;
  21937. sideOrientation?: number;
  21938. frontUVs?: Vector4;
  21939. backUVs?: Vector4;
  21940. invertUV?: boolean;
  21941. uvs?: Vector2[];
  21942. colors?: Color4[];
  21943. }): VertexData;
  21944. /**
  21945. * Creates the VertexData for a box
  21946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21947. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21948. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21949. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21950. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21951. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21952. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21954. * * 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)
  21955. * * 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)
  21956. * @returns the VertexData of the box
  21957. */
  21958. static CreateBox(options: {
  21959. size?: number;
  21960. width?: number;
  21961. height?: number;
  21962. depth?: number;
  21963. faceUV?: Vector4[];
  21964. faceColors?: Color4[];
  21965. sideOrientation?: number;
  21966. frontUVs?: Vector4;
  21967. backUVs?: Vector4;
  21968. }): VertexData;
  21969. /**
  21970. * Creates the VertexData for a tiled box
  21971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21972. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21973. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21974. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21976. * @returns the VertexData of the box
  21977. */
  21978. static CreateTiledBox(options: {
  21979. pattern?: number;
  21980. width?: number;
  21981. height?: number;
  21982. depth?: number;
  21983. tileSize?: number;
  21984. tileWidth?: number;
  21985. tileHeight?: number;
  21986. alignHorizontal?: number;
  21987. alignVertical?: number;
  21988. faceUV?: Vector4[];
  21989. faceColors?: Color4[];
  21990. sideOrientation?: number;
  21991. }): VertexData;
  21992. /**
  21993. * Creates the VertexData for a tiled plane
  21994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21995. * * pattern a limited pattern arrangement depending on the number
  21996. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21997. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21998. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22000. * * 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)
  22001. * * 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)
  22002. * @returns the VertexData of the tiled plane
  22003. */
  22004. static CreateTiledPlane(options: {
  22005. pattern?: number;
  22006. tileSize?: number;
  22007. tileWidth?: number;
  22008. tileHeight?: number;
  22009. size?: number;
  22010. width?: number;
  22011. height?: number;
  22012. alignHorizontal?: number;
  22013. alignVertical?: number;
  22014. sideOrientation?: number;
  22015. frontUVs?: Vector4;
  22016. backUVs?: Vector4;
  22017. }): VertexData;
  22018. /**
  22019. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22020. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22021. * * segments sets the number of horizontal strips optional, default 32
  22022. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22023. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22024. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22025. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22026. * * 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
  22027. * * 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
  22028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22029. * * 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)
  22030. * * 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)
  22031. * @returns the VertexData of the ellipsoid
  22032. */
  22033. static CreateSphere(options: {
  22034. segments?: number;
  22035. diameter?: number;
  22036. diameterX?: number;
  22037. diameterY?: number;
  22038. diameterZ?: number;
  22039. arc?: number;
  22040. slice?: number;
  22041. sideOrientation?: number;
  22042. frontUVs?: Vector4;
  22043. backUVs?: Vector4;
  22044. }): VertexData;
  22045. /**
  22046. * Creates the VertexData for a cylinder, cone or prism
  22047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22048. * * height sets the height (y direction) of the cylinder, optional, default 2
  22049. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22050. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22051. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22052. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22053. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22054. * * 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
  22055. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22056. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22057. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22058. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22059. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22060. * * 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)
  22061. * * 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)
  22062. * @returns the VertexData of the cylinder, cone or prism
  22063. */
  22064. static CreateCylinder(options: {
  22065. height?: number;
  22066. diameterTop?: number;
  22067. diameterBottom?: number;
  22068. diameter?: number;
  22069. tessellation?: number;
  22070. subdivisions?: number;
  22071. arc?: number;
  22072. faceColors?: Color4[];
  22073. faceUV?: Vector4[];
  22074. hasRings?: boolean;
  22075. enclose?: boolean;
  22076. sideOrientation?: number;
  22077. frontUVs?: Vector4;
  22078. backUVs?: Vector4;
  22079. }): VertexData;
  22080. /**
  22081. * Creates the VertexData for a torus
  22082. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22083. * * diameter the diameter of the torus, optional default 1
  22084. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22085. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22087. * * 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)
  22088. * * 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)
  22089. * @returns the VertexData of the torus
  22090. */
  22091. static CreateTorus(options: {
  22092. diameter?: number;
  22093. thickness?: number;
  22094. tessellation?: number;
  22095. sideOrientation?: number;
  22096. frontUVs?: Vector4;
  22097. backUVs?: Vector4;
  22098. }): VertexData;
  22099. /**
  22100. * Creates the VertexData of the LineSystem
  22101. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22102. * - lines an array of lines, each line being an array of successive Vector3
  22103. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22104. * @returns the VertexData of the LineSystem
  22105. */
  22106. static CreateLineSystem(options: {
  22107. lines: Vector3[][];
  22108. colors?: Nullable<Color4[][]>;
  22109. }): VertexData;
  22110. /**
  22111. * Create the VertexData for a DashedLines
  22112. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22113. * - points an array successive Vector3
  22114. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22115. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22116. * - dashNb the intended total number of dashes, optional, default 200
  22117. * @returns the VertexData for the DashedLines
  22118. */
  22119. static CreateDashedLines(options: {
  22120. points: Vector3[];
  22121. dashSize?: number;
  22122. gapSize?: number;
  22123. dashNb?: number;
  22124. }): VertexData;
  22125. /**
  22126. * Creates the VertexData for a Ground
  22127. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22128. * - width the width (x direction) of the ground, optional, default 1
  22129. * - height the height (z direction) of the ground, optional, default 1
  22130. * - subdivisions the number of subdivisions per side, optional, default 1
  22131. * @returns the VertexData of the Ground
  22132. */
  22133. static CreateGround(options: {
  22134. width?: number;
  22135. height?: number;
  22136. subdivisions?: number;
  22137. subdivisionsX?: number;
  22138. subdivisionsY?: number;
  22139. }): VertexData;
  22140. /**
  22141. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22142. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22143. * * xmin the ground minimum X coordinate, optional, default -1
  22144. * * zmin the ground minimum Z coordinate, optional, default -1
  22145. * * xmax the ground maximum X coordinate, optional, default 1
  22146. * * zmax the ground maximum Z coordinate, optional, default 1
  22147. * * 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}
  22148. * * 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}
  22149. * @returns the VertexData of the TiledGround
  22150. */
  22151. static CreateTiledGround(options: {
  22152. xmin: number;
  22153. zmin: number;
  22154. xmax: number;
  22155. zmax: number;
  22156. subdivisions?: {
  22157. w: number;
  22158. h: number;
  22159. };
  22160. precision?: {
  22161. w: number;
  22162. h: number;
  22163. };
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData of the Ground designed from a heightmap
  22167. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22168. * * width the width (x direction) of the ground
  22169. * * height the height (z direction) of the ground
  22170. * * subdivisions the number of subdivisions per side
  22171. * * minHeight the minimum altitude on the ground, optional, default 0
  22172. * * maxHeight the maximum altitude on the ground, optional default 1
  22173. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22174. * * buffer the array holding the image color data
  22175. * * bufferWidth the width of image
  22176. * * bufferHeight the height of image
  22177. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22178. * @returns the VertexData of the Ground designed from a heightmap
  22179. */
  22180. static CreateGroundFromHeightMap(options: {
  22181. width: number;
  22182. height: number;
  22183. subdivisions: number;
  22184. minHeight: number;
  22185. maxHeight: number;
  22186. colorFilter: Color3;
  22187. buffer: Uint8Array;
  22188. bufferWidth: number;
  22189. bufferHeight: number;
  22190. alphaFilter: number;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a Plane
  22194. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22195. * * size sets the width and height of the plane to the value of size, optional default 1
  22196. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22197. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22199. * * 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)
  22200. * * 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)
  22201. * @returns the VertexData of the box
  22202. */
  22203. static CreatePlane(options: {
  22204. size?: number;
  22205. width?: number;
  22206. height?: number;
  22207. sideOrientation?: number;
  22208. frontUVs?: Vector4;
  22209. backUVs?: Vector4;
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData of the Disc or regular Polygon
  22213. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22214. * * radius the radius of the disc, optional default 0.5
  22215. * * tessellation the number of polygon sides, optional, default 64
  22216. * * 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
  22217. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22218. * * 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)
  22219. * * 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)
  22220. * @returns the VertexData of the box
  22221. */
  22222. static CreateDisc(options: {
  22223. radius?: number;
  22224. tessellation?: number;
  22225. arc?: number;
  22226. sideOrientation?: number;
  22227. frontUVs?: Vector4;
  22228. backUVs?: Vector4;
  22229. }): VertexData;
  22230. /**
  22231. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22232. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22233. * @param polygon a mesh built from polygonTriangulation.build()
  22234. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22235. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22236. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22237. * @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)
  22238. * @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)
  22239. * @returns the VertexData of the Polygon
  22240. */
  22241. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22242. /**
  22243. * Creates the VertexData of the IcoSphere
  22244. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22245. * * radius the radius of the IcoSphere, optional default 1
  22246. * * radiusX allows stretching in the x direction, optional, default radius
  22247. * * radiusY allows stretching in the y direction, optional, default radius
  22248. * * radiusZ allows stretching in the z direction, optional, default radius
  22249. * * flat when true creates a flat shaded mesh, optional, default true
  22250. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22252. * * 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)
  22253. * * 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)
  22254. * @returns the VertexData of the IcoSphere
  22255. */
  22256. static CreateIcoSphere(options: {
  22257. radius?: number;
  22258. radiusX?: number;
  22259. radiusY?: number;
  22260. radiusZ?: number;
  22261. flat?: boolean;
  22262. subdivisions?: number;
  22263. sideOrientation?: number;
  22264. frontUVs?: Vector4;
  22265. backUVs?: Vector4;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData for a Polyhedron
  22269. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22270. * * type provided types are:
  22271. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22272. * * 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)
  22273. * * size the size of the IcoSphere, optional default 1
  22274. * * sizeX allows stretching in the x direction, optional, default size
  22275. * * sizeY allows stretching in the y direction, optional, default size
  22276. * * sizeZ allows stretching in the z direction, optional, default size
  22277. * * 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
  22278. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22279. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22280. * * flat when true creates a flat shaded mesh, optional, default true
  22281. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22283. * * 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)
  22284. * * 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)
  22285. * @returns the VertexData of the Polyhedron
  22286. */
  22287. static CreatePolyhedron(options: {
  22288. type?: number;
  22289. size?: number;
  22290. sizeX?: number;
  22291. sizeY?: number;
  22292. sizeZ?: number;
  22293. custom?: any;
  22294. faceUV?: Vector4[];
  22295. faceColors?: Color4[];
  22296. flat?: boolean;
  22297. sideOrientation?: number;
  22298. frontUVs?: Vector4;
  22299. backUVs?: Vector4;
  22300. }): VertexData;
  22301. /**
  22302. * Creates the VertexData for a TorusKnot
  22303. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22304. * * radius the radius of the torus knot, optional, default 2
  22305. * * tube the thickness of the tube, optional, default 0.5
  22306. * * radialSegments the number of sides on each tube segments, optional, default 32
  22307. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22308. * * p the number of windings around the z axis, optional, default 2
  22309. * * q the number of windings around the x axis, optional, default 3
  22310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22311. * * 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)
  22312. * * 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)
  22313. * @returns the VertexData of the Torus Knot
  22314. */
  22315. static CreateTorusKnot(options: {
  22316. radius?: number;
  22317. tube?: number;
  22318. radialSegments?: number;
  22319. tubularSegments?: number;
  22320. p?: number;
  22321. q?: number;
  22322. sideOrientation?: number;
  22323. frontUVs?: Vector4;
  22324. backUVs?: Vector4;
  22325. }): VertexData;
  22326. /**
  22327. * Compute normals for given positions and indices
  22328. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22329. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22330. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22331. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22332. * * facetNormals : optional array of facet normals (vector3)
  22333. * * facetPositions : optional array of facet positions (vector3)
  22334. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22335. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22336. * * bInfo : optional bounding info, required for facetPartitioning computation
  22337. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22338. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22339. * * useRightHandedSystem: optional boolean to for right handed system computation
  22340. * * depthSort : optional boolean to enable the facet depth sort computation
  22341. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22342. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22343. */
  22344. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22345. facetNormals?: any;
  22346. facetPositions?: any;
  22347. facetPartitioning?: any;
  22348. ratio?: number;
  22349. bInfo?: any;
  22350. bbSize?: Vector3;
  22351. subDiv?: any;
  22352. useRightHandedSystem?: boolean;
  22353. depthSort?: boolean;
  22354. distanceTo?: Vector3;
  22355. depthSortedFacets?: any;
  22356. }): void;
  22357. /** @hidden */
  22358. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22359. /**
  22360. * Applies VertexData created from the imported parameters to the geometry
  22361. * @param parsedVertexData the parsed data from an imported file
  22362. * @param geometry the geometry to apply the VertexData to
  22363. */
  22364. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22365. }
  22366. }
  22367. declare module "babylonjs/Morph/morphTarget" {
  22368. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22369. import { Observable } from "babylonjs/Misc/observable";
  22370. import { Nullable, FloatArray } from "babylonjs/types";
  22371. import { Scene } from "babylonjs/scene";
  22372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22373. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22374. /**
  22375. * Defines a target to use with MorphTargetManager
  22376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22377. */
  22378. export class MorphTarget implements IAnimatable {
  22379. /** defines the name of the target */
  22380. name: string;
  22381. /**
  22382. * Gets or sets the list of animations
  22383. */
  22384. animations: import("babylonjs/Animations/animation").Animation[];
  22385. private _scene;
  22386. private _positions;
  22387. private _normals;
  22388. private _tangents;
  22389. private _uvs;
  22390. private _influence;
  22391. /**
  22392. * Observable raised when the influence changes
  22393. */
  22394. onInfluenceChanged: Observable<boolean>;
  22395. /** @hidden */
  22396. _onDataLayoutChanged: Observable<void>;
  22397. /**
  22398. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22399. */
  22400. influence: number;
  22401. /**
  22402. * Gets or sets the id of the morph Target
  22403. */
  22404. id: string;
  22405. private _animationPropertiesOverride;
  22406. /**
  22407. * Gets or sets the animation properties override
  22408. */
  22409. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22410. /**
  22411. * Creates a new MorphTarget
  22412. * @param name defines the name of the target
  22413. * @param influence defines the influence to use
  22414. * @param scene defines the scene the morphtarget belongs to
  22415. */
  22416. constructor(
  22417. /** defines the name of the target */
  22418. name: string, influence?: number, scene?: Nullable<Scene>);
  22419. /**
  22420. * Gets a boolean defining if the target contains position data
  22421. */
  22422. readonly hasPositions: boolean;
  22423. /**
  22424. * Gets a boolean defining if the target contains normal data
  22425. */
  22426. readonly hasNormals: boolean;
  22427. /**
  22428. * Gets a boolean defining if the target contains tangent data
  22429. */
  22430. readonly hasTangents: boolean;
  22431. /**
  22432. * Gets a boolean defining if the target contains texture coordinates data
  22433. */
  22434. readonly hasUVs: boolean;
  22435. /**
  22436. * Affects position data to this target
  22437. * @param data defines the position data to use
  22438. */
  22439. setPositions(data: Nullable<FloatArray>): void;
  22440. /**
  22441. * Gets the position data stored in this target
  22442. * @returns a FloatArray containing the position data (or null if not present)
  22443. */
  22444. getPositions(): Nullable<FloatArray>;
  22445. /**
  22446. * Affects normal data to this target
  22447. * @param data defines the normal data to use
  22448. */
  22449. setNormals(data: Nullable<FloatArray>): void;
  22450. /**
  22451. * Gets the normal data stored in this target
  22452. * @returns a FloatArray containing the normal data (or null if not present)
  22453. */
  22454. getNormals(): Nullable<FloatArray>;
  22455. /**
  22456. * Affects tangent data to this target
  22457. * @param data defines the tangent data to use
  22458. */
  22459. setTangents(data: Nullable<FloatArray>): void;
  22460. /**
  22461. * Gets the tangent data stored in this target
  22462. * @returns a FloatArray containing the tangent data (or null if not present)
  22463. */
  22464. getTangents(): Nullable<FloatArray>;
  22465. /**
  22466. * Affects texture coordinates data to this target
  22467. * @param data defines the texture coordinates data to use
  22468. */
  22469. setUVs(data: Nullable<FloatArray>): void;
  22470. /**
  22471. * Gets the texture coordinates data stored in this target
  22472. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22473. */
  22474. getUVs(): Nullable<FloatArray>;
  22475. /**
  22476. * Serializes the current target into a Serialization object
  22477. * @returns the serialized object
  22478. */
  22479. serialize(): any;
  22480. /**
  22481. * Returns the string "MorphTarget"
  22482. * @returns "MorphTarget"
  22483. */
  22484. getClassName(): string;
  22485. /**
  22486. * Creates a new target from serialized data
  22487. * @param serializationObject defines the serialized data to use
  22488. * @returns a new MorphTarget
  22489. */
  22490. static Parse(serializationObject: any): MorphTarget;
  22491. /**
  22492. * Creates a MorphTarget from mesh data
  22493. * @param mesh defines the source mesh
  22494. * @param name defines the name to use for the new target
  22495. * @param influence defines the influence to attach to the target
  22496. * @returns a new MorphTarget
  22497. */
  22498. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22499. }
  22500. }
  22501. declare module "babylonjs/Morph/morphTargetManager" {
  22502. import { Nullable } from "babylonjs/types";
  22503. import { Scene } from "babylonjs/scene";
  22504. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22505. /**
  22506. * This class is used to deform meshes using morphing between different targets
  22507. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22508. */
  22509. export class MorphTargetManager {
  22510. private _targets;
  22511. private _targetInfluenceChangedObservers;
  22512. private _targetDataLayoutChangedObservers;
  22513. private _activeTargets;
  22514. private _scene;
  22515. private _influences;
  22516. private _supportsNormals;
  22517. private _supportsTangents;
  22518. private _supportsUVs;
  22519. private _vertexCount;
  22520. private _uniqueId;
  22521. private _tempInfluences;
  22522. /**
  22523. * Gets or sets a boolean indicating if normals must be morphed
  22524. */
  22525. enableNormalMorphing: boolean;
  22526. /**
  22527. * Gets or sets a boolean indicating if tangents must be morphed
  22528. */
  22529. enableTangentMorphing: boolean;
  22530. /**
  22531. * Gets or sets a boolean indicating if UV must be morphed
  22532. */
  22533. enableUVMorphing: boolean;
  22534. /**
  22535. * Creates a new MorphTargetManager
  22536. * @param scene defines the current scene
  22537. */
  22538. constructor(scene?: Nullable<Scene>);
  22539. /**
  22540. * Gets the unique ID of this manager
  22541. */
  22542. readonly uniqueId: number;
  22543. /**
  22544. * Gets the number of vertices handled by this manager
  22545. */
  22546. readonly vertexCount: number;
  22547. /**
  22548. * Gets a boolean indicating if this manager supports morphing of normals
  22549. */
  22550. readonly supportsNormals: boolean;
  22551. /**
  22552. * Gets a boolean indicating if this manager supports morphing of tangents
  22553. */
  22554. readonly supportsTangents: boolean;
  22555. /**
  22556. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22557. */
  22558. readonly supportsUVs: boolean;
  22559. /**
  22560. * Gets the number of targets stored in this manager
  22561. */
  22562. readonly numTargets: number;
  22563. /**
  22564. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22565. */
  22566. readonly numInfluencers: number;
  22567. /**
  22568. * Gets the list of influences (one per target)
  22569. */
  22570. readonly influences: Float32Array;
  22571. /**
  22572. * Gets the active target at specified index. An active target is a target with an influence > 0
  22573. * @param index defines the index to check
  22574. * @returns the requested target
  22575. */
  22576. getActiveTarget(index: number): MorphTarget;
  22577. /**
  22578. * Gets the target at specified index
  22579. * @param index defines the index to check
  22580. * @returns the requested target
  22581. */
  22582. getTarget(index: number): MorphTarget;
  22583. /**
  22584. * Add a new target to this manager
  22585. * @param target defines the target to add
  22586. */
  22587. addTarget(target: MorphTarget): void;
  22588. /**
  22589. * Removes a target from the manager
  22590. * @param target defines the target to remove
  22591. */
  22592. removeTarget(target: MorphTarget): void;
  22593. /**
  22594. * Serializes the current manager into a Serialization object
  22595. * @returns the serialized object
  22596. */
  22597. serialize(): any;
  22598. private _syncActiveTargets;
  22599. /**
  22600. * Syncrhonize the targets with all the meshes using this morph target manager
  22601. */
  22602. synchronize(): void;
  22603. /**
  22604. * Creates a new MorphTargetManager from serialized data
  22605. * @param serializationObject defines the serialized data
  22606. * @param scene defines the hosting scene
  22607. * @returns the new MorphTargetManager
  22608. */
  22609. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22610. }
  22611. }
  22612. declare module "babylonjs/Meshes/meshLODLevel" {
  22613. import { Mesh } from "babylonjs/Meshes/mesh";
  22614. import { Nullable } from "babylonjs/types";
  22615. /**
  22616. * Class used to represent a specific level of detail of a mesh
  22617. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22618. */
  22619. export class MeshLODLevel {
  22620. /** Defines the distance where this level should star being displayed */
  22621. distance: number;
  22622. /** Defines the mesh to use to render this level */
  22623. mesh: Nullable<Mesh>;
  22624. /**
  22625. * Creates a new LOD level
  22626. * @param distance defines the distance where this level should star being displayed
  22627. * @param mesh defines the mesh to use to render this level
  22628. */
  22629. constructor(
  22630. /** Defines the distance where this level should star being displayed */
  22631. distance: number,
  22632. /** Defines the mesh to use to render this level */
  22633. mesh: Nullable<Mesh>);
  22634. }
  22635. }
  22636. declare module "babylonjs/Meshes/groundMesh" {
  22637. import { Scene } from "babylonjs/scene";
  22638. import { Vector3 } from "babylonjs/Maths/math.vector";
  22639. import { Mesh } from "babylonjs/Meshes/mesh";
  22640. /**
  22641. * Mesh representing the gorund
  22642. */
  22643. export class GroundMesh extends Mesh {
  22644. /** If octree should be generated */
  22645. generateOctree: boolean;
  22646. private _heightQuads;
  22647. /** @hidden */
  22648. _subdivisionsX: number;
  22649. /** @hidden */
  22650. _subdivisionsY: number;
  22651. /** @hidden */
  22652. _width: number;
  22653. /** @hidden */
  22654. _height: number;
  22655. /** @hidden */
  22656. _minX: number;
  22657. /** @hidden */
  22658. _maxX: number;
  22659. /** @hidden */
  22660. _minZ: number;
  22661. /** @hidden */
  22662. _maxZ: number;
  22663. constructor(name: string, scene: Scene);
  22664. /**
  22665. * "GroundMesh"
  22666. * @returns "GroundMesh"
  22667. */
  22668. getClassName(): string;
  22669. /**
  22670. * The minimum of x and y subdivisions
  22671. */
  22672. readonly subdivisions: number;
  22673. /**
  22674. * X subdivisions
  22675. */
  22676. readonly subdivisionsX: number;
  22677. /**
  22678. * Y subdivisions
  22679. */
  22680. readonly subdivisionsY: number;
  22681. /**
  22682. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22683. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22684. * @param chunksCount the number of subdivisions for x and y
  22685. * @param octreeBlocksSize (Default: 32)
  22686. */
  22687. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22688. /**
  22689. * Returns a height (y) value in the Worl system :
  22690. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22691. * @param x x coordinate
  22692. * @param z z coordinate
  22693. * @returns the ground y position if (x, z) are outside the ground surface.
  22694. */
  22695. getHeightAtCoordinates(x: number, z: number): number;
  22696. /**
  22697. * Returns a normalized vector (Vector3) orthogonal to the ground
  22698. * at the ground coordinates (x, z) expressed in the World system.
  22699. * @param x x coordinate
  22700. * @param z z coordinate
  22701. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22702. */
  22703. getNormalAtCoordinates(x: number, z: number): Vector3;
  22704. /**
  22705. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22706. * at the ground coordinates (x, z) expressed in the World system.
  22707. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22708. * @param x x coordinate
  22709. * @param z z coordinate
  22710. * @param ref vector to store the result
  22711. * @returns the GroundMesh.
  22712. */
  22713. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22714. /**
  22715. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22716. * if the ground has been updated.
  22717. * This can be used in the render loop.
  22718. * @returns the GroundMesh.
  22719. */
  22720. updateCoordinateHeights(): GroundMesh;
  22721. private _getFacetAt;
  22722. private _initHeightQuads;
  22723. private _computeHeightQuads;
  22724. /**
  22725. * Serializes this ground mesh
  22726. * @param serializationObject object to write serialization to
  22727. */
  22728. serialize(serializationObject: any): void;
  22729. /**
  22730. * Parses a serialized ground mesh
  22731. * @param parsedMesh the serialized mesh
  22732. * @param scene the scene to create the ground mesh in
  22733. * @returns the created ground mesh
  22734. */
  22735. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22736. }
  22737. }
  22738. declare module "babylonjs/Physics/physicsJoint" {
  22739. import { Vector3 } from "babylonjs/Maths/math.vector";
  22740. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22741. /**
  22742. * Interface for Physics-Joint data
  22743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22744. */
  22745. export interface PhysicsJointData {
  22746. /**
  22747. * The main pivot of the joint
  22748. */
  22749. mainPivot?: Vector3;
  22750. /**
  22751. * The connected pivot of the joint
  22752. */
  22753. connectedPivot?: Vector3;
  22754. /**
  22755. * The main axis of the joint
  22756. */
  22757. mainAxis?: Vector3;
  22758. /**
  22759. * The connected axis of the joint
  22760. */
  22761. connectedAxis?: Vector3;
  22762. /**
  22763. * The collision of the joint
  22764. */
  22765. collision?: boolean;
  22766. /**
  22767. * Native Oimo/Cannon/Energy data
  22768. */
  22769. nativeParams?: any;
  22770. }
  22771. /**
  22772. * This is a holder class for the physics joint created by the physics plugin
  22773. * It holds a set of functions to control the underlying joint
  22774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22775. */
  22776. export class PhysicsJoint {
  22777. /**
  22778. * The type of the physics joint
  22779. */
  22780. type: number;
  22781. /**
  22782. * The data for the physics joint
  22783. */
  22784. jointData: PhysicsJointData;
  22785. private _physicsJoint;
  22786. protected _physicsPlugin: IPhysicsEnginePlugin;
  22787. /**
  22788. * Initializes the physics joint
  22789. * @param type The type of the physics joint
  22790. * @param jointData The data for the physics joint
  22791. */
  22792. constructor(
  22793. /**
  22794. * The type of the physics joint
  22795. */
  22796. type: number,
  22797. /**
  22798. * The data for the physics joint
  22799. */
  22800. jointData: PhysicsJointData);
  22801. /**
  22802. * Gets the physics joint
  22803. */
  22804. /**
  22805. * Sets the physics joint
  22806. */
  22807. physicsJoint: any;
  22808. /**
  22809. * Sets the physics plugin
  22810. */
  22811. physicsPlugin: IPhysicsEnginePlugin;
  22812. /**
  22813. * Execute a function that is physics-plugin specific.
  22814. * @param {Function} func the function that will be executed.
  22815. * It accepts two parameters: the physics world and the physics joint
  22816. */
  22817. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22818. /**
  22819. * Distance-Joint type
  22820. */
  22821. static DistanceJoint: number;
  22822. /**
  22823. * Hinge-Joint type
  22824. */
  22825. static HingeJoint: number;
  22826. /**
  22827. * Ball-and-Socket joint type
  22828. */
  22829. static BallAndSocketJoint: number;
  22830. /**
  22831. * Wheel-Joint type
  22832. */
  22833. static WheelJoint: number;
  22834. /**
  22835. * Slider-Joint type
  22836. */
  22837. static SliderJoint: number;
  22838. /**
  22839. * Prismatic-Joint type
  22840. */
  22841. static PrismaticJoint: number;
  22842. /**
  22843. * Universal-Joint type
  22844. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22845. */
  22846. static UniversalJoint: number;
  22847. /**
  22848. * Hinge-Joint 2 type
  22849. */
  22850. static Hinge2Joint: number;
  22851. /**
  22852. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22853. */
  22854. static PointToPointJoint: number;
  22855. /**
  22856. * Spring-Joint type
  22857. */
  22858. static SpringJoint: number;
  22859. /**
  22860. * Lock-Joint type
  22861. */
  22862. static LockJoint: number;
  22863. }
  22864. /**
  22865. * A class representing a physics distance joint
  22866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22867. */
  22868. export class DistanceJoint extends PhysicsJoint {
  22869. /**
  22870. *
  22871. * @param jointData The data for the Distance-Joint
  22872. */
  22873. constructor(jointData: DistanceJointData);
  22874. /**
  22875. * Update the predefined distance.
  22876. * @param maxDistance The maximum preferred distance
  22877. * @param minDistance The minimum preferred distance
  22878. */
  22879. updateDistance(maxDistance: number, minDistance?: number): void;
  22880. }
  22881. /**
  22882. * Represents a Motor-Enabled Joint
  22883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22884. */
  22885. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22886. /**
  22887. * Initializes the Motor-Enabled Joint
  22888. * @param type The type of the joint
  22889. * @param jointData The physica joint data for the joint
  22890. */
  22891. constructor(type: number, jointData: PhysicsJointData);
  22892. /**
  22893. * Set the motor values.
  22894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22895. * @param force the force to apply
  22896. * @param maxForce max force for this motor.
  22897. */
  22898. setMotor(force?: number, maxForce?: number): void;
  22899. /**
  22900. * Set the motor's limits.
  22901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22902. * @param upperLimit The upper limit of the motor
  22903. * @param lowerLimit The lower limit of the motor
  22904. */
  22905. setLimit(upperLimit: number, lowerLimit?: number): void;
  22906. }
  22907. /**
  22908. * This class represents a single physics Hinge-Joint
  22909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22910. */
  22911. export class HingeJoint extends MotorEnabledJoint {
  22912. /**
  22913. * Initializes the Hinge-Joint
  22914. * @param jointData The joint data for the Hinge-Joint
  22915. */
  22916. constructor(jointData: PhysicsJointData);
  22917. /**
  22918. * Set the motor values.
  22919. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22920. * @param {number} force the force to apply
  22921. * @param {number} maxForce max force for this motor.
  22922. */
  22923. setMotor(force?: number, maxForce?: number): void;
  22924. /**
  22925. * Set the motor's limits.
  22926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22927. * @param upperLimit The upper limit of the motor
  22928. * @param lowerLimit The lower limit of the motor
  22929. */
  22930. setLimit(upperLimit: number, lowerLimit?: number): void;
  22931. }
  22932. /**
  22933. * This class represents a dual hinge physics joint (same as wheel joint)
  22934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22935. */
  22936. export class Hinge2Joint extends MotorEnabledJoint {
  22937. /**
  22938. * Initializes the Hinge2-Joint
  22939. * @param jointData The joint data for the Hinge2-Joint
  22940. */
  22941. constructor(jointData: PhysicsJointData);
  22942. /**
  22943. * Set the motor values.
  22944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22945. * @param {number} targetSpeed the speed the motor is to reach
  22946. * @param {number} maxForce max force for this motor.
  22947. * @param {motorIndex} the motor's index, 0 or 1.
  22948. */
  22949. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22950. /**
  22951. * Set the motor limits.
  22952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22953. * @param {number} upperLimit the upper limit
  22954. * @param {number} lowerLimit lower limit
  22955. * @param {motorIndex} the motor's index, 0 or 1.
  22956. */
  22957. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22958. }
  22959. /**
  22960. * Interface for a motor enabled joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export interface IMotorEnabledJoint {
  22964. /**
  22965. * Physics joint
  22966. */
  22967. physicsJoint: any;
  22968. /**
  22969. * Sets the motor of the motor-enabled joint
  22970. * @param force The force of the motor
  22971. * @param maxForce The maximum force of the motor
  22972. * @param motorIndex The index of the motor
  22973. */
  22974. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22975. /**
  22976. * Sets the limit of the motor
  22977. * @param upperLimit The upper limit of the motor
  22978. * @param lowerLimit The lower limit of the motor
  22979. * @param motorIndex The index of the motor
  22980. */
  22981. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22982. }
  22983. /**
  22984. * Joint data for a Distance-Joint
  22985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22986. */
  22987. export interface DistanceJointData extends PhysicsJointData {
  22988. /**
  22989. * Max distance the 2 joint objects can be apart
  22990. */
  22991. maxDistance: number;
  22992. }
  22993. /**
  22994. * Joint data from a spring joint
  22995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22996. */
  22997. export interface SpringJointData extends PhysicsJointData {
  22998. /**
  22999. * Length of the spring
  23000. */
  23001. length: number;
  23002. /**
  23003. * Stiffness of the spring
  23004. */
  23005. stiffness: number;
  23006. /**
  23007. * Damping of the spring
  23008. */
  23009. damping: number;
  23010. /** this callback will be called when applying the force to the impostors. */
  23011. forceApplicationCallback: () => void;
  23012. }
  23013. }
  23014. declare module "babylonjs/Physics/physicsRaycastResult" {
  23015. import { Vector3 } from "babylonjs/Maths/math.vector";
  23016. /**
  23017. * Holds the data for the raycast result
  23018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23019. */
  23020. export class PhysicsRaycastResult {
  23021. private _hasHit;
  23022. private _hitDistance;
  23023. private _hitNormalWorld;
  23024. private _hitPointWorld;
  23025. private _rayFromWorld;
  23026. private _rayToWorld;
  23027. /**
  23028. * Gets if there was a hit
  23029. */
  23030. readonly hasHit: boolean;
  23031. /**
  23032. * Gets the distance from the hit
  23033. */
  23034. readonly hitDistance: number;
  23035. /**
  23036. * Gets the hit normal/direction in the world
  23037. */
  23038. readonly hitNormalWorld: Vector3;
  23039. /**
  23040. * Gets the hit point in the world
  23041. */
  23042. readonly hitPointWorld: Vector3;
  23043. /**
  23044. * Gets the ray "start point" of the ray in the world
  23045. */
  23046. readonly rayFromWorld: Vector3;
  23047. /**
  23048. * Gets the ray "end point" of the ray in the world
  23049. */
  23050. readonly rayToWorld: Vector3;
  23051. /**
  23052. * Sets the hit data (normal & point in world space)
  23053. * @param hitNormalWorld defines the normal in world space
  23054. * @param hitPointWorld defines the point in world space
  23055. */
  23056. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23057. /**
  23058. * Sets the distance from the start point to the hit point
  23059. * @param distance
  23060. */
  23061. setHitDistance(distance: number): void;
  23062. /**
  23063. * Calculates the distance manually
  23064. */
  23065. calculateHitDistance(): void;
  23066. /**
  23067. * Resets all the values to default
  23068. * @param from The from point on world space
  23069. * @param to The to point on world space
  23070. */
  23071. reset(from?: Vector3, to?: Vector3): void;
  23072. }
  23073. /**
  23074. * Interface for the size containing width and height
  23075. */
  23076. interface IXYZ {
  23077. /**
  23078. * X
  23079. */
  23080. x: number;
  23081. /**
  23082. * Y
  23083. */
  23084. y: number;
  23085. /**
  23086. * Z
  23087. */
  23088. z: number;
  23089. }
  23090. }
  23091. declare module "babylonjs/Physics/IPhysicsEngine" {
  23092. import { Nullable } from "babylonjs/types";
  23093. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23095. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23096. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23097. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23098. /**
  23099. * Interface used to describe a physics joint
  23100. */
  23101. export interface PhysicsImpostorJoint {
  23102. /** Defines the main impostor to which the joint is linked */
  23103. mainImpostor: PhysicsImpostor;
  23104. /** Defines the impostor that is connected to the main impostor using this joint */
  23105. connectedImpostor: PhysicsImpostor;
  23106. /** Defines the joint itself */
  23107. joint: PhysicsJoint;
  23108. }
  23109. /** @hidden */
  23110. export interface IPhysicsEnginePlugin {
  23111. world: any;
  23112. name: string;
  23113. setGravity(gravity: Vector3): void;
  23114. setTimeStep(timeStep: number): void;
  23115. getTimeStep(): number;
  23116. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23117. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23118. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23119. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23120. removePhysicsBody(impostor: PhysicsImpostor): void;
  23121. generateJoint(joint: PhysicsImpostorJoint): void;
  23122. removeJoint(joint: PhysicsImpostorJoint): void;
  23123. isSupported(): boolean;
  23124. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23125. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23126. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23127. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23128. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23129. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23130. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23131. getBodyMass(impostor: PhysicsImpostor): number;
  23132. getBodyFriction(impostor: PhysicsImpostor): number;
  23133. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23134. getBodyRestitution(impostor: PhysicsImpostor): number;
  23135. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23136. getBodyPressure?(impostor: PhysicsImpostor): number;
  23137. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23138. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23139. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23140. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23141. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23142. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23143. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23144. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23145. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23146. sleepBody(impostor: PhysicsImpostor): void;
  23147. wakeUpBody(impostor: PhysicsImpostor): void;
  23148. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23149. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23150. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23151. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23152. getRadius(impostor: PhysicsImpostor): number;
  23153. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23154. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23155. dispose(): void;
  23156. }
  23157. /**
  23158. * Interface used to define a physics engine
  23159. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23160. */
  23161. export interface IPhysicsEngine {
  23162. /**
  23163. * Gets the gravity vector used by the simulation
  23164. */
  23165. gravity: Vector3;
  23166. /**
  23167. * Sets the gravity vector used by the simulation
  23168. * @param gravity defines the gravity vector to use
  23169. */
  23170. setGravity(gravity: Vector3): void;
  23171. /**
  23172. * Set the time step of the physics engine.
  23173. * Default is 1/60.
  23174. * To slow it down, enter 1/600 for example.
  23175. * To speed it up, 1/30
  23176. * @param newTimeStep the new timestep to apply to this world.
  23177. */
  23178. setTimeStep(newTimeStep: number): void;
  23179. /**
  23180. * Get the time step of the physics engine.
  23181. * @returns the current time step
  23182. */
  23183. getTimeStep(): number;
  23184. /**
  23185. * Release all resources
  23186. */
  23187. dispose(): void;
  23188. /**
  23189. * Gets the name of the current physics plugin
  23190. * @returns the name of the plugin
  23191. */
  23192. getPhysicsPluginName(): string;
  23193. /**
  23194. * Adding a new impostor for the impostor tracking.
  23195. * This will be done by the impostor itself.
  23196. * @param impostor the impostor to add
  23197. */
  23198. addImpostor(impostor: PhysicsImpostor): void;
  23199. /**
  23200. * Remove an impostor from the engine.
  23201. * This impostor and its mesh will not longer be updated by the physics engine.
  23202. * @param impostor the impostor to remove
  23203. */
  23204. removeImpostor(impostor: PhysicsImpostor): void;
  23205. /**
  23206. * Add a joint to the physics engine
  23207. * @param mainImpostor defines the main impostor to which the joint is added.
  23208. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23209. * @param joint defines the joint that will connect both impostors.
  23210. */
  23211. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23212. /**
  23213. * Removes a joint from the simulation
  23214. * @param mainImpostor defines the impostor used with the joint
  23215. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23216. * @param joint defines the joint to remove
  23217. */
  23218. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23219. /**
  23220. * Gets the current plugin used to run the simulation
  23221. * @returns current plugin
  23222. */
  23223. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23224. /**
  23225. * Gets the list of physic impostors
  23226. * @returns an array of PhysicsImpostor
  23227. */
  23228. getImpostors(): Array<PhysicsImpostor>;
  23229. /**
  23230. * Gets the impostor for a physics enabled object
  23231. * @param object defines the object impersonated by the impostor
  23232. * @returns the PhysicsImpostor or null if not found
  23233. */
  23234. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23235. /**
  23236. * Gets the impostor for a physics body object
  23237. * @param body defines physics body used by the impostor
  23238. * @returns the PhysicsImpostor or null if not found
  23239. */
  23240. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23241. /**
  23242. * Does a raycast in the physics world
  23243. * @param from when should the ray start?
  23244. * @param to when should the ray end?
  23245. * @returns PhysicsRaycastResult
  23246. */
  23247. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23248. /**
  23249. * Called by the scene. No need to call it.
  23250. * @param delta defines the timespam between frames
  23251. */
  23252. _step(delta: number): void;
  23253. }
  23254. }
  23255. declare module "babylonjs/Physics/physicsImpostor" {
  23256. import { Nullable, IndicesArray } from "babylonjs/types";
  23257. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23260. import { Scene } from "babylonjs/scene";
  23261. import { Bone } from "babylonjs/Bones/bone";
  23262. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23263. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23264. import { Space } from "babylonjs/Maths/math.axis";
  23265. /**
  23266. * The interface for the physics imposter parameters
  23267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23268. */
  23269. export interface PhysicsImpostorParameters {
  23270. /**
  23271. * The mass of the physics imposter
  23272. */
  23273. mass: number;
  23274. /**
  23275. * The friction of the physics imposter
  23276. */
  23277. friction?: number;
  23278. /**
  23279. * The coefficient of restitution of the physics imposter
  23280. */
  23281. restitution?: number;
  23282. /**
  23283. * The native options of the physics imposter
  23284. */
  23285. nativeOptions?: any;
  23286. /**
  23287. * Specifies if the parent should be ignored
  23288. */
  23289. ignoreParent?: boolean;
  23290. /**
  23291. * Specifies if bi-directional transformations should be disabled
  23292. */
  23293. disableBidirectionalTransformation?: boolean;
  23294. /**
  23295. * The pressure inside the physics imposter, soft object only
  23296. */
  23297. pressure?: number;
  23298. /**
  23299. * The stiffness the physics imposter, soft object only
  23300. */
  23301. stiffness?: number;
  23302. /**
  23303. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23304. */
  23305. velocityIterations?: number;
  23306. /**
  23307. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23308. */
  23309. positionIterations?: number;
  23310. /**
  23311. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23312. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23313. * Add to fix multiple points
  23314. */
  23315. fixedPoints?: number;
  23316. /**
  23317. * The collision margin around a soft object
  23318. */
  23319. margin?: number;
  23320. /**
  23321. * The collision margin around a soft object
  23322. */
  23323. damping?: number;
  23324. /**
  23325. * The path for a rope based on an extrusion
  23326. */
  23327. path?: any;
  23328. /**
  23329. * The shape of an extrusion used for a rope based on an extrusion
  23330. */
  23331. shape?: any;
  23332. }
  23333. /**
  23334. * Interface for a physics-enabled object
  23335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23336. */
  23337. export interface IPhysicsEnabledObject {
  23338. /**
  23339. * The position of the physics-enabled object
  23340. */
  23341. position: Vector3;
  23342. /**
  23343. * The rotation of the physics-enabled object
  23344. */
  23345. rotationQuaternion: Nullable<Quaternion>;
  23346. /**
  23347. * The scale of the physics-enabled object
  23348. */
  23349. scaling: Vector3;
  23350. /**
  23351. * The rotation of the physics-enabled object
  23352. */
  23353. rotation?: Vector3;
  23354. /**
  23355. * The parent of the physics-enabled object
  23356. */
  23357. parent?: any;
  23358. /**
  23359. * The bounding info of the physics-enabled object
  23360. * @returns The bounding info of the physics-enabled object
  23361. */
  23362. getBoundingInfo(): BoundingInfo;
  23363. /**
  23364. * Computes the world matrix
  23365. * @param force Specifies if the world matrix should be computed by force
  23366. * @returns A world matrix
  23367. */
  23368. computeWorldMatrix(force: boolean): Matrix;
  23369. /**
  23370. * Gets the world matrix
  23371. * @returns A world matrix
  23372. */
  23373. getWorldMatrix?(): Matrix;
  23374. /**
  23375. * Gets the child meshes
  23376. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23377. * @returns An array of abstract meshes
  23378. */
  23379. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23380. /**
  23381. * Gets the vertex data
  23382. * @param kind The type of vertex data
  23383. * @returns A nullable array of numbers, or a float32 array
  23384. */
  23385. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23386. /**
  23387. * Gets the indices from the mesh
  23388. * @returns A nullable array of index arrays
  23389. */
  23390. getIndices?(): Nullable<IndicesArray>;
  23391. /**
  23392. * Gets the scene from the mesh
  23393. * @returns the indices array or null
  23394. */
  23395. getScene?(): Scene;
  23396. /**
  23397. * Gets the absolute position from the mesh
  23398. * @returns the absolute position
  23399. */
  23400. getAbsolutePosition(): Vector3;
  23401. /**
  23402. * Gets the absolute pivot point from the mesh
  23403. * @returns the absolute pivot point
  23404. */
  23405. getAbsolutePivotPoint(): Vector3;
  23406. /**
  23407. * Rotates the mesh
  23408. * @param axis The axis of rotation
  23409. * @param amount The amount of rotation
  23410. * @param space The space of the rotation
  23411. * @returns The rotation transform node
  23412. */
  23413. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23414. /**
  23415. * Translates the mesh
  23416. * @param axis The axis of translation
  23417. * @param distance The distance of translation
  23418. * @param space The space of the translation
  23419. * @returns The transform node
  23420. */
  23421. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23422. /**
  23423. * Sets the absolute position of the mesh
  23424. * @param absolutePosition The absolute position of the mesh
  23425. * @returns The transform node
  23426. */
  23427. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23428. /**
  23429. * Gets the class name of the mesh
  23430. * @returns The class name
  23431. */
  23432. getClassName(): string;
  23433. }
  23434. /**
  23435. * Represents a physics imposter
  23436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23437. */
  23438. export class PhysicsImpostor {
  23439. /**
  23440. * The physics-enabled object used as the physics imposter
  23441. */
  23442. object: IPhysicsEnabledObject;
  23443. /**
  23444. * The type of the physics imposter
  23445. */
  23446. type: number;
  23447. private _options;
  23448. private _scene?;
  23449. /**
  23450. * The default object size of the imposter
  23451. */
  23452. static DEFAULT_OBJECT_SIZE: Vector3;
  23453. /**
  23454. * The identity quaternion of the imposter
  23455. */
  23456. static IDENTITY_QUATERNION: Quaternion;
  23457. /** @hidden */
  23458. _pluginData: any;
  23459. private _physicsEngine;
  23460. private _physicsBody;
  23461. private _bodyUpdateRequired;
  23462. private _onBeforePhysicsStepCallbacks;
  23463. private _onAfterPhysicsStepCallbacks;
  23464. /** @hidden */
  23465. _onPhysicsCollideCallbacks: Array<{
  23466. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23467. otherImpostors: Array<PhysicsImpostor>;
  23468. }>;
  23469. private _deltaPosition;
  23470. private _deltaRotation;
  23471. private _deltaRotationConjugated;
  23472. /** @hidden */
  23473. _isFromLine: boolean;
  23474. private _parent;
  23475. private _isDisposed;
  23476. private static _tmpVecs;
  23477. private static _tmpQuat;
  23478. /**
  23479. * Specifies if the physics imposter is disposed
  23480. */
  23481. readonly isDisposed: boolean;
  23482. /**
  23483. * Gets the mass of the physics imposter
  23484. */
  23485. mass: number;
  23486. /**
  23487. * Gets the coefficient of friction
  23488. */
  23489. /**
  23490. * Sets the coefficient of friction
  23491. */
  23492. friction: number;
  23493. /**
  23494. * Gets the coefficient of restitution
  23495. */
  23496. /**
  23497. * Sets the coefficient of restitution
  23498. */
  23499. restitution: number;
  23500. /**
  23501. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23502. */
  23503. /**
  23504. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23505. */
  23506. pressure: number;
  23507. /**
  23508. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23509. */
  23510. /**
  23511. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23512. */
  23513. stiffness: number;
  23514. /**
  23515. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23516. */
  23517. /**
  23518. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23519. */
  23520. velocityIterations: number;
  23521. /**
  23522. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23523. */
  23524. /**
  23525. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23526. */
  23527. positionIterations: number;
  23528. /**
  23529. * The unique id of the physics imposter
  23530. * set by the physics engine when adding this impostor to the array
  23531. */
  23532. uniqueId: number;
  23533. /**
  23534. * @hidden
  23535. */
  23536. soft: boolean;
  23537. /**
  23538. * @hidden
  23539. */
  23540. segments: number;
  23541. private _joints;
  23542. /**
  23543. * Initializes the physics imposter
  23544. * @param object The physics-enabled object used as the physics imposter
  23545. * @param type The type of the physics imposter
  23546. * @param _options The options for the physics imposter
  23547. * @param _scene The Babylon scene
  23548. */
  23549. constructor(
  23550. /**
  23551. * The physics-enabled object used as the physics imposter
  23552. */
  23553. object: IPhysicsEnabledObject,
  23554. /**
  23555. * The type of the physics imposter
  23556. */
  23557. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23558. /**
  23559. * This function will completly initialize this impostor.
  23560. * It will create a new body - but only if this mesh has no parent.
  23561. * If it has, this impostor will not be used other than to define the impostor
  23562. * of the child mesh.
  23563. * @hidden
  23564. */
  23565. _init(): void;
  23566. private _getPhysicsParent;
  23567. /**
  23568. * Should a new body be generated.
  23569. * @returns boolean specifying if body initialization is required
  23570. */
  23571. isBodyInitRequired(): boolean;
  23572. /**
  23573. * Sets the updated scaling
  23574. * @param updated Specifies if the scaling is updated
  23575. */
  23576. setScalingUpdated(): void;
  23577. /**
  23578. * Force a regeneration of this or the parent's impostor's body.
  23579. * Use under cautious - This will remove all joints already implemented.
  23580. */
  23581. forceUpdate(): void;
  23582. /**
  23583. * Gets the body that holds this impostor. Either its own, or its parent.
  23584. */
  23585. /**
  23586. * Set the physics body. Used mainly by the physics engine/plugin
  23587. */
  23588. physicsBody: any;
  23589. /**
  23590. * Get the parent of the physics imposter
  23591. * @returns Physics imposter or null
  23592. */
  23593. /**
  23594. * Sets the parent of the physics imposter
  23595. */
  23596. parent: Nullable<PhysicsImpostor>;
  23597. /**
  23598. * Resets the update flags
  23599. */
  23600. resetUpdateFlags(): void;
  23601. /**
  23602. * Gets the object extend size
  23603. * @returns the object extend size
  23604. */
  23605. getObjectExtendSize(): Vector3;
  23606. /**
  23607. * Gets the object center
  23608. * @returns The object center
  23609. */
  23610. getObjectCenter(): Vector3;
  23611. /**
  23612. * Get a specific parametes from the options parameter
  23613. * @param paramName The object parameter name
  23614. * @returns The object parameter
  23615. */
  23616. getParam(paramName: string): any;
  23617. /**
  23618. * Sets a specific parameter in the options given to the physics plugin
  23619. * @param paramName The parameter name
  23620. * @param value The value of the parameter
  23621. */
  23622. setParam(paramName: string, value: number): void;
  23623. /**
  23624. * Specifically change the body's mass option. Won't recreate the physics body object
  23625. * @param mass The mass of the physics imposter
  23626. */
  23627. setMass(mass: number): void;
  23628. /**
  23629. * Gets the linear velocity
  23630. * @returns linear velocity or null
  23631. */
  23632. getLinearVelocity(): Nullable<Vector3>;
  23633. /**
  23634. * Sets the linear velocity
  23635. * @param velocity linear velocity or null
  23636. */
  23637. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23638. /**
  23639. * Gets the angular velocity
  23640. * @returns angular velocity or null
  23641. */
  23642. getAngularVelocity(): Nullable<Vector3>;
  23643. /**
  23644. * Sets the angular velocity
  23645. * @param velocity The velocity or null
  23646. */
  23647. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23648. /**
  23649. * Execute a function with the physics plugin native code
  23650. * Provide a function the will have two variables - the world object and the physics body object
  23651. * @param func The function to execute with the physics plugin native code
  23652. */
  23653. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23654. /**
  23655. * Register a function that will be executed before the physics world is stepping forward
  23656. * @param func The function to execute before the physics world is stepped forward
  23657. */
  23658. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23659. /**
  23660. * Unregister a function that will be executed before the physics world is stepping forward
  23661. * @param func The function to execute before the physics world is stepped forward
  23662. */
  23663. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23664. /**
  23665. * Register a function that will be executed after the physics step
  23666. * @param func The function to execute after physics step
  23667. */
  23668. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23669. /**
  23670. * Unregisters a function that will be executed after the physics step
  23671. * @param func The function to execute after physics step
  23672. */
  23673. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23674. /**
  23675. * register a function that will be executed when this impostor collides against a different body
  23676. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23677. * @param func Callback that is executed on collision
  23678. */
  23679. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23680. /**
  23681. * Unregisters the physics imposter on contact
  23682. * @param collideAgainst The physics object to collide against
  23683. * @param func Callback to execute on collision
  23684. */
  23685. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23686. private _tmpQuat;
  23687. private _tmpQuat2;
  23688. /**
  23689. * Get the parent rotation
  23690. * @returns The parent rotation
  23691. */
  23692. getParentsRotation(): Quaternion;
  23693. /**
  23694. * this function is executed by the physics engine.
  23695. */
  23696. beforeStep: () => void;
  23697. /**
  23698. * this function is executed by the physics engine
  23699. */
  23700. afterStep: () => void;
  23701. /**
  23702. * Legacy collision detection event support
  23703. */
  23704. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23705. /**
  23706. * event and body object due to cannon's event-based architecture.
  23707. */
  23708. onCollide: (e: {
  23709. body: any;
  23710. }) => void;
  23711. /**
  23712. * Apply a force
  23713. * @param force The force to apply
  23714. * @param contactPoint The contact point for the force
  23715. * @returns The physics imposter
  23716. */
  23717. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23718. /**
  23719. * Apply an impulse
  23720. * @param force The impulse force
  23721. * @param contactPoint The contact point for the impulse force
  23722. * @returns The physics imposter
  23723. */
  23724. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23725. /**
  23726. * A help function to create a joint
  23727. * @param otherImpostor A physics imposter used to create a joint
  23728. * @param jointType The type of joint
  23729. * @param jointData The data for the joint
  23730. * @returns The physics imposter
  23731. */
  23732. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23733. /**
  23734. * Add a joint to this impostor with a different impostor
  23735. * @param otherImpostor A physics imposter used to add a joint
  23736. * @param joint The joint to add
  23737. * @returns The physics imposter
  23738. */
  23739. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23740. /**
  23741. * Add an anchor to a cloth impostor
  23742. * @param otherImpostor rigid impostor to anchor to
  23743. * @param width ratio across width from 0 to 1
  23744. * @param height ratio up height from 0 to 1
  23745. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23746. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23747. * @returns impostor the soft imposter
  23748. */
  23749. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23750. /**
  23751. * Add a hook to a rope impostor
  23752. * @param otherImpostor rigid impostor to anchor to
  23753. * @param length ratio across rope from 0 to 1
  23754. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23755. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23756. * @returns impostor the rope imposter
  23757. */
  23758. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23759. /**
  23760. * Will keep this body still, in a sleep mode.
  23761. * @returns the physics imposter
  23762. */
  23763. sleep(): PhysicsImpostor;
  23764. /**
  23765. * Wake the body up.
  23766. * @returns The physics imposter
  23767. */
  23768. wakeUp(): PhysicsImpostor;
  23769. /**
  23770. * Clones the physics imposter
  23771. * @param newObject The physics imposter clones to this physics-enabled object
  23772. * @returns A nullable physics imposter
  23773. */
  23774. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23775. /**
  23776. * Disposes the physics imposter
  23777. */
  23778. dispose(): void;
  23779. /**
  23780. * Sets the delta position
  23781. * @param position The delta position amount
  23782. */
  23783. setDeltaPosition(position: Vector3): void;
  23784. /**
  23785. * Sets the delta rotation
  23786. * @param rotation The delta rotation amount
  23787. */
  23788. setDeltaRotation(rotation: Quaternion): void;
  23789. /**
  23790. * Gets the box size of the physics imposter and stores the result in the input parameter
  23791. * @param result Stores the box size
  23792. * @returns The physics imposter
  23793. */
  23794. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23795. /**
  23796. * Gets the radius of the physics imposter
  23797. * @returns Radius of the physics imposter
  23798. */
  23799. getRadius(): number;
  23800. /**
  23801. * Sync a bone with this impostor
  23802. * @param bone The bone to sync to the impostor.
  23803. * @param boneMesh The mesh that the bone is influencing.
  23804. * @param jointPivot The pivot of the joint / bone in local space.
  23805. * @param distToJoint Optional distance from the impostor to the joint.
  23806. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23807. */
  23808. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23809. /**
  23810. * Sync impostor to a bone
  23811. * @param bone The bone that the impostor will be synced to.
  23812. * @param boneMesh The mesh that the bone is influencing.
  23813. * @param jointPivot The pivot of the joint / bone in local space.
  23814. * @param distToJoint Optional distance from the impostor to the joint.
  23815. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23816. * @param boneAxis Optional vector3 axis the bone is aligned with
  23817. */
  23818. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23819. /**
  23820. * No-Imposter type
  23821. */
  23822. static NoImpostor: number;
  23823. /**
  23824. * Sphere-Imposter type
  23825. */
  23826. static SphereImpostor: number;
  23827. /**
  23828. * Box-Imposter type
  23829. */
  23830. static BoxImpostor: number;
  23831. /**
  23832. * Plane-Imposter type
  23833. */
  23834. static PlaneImpostor: number;
  23835. /**
  23836. * Mesh-imposter type
  23837. */
  23838. static MeshImpostor: number;
  23839. /**
  23840. * Capsule-Impostor type (Ammo.js plugin only)
  23841. */
  23842. static CapsuleImpostor: number;
  23843. /**
  23844. * Cylinder-Imposter type
  23845. */
  23846. static CylinderImpostor: number;
  23847. /**
  23848. * Particle-Imposter type
  23849. */
  23850. static ParticleImpostor: number;
  23851. /**
  23852. * Heightmap-Imposter type
  23853. */
  23854. static HeightmapImpostor: number;
  23855. /**
  23856. * ConvexHull-Impostor type (Ammo.js plugin only)
  23857. */
  23858. static ConvexHullImpostor: number;
  23859. /**
  23860. * Rope-Imposter type
  23861. */
  23862. static RopeImpostor: number;
  23863. /**
  23864. * Cloth-Imposter type
  23865. */
  23866. static ClothImpostor: number;
  23867. /**
  23868. * Softbody-Imposter type
  23869. */
  23870. static SoftbodyImpostor: number;
  23871. }
  23872. }
  23873. declare module "babylonjs/Meshes/mesh" {
  23874. import { Observable } from "babylonjs/Misc/observable";
  23875. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23876. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23877. import { Camera } from "babylonjs/Cameras/camera";
  23878. import { Scene } from "babylonjs/scene";
  23879. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23880. import { Color4 } from "babylonjs/Maths/math.color";
  23881. import { Engine } from "babylonjs/Engines/engine";
  23882. import { Node } from "babylonjs/node";
  23883. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23884. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23885. import { Buffer } from "babylonjs/Meshes/buffer";
  23886. import { Geometry } from "babylonjs/Meshes/geometry";
  23887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23889. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23890. import { Effect } from "babylonjs/Materials/effect";
  23891. import { Material } from "babylonjs/Materials/material";
  23892. import { Skeleton } from "babylonjs/Bones/skeleton";
  23893. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23894. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23895. import { Path3D } from "babylonjs/Maths/math.path";
  23896. import { Plane } from "babylonjs/Maths/math.plane";
  23897. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23898. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23899. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23900. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23901. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23902. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23903. /**
  23904. * @hidden
  23905. **/
  23906. export class _CreationDataStorage {
  23907. closePath?: boolean;
  23908. closeArray?: boolean;
  23909. idx: number[];
  23910. dashSize: number;
  23911. gapSize: number;
  23912. path3D: Path3D;
  23913. pathArray: Vector3[][];
  23914. arc: number;
  23915. radius: number;
  23916. cap: number;
  23917. tessellation: number;
  23918. }
  23919. /**
  23920. * @hidden
  23921. **/
  23922. class _InstanceDataStorage {
  23923. visibleInstances: any;
  23924. batchCache: _InstancesBatch;
  23925. instancesBufferSize: number;
  23926. instancesBuffer: Nullable<Buffer>;
  23927. instancesData: Float32Array;
  23928. overridenInstanceCount: number;
  23929. isFrozen: boolean;
  23930. previousBatch: Nullable<_InstancesBatch>;
  23931. hardwareInstancedRendering: boolean;
  23932. sideOrientation: number;
  23933. }
  23934. /**
  23935. * @hidden
  23936. **/
  23937. export class _InstancesBatch {
  23938. mustReturn: boolean;
  23939. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23940. renderSelf: boolean[];
  23941. hardwareInstancedRendering: boolean[];
  23942. }
  23943. /**
  23944. * Class used to represent renderable models
  23945. */
  23946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23947. /**
  23948. * Mesh side orientation : usually the external or front surface
  23949. */
  23950. static readonly FRONTSIDE: number;
  23951. /**
  23952. * Mesh side orientation : usually the internal or back surface
  23953. */
  23954. static readonly BACKSIDE: number;
  23955. /**
  23956. * Mesh side orientation : both internal and external or front and back surfaces
  23957. */
  23958. static readonly DOUBLESIDE: number;
  23959. /**
  23960. * Mesh side orientation : by default, `FRONTSIDE`
  23961. */
  23962. static readonly DEFAULTSIDE: number;
  23963. /**
  23964. * Mesh cap setting : no cap
  23965. */
  23966. static readonly NO_CAP: number;
  23967. /**
  23968. * Mesh cap setting : one cap at the beginning of the mesh
  23969. */
  23970. static readonly CAP_START: number;
  23971. /**
  23972. * Mesh cap setting : one cap at the end of the mesh
  23973. */
  23974. static readonly CAP_END: number;
  23975. /**
  23976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23977. */
  23978. static readonly CAP_ALL: number;
  23979. /**
  23980. * Mesh pattern setting : no flip or rotate
  23981. */
  23982. static readonly NO_FLIP: number;
  23983. /**
  23984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23985. */
  23986. static readonly FLIP_TILE: number;
  23987. /**
  23988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23989. */
  23990. static readonly ROTATE_TILE: number;
  23991. /**
  23992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23993. */
  23994. static readonly FLIP_ROW: number;
  23995. /**
  23996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23997. */
  23998. static readonly ROTATE_ROW: number;
  23999. /**
  24000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24001. */
  24002. static readonly FLIP_N_ROTATE_TILE: number;
  24003. /**
  24004. * Mesh pattern setting : rotate pattern and rotate
  24005. */
  24006. static readonly FLIP_N_ROTATE_ROW: number;
  24007. /**
  24008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24009. */
  24010. static readonly CENTER: number;
  24011. /**
  24012. * Mesh tile positioning : part tiles on left
  24013. */
  24014. static readonly LEFT: number;
  24015. /**
  24016. * Mesh tile positioning : part tiles on right
  24017. */
  24018. static readonly RIGHT: number;
  24019. /**
  24020. * Mesh tile positioning : part tiles on top
  24021. */
  24022. static readonly TOP: number;
  24023. /**
  24024. * Mesh tile positioning : part tiles on bottom
  24025. */
  24026. static readonly BOTTOM: number;
  24027. /**
  24028. * Gets the default side orientation.
  24029. * @param orientation the orientation to value to attempt to get
  24030. * @returns the default orientation
  24031. * @hidden
  24032. */
  24033. static _GetDefaultSideOrientation(orientation?: number): number;
  24034. private _internalMeshDataInfo;
  24035. /**
  24036. * An event triggered before rendering the mesh
  24037. */
  24038. readonly onBeforeRenderObservable: Observable<Mesh>;
  24039. /**
  24040. * An event triggered before binding the mesh
  24041. */
  24042. readonly onBeforeBindObservable: Observable<Mesh>;
  24043. /**
  24044. * An event triggered after rendering the mesh
  24045. */
  24046. readonly onAfterRenderObservable: Observable<Mesh>;
  24047. /**
  24048. * An event triggered before drawing the mesh
  24049. */
  24050. readonly onBeforeDrawObservable: Observable<Mesh>;
  24051. private _onBeforeDrawObserver;
  24052. /**
  24053. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24054. */
  24055. onBeforeDraw: () => void;
  24056. readonly hasInstances: boolean;
  24057. /**
  24058. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24059. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24060. */
  24061. delayLoadState: number;
  24062. /**
  24063. * Gets the list of instances created from this mesh
  24064. * it is not supposed to be modified manually.
  24065. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24067. */
  24068. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24069. /**
  24070. * Gets the file containing delay loading data for this mesh
  24071. */
  24072. delayLoadingFile: string;
  24073. /** @hidden */
  24074. _binaryInfo: any;
  24075. /**
  24076. * User defined function used to change how LOD level selection is done
  24077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24078. */
  24079. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24080. /**
  24081. * Gets or sets the morph target manager
  24082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24083. */
  24084. morphTargetManager: Nullable<MorphTargetManager>;
  24085. /** @hidden */
  24086. _creationDataStorage: Nullable<_CreationDataStorage>;
  24087. /** @hidden */
  24088. _geometry: Nullable<Geometry>;
  24089. /** @hidden */
  24090. _delayInfo: Array<string>;
  24091. /** @hidden */
  24092. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24093. /** @hidden */
  24094. _instanceDataStorage: _InstanceDataStorage;
  24095. private _effectiveMaterial;
  24096. /** @hidden */
  24097. _shouldGenerateFlatShading: boolean;
  24098. /** @hidden */
  24099. _originalBuilderSideOrientation: number;
  24100. /**
  24101. * Use this property to change the original side orientation defined at construction time
  24102. */
  24103. overrideMaterialSideOrientation: Nullable<number>;
  24104. /**
  24105. * Gets the source mesh (the one used to clone this one from)
  24106. */
  24107. readonly source: Nullable<Mesh>;
  24108. /**
  24109. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24110. */
  24111. isUnIndexed: boolean;
  24112. /**
  24113. * @constructor
  24114. * @param name The value used by scene.getMeshByName() to do a lookup.
  24115. * @param scene The scene to add this mesh to.
  24116. * @param parent The parent of this mesh, if it has one
  24117. * @param source An optional Mesh from which geometry is shared, cloned.
  24118. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24119. * When false, achieved by calling a clone(), also passing False.
  24120. * This will make creation of children, recursive.
  24121. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24122. */
  24123. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24124. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24125. /**
  24126. * Gets the class name
  24127. * @returns the string "Mesh".
  24128. */
  24129. getClassName(): string;
  24130. /** @hidden */
  24131. readonly _isMesh: boolean;
  24132. /**
  24133. * Returns a description of this mesh
  24134. * @param fullDetails define if full details about this mesh must be used
  24135. * @returns a descriptive string representing this mesh
  24136. */
  24137. toString(fullDetails?: boolean): string;
  24138. /** @hidden */
  24139. _unBindEffect(): void;
  24140. /**
  24141. * Gets a boolean indicating if this mesh has LOD
  24142. */
  24143. readonly hasLODLevels: boolean;
  24144. /**
  24145. * Gets the list of MeshLODLevel associated with the current mesh
  24146. * @returns an array of MeshLODLevel
  24147. */
  24148. getLODLevels(): MeshLODLevel[];
  24149. private _sortLODLevels;
  24150. /**
  24151. * Add a mesh as LOD level triggered at the given distance.
  24152. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24153. * @param distance The distance from the center of the object to show this level
  24154. * @param mesh The mesh to be added as LOD level (can be null)
  24155. * @return This mesh (for chaining)
  24156. */
  24157. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24158. /**
  24159. * Returns the LOD level mesh at the passed distance or null if not found.
  24160. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24161. * @param distance The distance from the center of the object to show this level
  24162. * @returns a Mesh or `null`
  24163. */
  24164. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24165. /**
  24166. * Remove a mesh from the LOD array
  24167. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24168. * @param mesh defines the mesh to be removed
  24169. * @return This mesh (for chaining)
  24170. */
  24171. removeLODLevel(mesh: Mesh): Mesh;
  24172. /**
  24173. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24174. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24175. * @param camera defines the camera to use to compute distance
  24176. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24177. * @return This mesh (for chaining)
  24178. */
  24179. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24180. /**
  24181. * Gets the mesh internal Geometry object
  24182. */
  24183. readonly geometry: Nullable<Geometry>;
  24184. /**
  24185. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24186. * @returns the total number of vertices
  24187. */
  24188. getTotalVertices(): number;
  24189. /**
  24190. * Returns the content of an associated vertex buffer
  24191. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24192. * - VertexBuffer.PositionKind
  24193. * - VertexBuffer.UVKind
  24194. * - VertexBuffer.UV2Kind
  24195. * - VertexBuffer.UV3Kind
  24196. * - VertexBuffer.UV4Kind
  24197. * - VertexBuffer.UV5Kind
  24198. * - VertexBuffer.UV6Kind
  24199. * - VertexBuffer.ColorKind
  24200. * - VertexBuffer.MatricesIndicesKind
  24201. * - VertexBuffer.MatricesIndicesExtraKind
  24202. * - VertexBuffer.MatricesWeightsKind
  24203. * - VertexBuffer.MatricesWeightsExtraKind
  24204. * @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
  24205. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24206. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24207. */
  24208. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24209. /**
  24210. * Returns the mesh VertexBuffer object from the requested `kind`
  24211. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24212. * - VertexBuffer.PositionKind
  24213. * - VertexBuffer.NormalKind
  24214. * - VertexBuffer.UVKind
  24215. * - VertexBuffer.UV2Kind
  24216. * - VertexBuffer.UV3Kind
  24217. * - VertexBuffer.UV4Kind
  24218. * - VertexBuffer.UV5Kind
  24219. * - VertexBuffer.UV6Kind
  24220. * - VertexBuffer.ColorKind
  24221. * - VertexBuffer.MatricesIndicesKind
  24222. * - VertexBuffer.MatricesIndicesExtraKind
  24223. * - VertexBuffer.MatricesWeightsKind
  24224. * - VertexBuffer.MatricesWeightsExtraKind
  24225. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24226. */
  24227. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24228. /**
  24229. * Tests if a specific vertex buffer is associated with this mesh
  24230. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24231. * - VertexBuffer.PositionKind
  24232. * - VertexBuffer.NormalKind
  24233. * - VertexBuffer.UVKind
  24234. * - VertexBuffer.UV2Kind
  24235. * - VertexBuffer.UV3Kind
  24236. * - VertexBuffer.UV4Kind
  24237. * - VertexBuffer.UV5Kind
  24238. * - VertexBuffer.UV6Kind
  24239. * - VertexBuffer.ColorKind
  24240. * - VertexBuffer.MatricesIndicesKind
  24241. * - VertexBuffer.MatricesIndicesExtraKind
  24242. * - VertexBuffer.MatricesWeightsKind
  24243. * - VertexBuffer.MatricesWeightsExtraKind
  24244. * @returns a boolean
  24245. */
  24246. isVerticesDataPresent(kind: string): boolean;
  24247. /**
  24248. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24249. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24250. * - VertexBuffer.PositionKind
  24251. * - VertexBuffer.UVKind
  24252. * - VertexBuffer.UV2Kind
  24253. * - VertexBuffer.UV3Kind
  24254. * - VertexBuffer.UV4Kind
  24255. * - VertexBuffer.UV5Kind
  24256. * - VertexBuffer.UV6Kind
  24257. * - VertexBuffer.ColorKind
  24258. * - VertexBuffer.MatricesIndicesKind
  24259. * - VertexBuffer.MatricesIndicesExtraKind
  24260. * - VertexBuffer.MatricesWeightsKind
  24261. * - VertexBuffer.MatricesWeightsExtraKind
  24262. * @returns a boolean
  24263. */
  24264. isVertexBufferUpdatable(kind: string): boolean;
  24265. /**
  24266. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24267. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24268. * - VertexBuffer.PositionKind
  24269. * - VertexBuffer.NormalKind
  24270. * - VertexBuffer.UVKind
  24271. * - VertexBuffer.UV2Kind
  24272. * - VertexBuffer.UV3Kind
  24273. * - VertexBuffer.UV4Kind
  24274. * - VertexBuffer.UV5Kind
  24275. * - VertexBuffer.UV6Kind
  24276. * - VertexBuffer.ColorKind
  24277. * - VertexBuffer.MatricesIndicesKind
  24278. * - VertexBuffer.MatricesIndicesExtraKind
  24279. * - VertexBuffer.MatricesWeightsKind
  24280. * - VertexBuffer.MatricesWeightsExtraKind
  24281. * @returns an array of strings
  24282. */
  24283. getVerticesDataKinds(): string[];
  24284. /**
  24285. * Returns a positive integer : the total number of indices in this mesh geometry.
  24286. * @returns the numner of indices or zero if the mesh has no geometry.
  24287. */
  24288. getTotalIndices(): number;
  24289. /**
  24290. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24291. * @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.
  24292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24293. * @returns the indices array or an empty array if the mesh has no geometry
  24294. */
  24295. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24296. readonly isBlocked: boolean;
  24297. /**
  24298. * Determine if the current mesh is ready to be rendered
  24299. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24300. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24301. * @returns true if all associated assets are ready (material, textures, shaders)
  24302. */
  24303. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24304. /**
  24305. * 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.
  24306. */
  24307. readonly areNormalsFrozen: boolean;
  24308. /**
  24309. * 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.
  24310. * @returns the current mesh
  24311. */
  24312. freezeNormals(): Mesh;
  24313. /**
  24314. * 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
  24315. * @returns the current mesh
  24316. */
  24317. unfreezeNormals(): Mesh;
  24318. /**
  24319. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24320. */
  24321. overridenInstanceCount: number;
  24322. /** @hidden */
  24323. _preActivate(): Mesh;
  24324. /** @hidden */
  24325. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24326. /** @hidden */
  24327. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24328. /**
  24329. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24330. * This means the mesh underlying bounding box and sphere are recomputed.
  24331. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24332. * @returns the current mesh
  24333. */
  24334. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24335. /** @hidden */
  24336. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24337. /**
  24338. * This function will subdivide the mesh into multiple submeshes
  24339. * @param count defines the expected number of submeshes
  24340. */
  24341. subdivide(count: number): void;
  24342. /**
  24343. * Copy a FloatArray into a specific associated vertex buffer
  24344. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24345. * - VertexBuffer.PositionKind
  24346. * - VertexBuffer.UVKind
  24347. * - VertexBuffer.UV2Kind
  24348. * - VertexBuffer.UV3Kind
  24349. * - VertexBuffer.UV4Kind
  24350. * - VertexBuffer.UV5Kind
  24351. * - VertexBuffer.UV6Kind
  24352. * - VertexBuffer.ColorKind
  24353. * - VertexBuffer.MatricesIndicesKind
  24354. * - VertexBuffer.MatricesIndicesExtraKind
  24355. * - VertexBuffer.MatricesWeightsKind
  24356. * - VertexBuffer.MatricesWeightsExtraKind
  24357. * @param data defines the data source
  24358. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24359. * @param stride defines the data stride size (can be null)
  24360. * @returns the current mesh
  24361. */
  24362. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24363. /**
  24364. * Flags an associated vertex buffer as updatable
  24365. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24366. * - VertexBuffer.PositionKind
  24367. * - VertexBuffer.UVKind
  24368. * - VertexBuffer.UV2Kind
  24369. * - VertexBuffer.UV3Kind
  24370. * - VertexBuffer.UV4Kind
  24371. * - VertexBuffer.UV5Kind
  24372. * - VertexBuffer.UV6Kind
  24373. * - VertexBuffer.ColorKind
  24374. * - VertexBuffer.MatricesIndicesKind
  24375. * - VertexBuffer.MatricesIndicesExtraKind
  24376. * - VertexBuffer.MatricesWeightsKind
  24377. * - VertexBuffer.MatricesWeightsExtraKind
  24378. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24379. */
  24380. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24381. /**
  24382. * Sets the mesh global Vertex Buffer
  24383. * @param buffer defines the buffer to use
  24384. * @returns the current mesh
  24385. */
  24386. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24387. /**
  24388. * Update a specific associated vertex buffer
  24389. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24390. * - VertexBuffer.PositionKind
  24391. * - VertexBuffer.UVKind
  24392. * - VertexBuffer.UV2Kind
  24393. * - VertexBuffer.UV3Kind
  24394. * - VertexBuffer.UV4Kind
  24395. * - VertexBuffer.UV5Kind
  24396. * - VertexBuffer.UV6Kind
  24397. * - VertexBuffer.ColorKind
  24398. * - VertexBuffer.MatricesIndicesKind
  24399. * - VertexBuffer.MatricesIndicesExtraKind
  24400. * - VertexBuffer.MatricesWeightsKind
  24401. * - VertexBuffer.MatricesWeightsExtraKind
  24402. * @param data defines the data source
  24403. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24404. * @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)
  24405. * @returns the current mesh
  24406. */
  24407. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24408. /**
  24409. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24410. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24411. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24412. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24413. * @returns the current mesh
  24414. */
  24415. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24416. /**
  24417. * Creates a un-shared specific occurence of the geometry for the mesh.
  24418. * @returns the current mesh
  24419. */
  24420. makeGeometryUnique(): Mesh;
  24421. /**
  24422. * Set the index buffer of this mesh
  24423. * @param indices defines the source data
  24424. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24425. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24426. * @returns the current mesh
  24427. */
  24428. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24429. /**
  24430. * Update the current index buffer
  24431. * @param indices defines the source data
  24432. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24433. * @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)
  24434. * @returns the current mesh
  24435. */
  24436. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24437. /**
  24438. * Invert the geometry to move from a right handed system to a left handed one.
  24439. * @returns the current mesh
  24440. */
  24441. toLeftHanded(): Mesh;
  24442. /** @hidden */
  24443. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24444. /** @hidden */
  24445. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24446. /**
  24447. * Registers for this mesh a javascript function called just before the rendering process
  24448. * @param func defines the function to call before rendering this mesh
  24449. * @returns the current mesh
  24450. */
  24451. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24452. /**
  24453. * Disposes a previously registered javascript function called before the rendering
  24454. * @param func defines the function to remove
  24455. * @returns the current mesh
  24456. */
  24457. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24458. /**
  24459. * Registers for this mesh a javascript function called just after the rendering is complete
  24460. * @param func defines the function to call after rendering this mesh
  24461. * @returns the current mesh
  24462. */
  24463. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24464. /**
  24465. * Disposes a previously registered javascript function called after the rendering.
  24466. * @param func defines the function to remove
  24467. * @returns the current mesh
  24468. */
  24469. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24470. /** @hidden */
  24471. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24472. /** @hidden */
  24473. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24474. /** @hidden */
  24475. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24476. /** @hidden */
  24477. _rebuild(): void;
  24478. /** @hidden */
  24479. _freeze(): void;
  24480. /** @hidden */
  24481. _unFreeze(): void;
  24482. /**
  24483. * 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
  24484. * @param subMesh defines the subMesh to render
  24485. * @param enableAlphaMode defines if alpha mode can be changed
  24486. * @returns the current mesh
  24487. */
  24488. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24489. private _onBeforeDraw;
  24490. /**
  24491. * Renormalize the mesh and patch it up if there are no weights
  24492. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24493. * However in the case of zero weights then we set just a single influence to 1.
  24494. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24495. */
  24496. cleanMatrixWeights(): void;
  24497. private normalizeSkinFourWeights;
  24498. private normalizeSkinWeightsAndExtra;
  24499. /**
  24500. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24501. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24502. * the user know there was an issue with importing the mesh
  24503. * @returns a validation object with skinned, valid and report string
  24504. */
  24505. validateSkinning(): {
  24506. skinned: boolean;
  24507. valid: boolean;
  24508. report: string;
  24509. };
  24510. /** @hidden */
  24511. _checkDelayState(): Mesh;
  24512. private _queueLoad;
  24513. /**
  24514. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24515. * A mesh is in the frustum if its bounding box intersects the frustum
  24516. * @param frustumPlanes defines the frustum to test
  24517. * @returns true if the mesh is in the frustum planes
  24518. */
  24519. isInFrustum(frustumPlanes: Plane[]): boolean;
  24520. /**
  24521. * Sets the mesh material by the material or multiMaterial `id` property
  24522. * @param id is a string identifying the material or the multiMaterial
  24523. * @returns the current mesh
  24524. */
  24525. setMaterialByID(id: string): Mesh;
  24526. /**
  24527. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24528. * @returns an array of IAnimatable
  24529. */
  24530. getAnimatables(): IAnimatable[];
  24531. /**
  24532. * Modifies the mesh geometry according to the passed transformation matrix.
  24533. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24534. * The mesh normals are modified using the same transformation.
  24535. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24536. * @param transform defines the transform matrix to use
  24537. * @see http://doc.babylonjs.com/resources/baking_transformations
  24538. * @returns the current mesh
  24539. */
  24540. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24541. /**
  24542. * Modifies the mesh geometry according to its own current World Matrix.
  24543. * The mesh World Matrix is then reset.
  24544. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24545. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24546. * @see http://doc.babylonjs.com/resources/baking_transformations
  24547. * @returns the current mesh
  24548. */
  24549. bakeCurrentTransformIntoVertices(): Mesh;
  24550. /** @hidden */
  24551. readonly _positions: Nullable<Vector3[]>;
  24552. /** @hidden */
  24553. _resetPointsArrayCache(): Mesh;
  24554. /** @hidden */
  24555. _generatePointsArray(): boolean;
  24556. /**
  24557. * Returns a new Mesh object generated from the current mesh properties.
  24558. * This method must not get confused with createInstance()
  24559. * @param name is a string, the name given to the new mesh
  24560. * @param newParent can be any Node object (default `null`)
  24561. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24562. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24563. * @returns a new mesh
  24564. */
  24565. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24566. /**
  24567. * Releases resources associated with this mesh.
  24568. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24569. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24570. */
  24571. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24572. /**
  24573. * Modifies the mesh geometry according to a displacement map.
  24574. * 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.
  24575. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24576. * @param url is a string, the URL from the image file is to be downloaded.
  24577. * @param minHeight is the lower limit of the displacement.
  24578. * @param maxHeight is the upper limit of the displacement.
  24579. * @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.
  24580. * @param uvOffset is an optional vector2 used to offset UV.
  24581. * @param uvScale is an optional vector2 used to scale UV.
  24582. * @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.
  24583. * @returns the Mesh.
  24584. */
  24585. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24586. /**
  24587. * Modifies the mesh geometry according to a displacementMap buffer.
  24588. * 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.
  24589. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24590. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24591. * @param heightMapWidth is the width of the buffer image.
  24592. * @param heightMapHeight is the height of the buffer image.
  24593. * @param minHeight is the lower limit of the displacement.
  24594. * @param maxHeight is the upper limit of the displacement.
  24595. * @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.
  24596. * @param uvOffset is an optional vector2 used to offset UV.
  24597. * @param uvScale is an optional vector2 used to scale UV.
  24598. * @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.
  24599. * @returns the Mesh.
  24600. */
  24601. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24602. /**
  24603. * Modify the mesh to get a flat shading rendering.
  24604. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24605. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24606. * @returns current mesh
  24607. */
  24608. convertToFlatShadedMesh(): Mesh;
  24609. /**
  24610. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24611. * In other words, more vertices, no more indices and a single bigger VBO.
  24612. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24613. * @returns current mesh
  24614. */
  24615. convertToUnIndexedMesh(): Mesh;
  24616. /**
  24617. * Inverses facet orientations.
  24618. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24619. * @param flipNormals will also inverts the normals
  24620. * @returns current mesh
  24621. */
  24622. flipFaces(flipNormals?: boolean): Mesh;
  24623. /**
  24624. * Increase the number of facets and hence vertices in a mesh
  24625. * Vertex normals are interpolated from existing vertex normals
  24626. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24627. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24628. */
  24629. increaseVertices(numberPerEdge: number): void;
  24630. /**
  24631. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24632. * This will undo any application of covertToFlatShadedMesh
  24633. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24634. */
  24635. forceSharedVertices(): void;
  24636. /** @hidden */
  24637. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24638. /** @hidden */
  24639. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24640. /**
  24641. * Creates a new InstancedMesh object from the mesh model.
  24642. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24643. * @param name defines the name of the new instance
  24644. * @returns a new InstancedMesh
  24645. */
  24646. createInstance(name: string): InstancedMesh;
  24647. /**
  24648. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24649. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24650. * @returns the current mesh
  24651. */
  24652. synchronizeInstances(): Mesh;
  24653. /**
  24654. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24655. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24656. * This should be used together with the simplification to avoid disappearing triangles.
  24657. * @param successCallback an optional success callback to be called after the optimization finished.
  24658. * @returns the current mesh
  24659. */
  24660. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24661. /**
  24662. * Serialize current mesh
  24663. * @param serializationObject defines the object which will receive the serialization data
  24664. */
  24665. serialize(serializationObject: any): void;
  24666. /** @hidden */
  24667. _syncGeometryWithMorphTargetManager(): void;
  24668. /** @hidden */
  24669. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24670. /**
  24671. * Returns a new Mesh object parsed from the source provided.
  24672. * @param parsedMesh is the source
  24673. * @param scene defines the hosting scene
  24674. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24675. * @returns a new Mesh
  24676. */
  24677. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24678. /**
  24679. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24680. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24681. * @param name defines the name of the mesh to create
  24682. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24683. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24684. * @param closePath creates a seam between the first and the last points of each path of the path array
  24685. * @param offset is taken in account only if the `pathArray` is containing a single path
  24686. * @param scene defines the hosting scene
  24687. * @param updatable defines if the mesh must be flagged as updatable
  24688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24689. * @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)
  24690. * @returns a new Mesh
  24691. */
  24692. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24693. /**
  24694. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24695. * @param name defines the name of the mesh to create
  24696. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24697. * @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
  24698. * @param scene defines the hosting scene
  24699. * @param updatable defines if the mesh must be flagged as updatable
  24700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24701. * @returns a new Mesh
  24702. */
  24703. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24704. /**
  24705. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24706. * @param name defines the name of the mesh to create
  24707. * @param size sets the size (float) of each box side (default 1)
  24708. * @param scene defines the hosting scene
  24709. * @param updatable defines if the mesh must be flagged as updatable
  24710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24711. * @returns a new Mesh
  24712. */
  24713. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24714. /**
  24715. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24716. * @param name defines the name of the mesh to create
  24717. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24718. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24719. * @param scene defines the hosting scene
  24720. * @param updatable defines if the mesh must be flagged as updatable
  24721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24722. * @returns a new Mesh
  24723. */
  24724. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24725. /**
  24726. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24727. * @param name defines the name of the mesh to create
  24728. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24729. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24730. * @param scene defines the hosting scene
  24731. * @returns a new Mesh
  24732. */
  24733. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24734. /**
  24735. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24736. * @param name defines the name of the mesh to create
  24737. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24738. * @param diameterTop set the top cap diameter (floats, default 1)
  24739. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24740. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24741. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24742. * @param scene defines the hosting scene
  24743. * @param updatable defines if the mesh must be flagged as updatable
  24744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24745. * @returns a new Mesh
  24746. */
  24747. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24748. /**
  24749. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24750. * @param name defines the name of the mesh to create
  24751. * @param diameter sets the diameter size (float) of the torus (default 1)
  24752. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24753. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24754. * @param scene defines the hosting scene
  24755. * @param updatable defines if the mesh must be flagged as updatable
  24756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24757. * @returns a new Mesh
  24758. */
  24759. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24760. /**
  24761. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24762. * @param name defines the name of the mesh to create
  24763. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24764. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24765. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24766. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24767. * @param p the number of windings on X axis (positive integers, default 2)
  24768. * @param q the number of windings on Y axis (positive integers, default 3)
  24769. * @param scene defines the hosting scene
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24772. * @returns a new Mesh
  24773. */
  24774. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24775. /**
  24776. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24777. * @param name defines the name of the mesh to create
  24778. * @param points is an array successive Vector3
  24779. * @param scene defines the hosting scene
  24780. * @param updatable defines if the mesh must be flagged as updatable
  24781. * @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).
  24782. * @returns a new Mesh
  24783. */
  24784. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24785. /**
  24786. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24787. * @param name defines the name of the mesh to create
  24788. * @param points is an array successive Vector3
  24789. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24790. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24791. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24792. * @param scene defines the hosting scene
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @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)
  24795. * @returns a new Mesh
  24796. */
  24797. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24798. /**
  24799. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24800. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24801. * 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.
  24802. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24803. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24804. * Remember you can only change the shape positions, not their number when updating a polygon.
  24805. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24806. * @param name defines the name of the mesh to create
  24807. * @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
  24808. * @param scene defines the hosting scene
  24809. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24810. * @param updatable defines if the mesh must be flagged as updatable
  24811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24812. * @param earcutInjection can be used to inject your own earcut reference
  24813. * @returns a new Mesh
  24814. */
  24815. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24816. /**
  24817. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24819. * @param name defines the name of the mesh to create
  24820. * @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
  24821. * @param depth defines the height of extrusion
  24822. * @param scene defines the hosting scene
  24823. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24824. * @param updatable defines if the mesh must be flagged as updatable
  24825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24826. * @param earcutInjection can be used to inject your own earcut reference
  24827. * @returns a new Mesh
  24828. */
  24829. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24830. /**
  24831. * Creates an extruded shape mesh.
  24832. * 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
  24833. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24834. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24835. * @param name defines the name of the mesh to create
  24836. * @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
  24837. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24838. * @param scale is the value to scale the shape
  24839. * @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
  24840. * @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
  24841. * @param scene defines the hosting scene
  24842. * @param updatable defines if the mesh must be flagged as updatable
  24843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24844. * @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)
  24845. * @returns a new Mesh
  24846. */
  24847. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24848. /**
  24849. * Creates an custom extruded shape mesh.
  24850. * The custom extrusion is a parametric shape.
  24851. * It has no predefined shape. Its final shape will depend on the input parameters.
  24852. * Please consider using the same method from the MeshBuilder class instead
  24853. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24854. * @param name defines the name of the mesh to create
  24855. * @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
  24856. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24857. * @param scaleFunction is a custom Javascript function called on each path point
  24858. * @param rotationFunction is a custom Javascript function called on each path point
  24859. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24860. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24861. * @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
  24862. * @param scene defines the hosting scene
  24863. * @param updatable defines if the mesh must be flagged as updatable
  24864. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24865. * @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)
  24866. * @returns a new Mesh
  24867. */
  24868. 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;
  24869. /**
  24870. * Creates lathe mesh.
  24871. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24872. * Please consider using the same method from the MeshBuilder class instead
  24873. * @param name defines the name of the mesh to create
  24874. * @param 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
  24875. * @param radius is the radius value of the lathe
  24876. * @param tessellation is the side number of the lathe.
  24877. * @param scene defines the hosting scene
  24878. * @param updatable defines if the mesh must be flagged as updatable
  24879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24880. * @returns a new Mesh
  24881. */
  24882. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24883. /**
  24884. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24885. * @param name defines the name of the mesh to create
  24886. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24887. * @param scene defines the hosting scene
  24888. * @param updatable defines if the mesh must be flagged as updatable
  24889. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24890. * @returns a new Mesh
  24891. */
  24892. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24893. /**
  24894. * Creates a ground mesh.
  24895. * Please consider using the same method from the MeshBuilder class instead
  24896. * @param name defines the name of the mesh to create
  24897. * @param width set the width of the ground
  24898. * @param height set the height of the ground
  24899. * @param subdivisions sets the number of subdivisions per side
  24900. * @param scene defines the hosting scene
  24901. * @param updatable defines if the mesh must be flagged as updatable
  24902. * @returns a new Mesh
  24903. */
  24904. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24905. /**
  24906. * Creates a tiled ground mesh.
  24907. * Please consider using the same method from the MeshBuilder class instead
  24908. * @param name defines the name of the mesh to create
  24909. * @param xmin set the ground minimum X coordinate
  24910. * @param zmin set the ground minimum Y coordinate
  24911. * @param xmax set the ground maximum X coordinate
  24912. * @param zmax set the ground maximum Z coordinate
  24913. * @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
  24914. * @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
  24915. * @param scene defines the hosting scene
  24916. * @param updatable defines if the mesh must be flagged as updatable
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24920. w: number;
  24921. h: number;
  24922. }, precision: {
  24923. w: number;
  24924. h: number;
  24925. }, scene: Scene, updatable?: boolean): Mesh;
  24926. /**
  24927. * Creates a ground mesh from a height map.
  24928. * Please consider using the same method from the MeshBuilder class instead
  24929. * @see http://doc.babylonjs.com/babylon101/height_map
  24930. * @param name defines the name of the mesh to create
  24931. * @param url sets the URL of the height map image resource
  24932. * @param width set the ground width size
  24933. * @param height set the ground height size
  24934. * @param subdivisions sets the number of subdivision per side
  24935. * @param minHeight is the minimum altitude on the ground
  24936. * @param maxHeight is the maximum altitude on the ground
  24937. * @param scene defines the hosting scene
  24938. * @param updatable defines if the mesh must be flagged as updatable
  24939. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24940. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24941. * @returns a new Mesh
  24942. */
  24943. 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;
  24944. /**
  24945. * Creates a tube mesh.
  24946. * The tube is a parametric shape.
  24947. * It has no predefined shape. Its final shape will depend on the input parameters.
  24948. * Please consider using the same method from the MeshBuilder class instead
  24949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24950. * @param name defines the name of the mesh to create
  24951. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24952. * @param radius sets the tube radius size
  24953. * @param tessellation is the number of sides on the tubular surface
  24954. * @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
  24955. * @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
  24956. * @param scene defines the hosting scene
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @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)
  24960. * @returns a new Mesh
  24961. */
  24962. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24963. (i: number, distance: number): number;
  24964. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24965. /**
  24966. * Creates a polyhedron mesh.
  24967. * Please consider using the same method from the MeshBuilder class instead.
  24968. * * 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
  24969. * * The parameter `size` (positive float, default 1) sets the polygon size
  24970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24971. * * 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`
  24972. * * 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
  24973. * * 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)`)
  24974. * * 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
  24975. * * 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
  24976. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24977. * * If you create a double-sided mesh, you can choose what parts of 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
  24978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24979. * @param name defines the name of the mesh to create
  24980. * @param options defines the options used to create the mesh
  24981. * @param scene defines the hosting scene
  24982. * @returns a new Mesh
  24983. */
  24984. static CreatePolyhedron(name: string, options: {
  24985. type?: number;
  24986. size?: number;
  24987. sizeX?: number;
  24988. sizeY?: number;
  24989. sizeZ?: number;
  24990. custom?: any;
  24991. faceUV?: Vector4[];
  24992. faceColors?: Color4[];
  24993. updatable?: boolean;
  24994. sideOrientation?: number;
  24995. }, scene: Scene): Mesh;
  24996. /**
  24997. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24998. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24999. * * 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`)
  25000. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25001. * * 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
  25002. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25003. * * If you create a double-sided mesh, you can choose what parts of 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
  25004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25005. * @param name defines the name of the mesh
  25006. * @param options defines the options used to create the mesh
  25007. * @param scene defines the hosting scene
  25008. * @returns a new Mesh
  25009. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25010. */
  25011. static CreateIcoSphere(name: string, options: {
  25012. radius?: number;
  25013. flat?: boolean;
  25014. subdivisions?: number;
  25015. sideOrientation?: number;
  25016. updatable?: boolean;
  25017. }, scene: Scene): Mesh;
  25018. /**
  25019. * Creates a decal mesh.
  25020. * Please consider using the same method from the MeshBuilder class instead.
  25021. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25022. * @param name defines the name of the mesh
  25023. * @param sourceMesh defines the mesh receiving the decal
  25024. * @param position sets the position of the decal in world coordinates
  25025. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25026. * @param size sets the decal scaling
  25027. * @param angle sets the angle to rotate the decal
  25028. * @returns a new Mesh
  25029. */
  25030. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25031. /**
  25032. * Prepare internal position array for software CPU skinning
  25033. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25034. */
  25035. setPositionsForCPUSkinning(): Float32Array;
  25036. /**
  25037. * Prepare internal normal array for software CPU skinning
  25038. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25039. */
  25040. setNormalsForCPUSkinning(): Float32Array;
  25041. /**
  25042. * Updates the vertex buffer by applying transformation from the bones
  25043. * @param skeleton defines the skeleton to apply to current mesh
  25044. * @returns the current mesh
  25045. */
  25046. applySkeleton(skeleton: Skeleton): Mesh;
  25047. /**
  25048. * 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
  25049. * @param meshes defines the list of meshes to scan
  25050. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25051. */
  25052. static MinMax(meshes: AbstractMesh[]): {
  25053. min: Vector3;
  25054. max: Vector3;
  25055. };
  25056. /**
  25057. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25058. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25059. * @returns a vector3
  25060. */
  25061. static Center(meshesOrMinMaxVector: {
  25062. min: Vector3;
  25063. max: Vector3;
  25064. } | AbstractMesh[]): Vector3;
  25065. /**
  25066. * Merge the array of meshes into a single mesh for performance reasons.
  25067. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25068. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25069. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25070. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25071. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25072. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25073. * @returns a new mesh
  25074. */
  25075. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25076. /** @hidden */
  25077. addInstance(instance: InstancedMesh): void;
  25078. /** @hidden */
  25079. removeInstance(instance: InstancedMesh): void;
  25080. }
  25081. }
  25082. declare module "babylonjs/Cameras/camera" {
  25083. import { SmartArray } from "babylonjs/Misc/smartArray";
  25084. import { Observable } from "babylonjs/Misc/observable";
  25085. import { Nullable } from "babylonjs/types";
  25086. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25087. import { Scene } from "babylonjs/scene";
  25088. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25089. import { Node } from "babylonjs/node";
  25090. import { Mesh } from "babylonjs/Meshes/mesh";
  25091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25092. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25093. import { Viewport } from "babylonjs/Maths/math.viewport";
  25094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25097. import { Ray } from "babylonjs/Culling/ray";
  25098. /**
  25099. * This is the base class of all the camera used in the application.
  25100. * @see http://doc.babylonjs.com/features/cameras
  25101. */
  25102. export class Camera extends Node {
  25103. /** @hidden */
  25104. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25105. /**
  25106. * This is the default projection mode used by the cameras.
  25107. * It helps recreating a feeling of perspective and better appreciate depth.
  25108. * This is the best way to simulate real life cameras.
  25109. */
  25110. static readonly PERSPECTIVE_CAMERA: number;
  25111. /**
  25112. * This helps creating camera with an orthographic mode.
  25113. * 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.
  25114. */
  25115. static readonly ORTHOGRAPHIC_CAMERA: number;
  25116. /**
  25117. * This is the default FOV mode for perspective cameras.
  25118. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25119. */
  25120. static readonly FOVMODE_VERTICAL_FIXED: number;
  25121. /**
  25122. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25123. */
  25124. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25125. /**
  25126. * This specifies ther is no need for a camera rig.
  25127. * Basically only one eye is rendered corresponding to the camera.
  25128. */
  25129. static readonly RIG_MODE_NONE: number;
  25130. /**
  25131. * Simulates a camera Rig with one blue eye and one red eye.
  25132. * This can be use with 3d blue and red glasses.
  25133. */
  25134. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25135. /**
  25136. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25137. */
  25138. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25139. /**
  25140. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25141. */
  25142. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25143. /**
  25144. * Defines that both eyes of the camera will be rendered over under each other.
  25145. */
  25146. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25147. /**
  25148. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25149. */
  25150. static readonly RIG_MODE_VR: number;
  25151. /**
  25152. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25153. */
  25154. static readonly RIG_MODE_WEBVR: number;
  25155. /**
  25156. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25157. */
  25158. static readonly RIG_MODE_CUSTOM: number;
  25159. /**
  25160. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25161. */
  25162. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25163. /**
  25164. * Define the input manager associated with the camera.
  25165. */
  25166. inputs: CameraInputsManager<Camera>;
  25167. /** @hidden */
  25168. _position: Vector3;
  25169. /**
  25170. * Define the current local position of the camera in the scene
  25171. */
  25172. position: Vector3;
  25173. /**
  25174. * The vector the camera should consider as up.
  25175. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25176. */
  25177. upVector: Vector3;
  25178. /**
  25179. * Define the current limit on the left side for an orthographic camera
  25180. * In scene unit
  25181. */
  25182. orthoLeft: Nullable<number>;
  25183. /**
  25184. * Define the current limit on the right side for an orthographic camera
  25185. * In scene unit
  25186. */
  25187. orthoRight: Nullable<number>;
  25188. /**
  25189. * Define the current limit on the bottom side for an orthographic camera
  25190. * In scene unit
  25191. */
  25192. orthoBottom: Nullable<number>;
  25193. /**
  25194. * Define the current limit on the top side for an orthographic camera
  25195. * In scene unit
  25196. */
  25197. orthoTop: Nullable<number>;
  25198. /**
  25199. * Field Of View is set in Radians. (default is 0.8)
  25200. */
  25201. fov: number;
  25202. /**
  25203. * Define the minimum distance the camera can see from.
  25204. * This is important to note that the depth buffer are not infinite and the closer it starts
  25205. * the more your scene might encounter depth fighting issue.
  25206. */
  25207. minZ: number;
  25208. /**
  25209. * Define the maximum distance the camera can see to.
  25210. * This is important to note that the depth buffer are not infinite and the further it end
  25211. * the more your scene might encounter depth fighting issue.
  25212. */
  25213. maxZ: number;
  25214. /**
  25215. * Define the default inertia of the camera.
  25216. * This helps giving a smooth feeling to the camera movement.
  25217. */
  25218. inertia: number;
  25219. /**
  25220. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25221. */
  25222. mode: number;
  25223. /**
  25224. * Define wether the camera is intermediate.
  25225. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25226. */
  25227. isIntermediate: boolean;
  25228. /**
  25229. * Define the viewport of the camera.
  25230. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25231. */
  25232. viewport: Viewport;
  25233. /**
  25234. * Restricts the camera to viewing objects with the same layerMask.
  25235. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25236. */
  25237. layerMask: number;
  25238. /**
  25239. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25240. */
  25241. fovMode: number;
  25242. /**
  25243. * Rig mode of the camera.
  25244. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25245. * This is normally controlled byt the camera themselves as internal use.
  25246. */
  25247. cameraRigMode: number;
  25248. /**
  25249. * Defines the distance between both "eyes" in case of a RIG
  25250. */
  25251. interaxialDistance: number;
  25252. /**
  25253. * Defines if stereoscopic rendering is done side by side or over under.
  25254. */
  25255. isStereoscopicSideBySide: boolean;
  25256. /**
  25257. * 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
  25258. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25259. * else in the scene. (Eg. security camera)
  25260. *
  25261. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25262. */
  25263. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25264. /**
  25265. * When set, the camera will render to this render target instead of the default canvas
  25266. *
  25267. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25268. */
  25269. outputRenderTarget: Nullable<RenderTargetTexture>;
  25270. /**
  25271. * Observable triggered when the camera view matrix has changed.
  25272. */
  25273. onViewMatrixChangedObservable: Observable<Camera>;
  25274. /**
  25275. * Observable triggered when the camera Projection matrix has changed.
  25276. */
  25277. onProjectionMatrixChangedObservable: Observable<Camera>;
  25278. /**
  25279. * Observable triggered when the inputs have been processed.
  25280. */
  25281. onAfterCheckInputsObservable: Observable<Camera>;
  25282. /**
  25283. * Observable triggered when reset has been called and applied to the camera.
  25284. */
  25285. onRestoreStateObservable: Observable<Camera>;
  25286. /** @hidden */
  25287. _cameraRigParams: any;
  25288. /** @hidden */
  25289. _rigCameras: Camera[];
  25290. /** @hidden */
  25291. _rigPostProcess: Nullable<PostProcess>;
  25292. protected _webvrViewMatrix: Matrix;
  25293. /** @hidden */
  25294. _skipRendering: boolean;
  25295. /** @hidden */
  25296. _projectionMatrix: Matrix;
  25297. /** @hidden */
  25298. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25299. /** @hidden */
  25300. _activeMeshes: SmartArray<AbstractMesh>;
  25301. protected _globalPosition: Vector3;
  25302. /** @hidden */
  25303. _computedViewMatrix: Matrix;
  25304. private _doNotComputeProjectionMatrix;
  25305. private _transformMatrix;
  25306. private _frustumPlanes;
  25307. private _refreshFrustumPlanes;
  25308. private _storedFov;
  25309. private _stateStored;
  25310. /**
  25311. * Instantiates a new camera object.
  25312. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25313. * @see http://doc.babylonjs.com/features/cameras
  25314. * @param name Defines the name of the camera in the scene
  25315. * @param position Defines the position of the camera
  25316. * @param scene Defines the scene the camera belongs too
  25317. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25318. */
  25319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25320. /**
  25321. * Store current camera state (fov, position, etc..)
  25322. * @returns the camera
  25323. */
  25324. storeState(): Camera;
  25325. /**
  25326. * Restores the camera state values if it has been stored. You must call storeState() first
  25327. */
  25328. protected _restoreStateValues(): boolean;
  25329. /**
  25330. * Restored camera state. You must call storeState() first.
  25331. * @returns true if restored and false otherwise
  25332. */
  25333. restoreState(): boolean;
  25334. /**
  25335. * Gets the class name of the camera.
  25336. * @returns the class name
  25337. */
  25338. getClassName(): string;
  25339. /** @hidden */
  25340. readonly _isCamera: boolean;
  25341. /**
  25342. * Gets a string representation of the camera useful for debug purpose.
  25343. * @param fullDetails Defines that a more verboe level of logging is required
  25344. * @returns the string representation
  25345. */
  25346. toString(fullDetails?: boolean): string;
  25347. /**
  25348. * Gets the current world space position of the camera.
  25349. */
  25350. readonly globalPosition: Vector3;
  25351. /**
  25352. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25353. * @returns the active meshe list
  25354. */
  25355. getActiveMeshes(): SmartArray<AbstractMesh>;
  25356. /**
  25357. * Check wether a mesh is part of the current active mesh list of the camera
  25358. * @param mesh Defines the mesh to check
  25359. * @returns true if active, false otherwise
  25360. */
  25361. isActiveMesh(mesh: Mesh): boolean;
  25362. /**
  25363. * Is this camera ready to be used/rendered
  25364. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25365. * @return true if the camera is ready
  25366. */
  25367. isReady(completeCheck?: boolean): boolean;
  25368. /** @hidden */
  25369. _initCache(): void;
  25370. /** @hidden */
  25371. _updateCache(ignoreParentClass?: boolean): void;
  25372. /** @hidden */
  25373. _isSynchronized(): boolean;
  25374. /** @hidden */
  25375. _isSynchronizedViewMatrix(): boolean;
  25376. /** @hidden */
  25377. _isSynchronizedProjectionMatrix(): boolean;
  25378. /**
  25379. * Attach the input controls to a specific dom element to get the input from.
  25380. * @param element Defines the element the controls should be listened from
  25381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25382. */
  25383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25384. /**
  25385. * Detach the current controls from the specified dom element.
  25386. * @param element Defines the element to stop listening the inputs from
  25387. */
  25388. detachControl(element: HTMLElement): void;
  25389. /**
  25390. * Update the camera state according to the different inputs gathered during the frame.
  25391. */
  25392. update(): void;
  25393. /** @hidden */
  25394. _checkInputs(): void;
  25395. /** @hidden */
  25396. readonly rigCameras: Camera[];
  25397. /**
  25398. * Gets the post process used by the rig cameras
  25399. */
  25400. readonly rigPostProcess: Nullable<PostProcess>;
  25401. /**
  25402. * Internal, gets the first post proces.
  25403. * @returns the first post process to be run on this camera.
  25404. */
  25405. _getFirstPostProcess(): Nullable<PostProcess>;
  25406. private _cascadePostProcessesToRigCams;
  25407. /**
  25408. * Attach a post process to the camera.
  25409. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25410. * @param postProcess The post process to attach to the camera
  25411. * @param insertAt The position of the post process in case several of them are in use in the scene
  25412. * @returns the position the post process has been inserted at
  25413. */
  25414. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25415. /**
  25416. * Detach a post process to the camera.
  25417. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25418. * @param postProcess The post process to detach from the camera
  25419. */
  25420. detachPostProcess(postProcess: PostProcess): void;
  25421. /**
  25422. * Gets the current world matrix of the camera
  25423. */
  25424. getWorldMatrix(): Matrix;
  25425. /** @hidden */
  25426. _getViewMatrix(): Matrix;
  25427. /**
  25428. * Gets the current view matrix of the camera.
  25429. * @param force forces the camera to recompute the matrix without looking at the cached state
  25430. * @returns the view matrix
  25431. */
  25432. getViewMatrix(force?: boolean): Matrix;
  25433. /**
  25434. * Freeze the projection matrix.
  25435. * It will prevent the cache check of the camera projection compute and can speed up perf
  25436. * if no parameter of the camera are meant to change
  25437. * @param projection Defines manually a projection if necessary
  25438. */
  25439. freezeProjectionMatrix(projection?: Matrix): void;
  25440. /**
  25441. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25442. */
  25443. unfreezeProjectionMatrix(): void;
  25444. /**
  25445. * Gets the current projection matrix of the camera.
  25446. * @param force forces the camera to recompute the matrix without looking at the cached state
  25447. * @returns the projection matrix
  25448. */
  25449. getProjectionMatrix(force?: boolean): Matrix;
  25450. /**
  25451. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25452. * @returns a Matrix
  25453. */
  25454. getTransformationMatrix(): Matrix;
  25455. private _updateFrustumPlanes;
  25456. /**
  25457. * Checks if a cullable object (mesh...) is in the camera frustum
  25458. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25459. * @param target The object to check
  25460. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25461. * @returns true if the object is in frustum otherwise false
  25462. */
  25463. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25464. /**
  25465. * Checks if a cullable object (mesh...) is in the camera frustum
  25466. * Unlike isInFrustum this cheks the full bounding box
  25467. * @param target The object to check
  25468. * @returns true if the object is in frustum otherwise false
  25469. */
  25470. isCompletelyInFrustum(target: ICullable): boolean;
  25471. /**
  25472. * Gets a ray in the forward direction from the camera.
  25473. * @param length Defines the length of the ray to create
  25474. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25475. * @param origin Defines the start point of the ray which defaults to the camera position
  25476. * @returns the forward ray
  25477. */
  25478. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25479. /**
  25480. * Releases resources associated with this node.
  25481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25483. */
  25484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25485. /** @hidden */
  25486. _isLeftCamera: boolean;
  25487. /**
  25488. * Gets the left camera of a rig setup in case of Rigged Camera
  25489. */
  25490. readonly isLeftCamera: boolean;
  25491. /** @hidden */
  25492. _isRightCamera: boolean;
  25493. /**
  25494. * Gets the right camera of a rig setup in case of Rigged Camera
  25495. */
  25496. readonly isRightCamera: boolean;
  25497. /**
  25498. * Gets the left camera of a rig setup in case of Rigged Camera
  25499. */
  25500. readonly leftCamera: Nullable<FreeCamera>;
  25501. /**
  25502. * Gets the right camera of a rig setup in case of Rigged Camera
  25503. */
  25504. readonly rightCamera: Nullable<FreeCamera>;
  25505. /**
  25506. * Gets the left camera target of a rig setup in case of Rigged Camera
  25507. * @returns the target position
  25508. */
  25509. getLeftTarget(): Nullable<Vector3>;
  25510. /**
  25511. * Gets the right camera target of a rig setup in case of Rigged Camera
  25512. * @returns the target position
  25513. */
  25514. getRightTarget(): Nullable<Vector3>;
  25515. /**
  25516. * @hidden
  25517. */
  25518. setCameraRigMode(mode: number, rigParams: any): void;
  25519. /** @hidden */
  25520. static _setStereoscopicRigMode(camera: Camera): void;
  25521. /** @hidden */
  25522. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25523. /** @hidden */
  25524. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25525. /** @hidden */
  25526. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25527. /** @hidden */
  25528. _getVRProjectionMatrix(): Matrix;
  25529. protected _updateCameraRotationMatrix(): void;
  25530. protected _updateWebVRCameraRotationMatrix(): void;
  25531. /**
  25532. * This function MUST be overwritten by the different WebVR cameras available.
  25533. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25534. * @hidden
  25535. */
  25536. _getWebVRProjectionMatrix(): Matrix;
  25537. /**
  25538. * This function MUST be overwritten by the different WebVR cameras available.
  25539. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25540. * @hidden
  25541. */
  25542. _getWebVRViewMatrix(): Matrix;
  25543. /** @hidden */
  25544. setCameraRigParameter(name: string, value: any): void;
  25545. /**
  25546. * needs to be overridden by children so sub has required properties to be copied
  25547. * @hidden
  25548. */
  25549. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25550. /**
  25551. * May need to be overridden by children
  25552. * @hidden
  25553. */
  25554. _updateRigCameras(): void;
  25555. /** @hidden */
  25556. _setupInputs(): void;
  25557. /**
  25558. * Serialiaze the camera setup to a json represention
  25559. * @returns the JSON representation
  25560. */
  25561. serialize(): any;
  25562. /**
  25563. * Clones the current camera.
  25564. * @param name The cloned camera name
  25565. * @returns the cloned camera
  25566. */
  25567. clone(name: string): Camera;
  25568. /**
  25569. * Gets the direction of the camera relative to a given local axis.
  25570. * @param localAxis Defines the reference axis to provide a relative direction.
  25571. * @return the direction
  25572. */
  25573. getDirection(localAxis: Vector3): Vector3;
  25574. /**
  25575. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25576. * @param localAxis Defines the reference axis to provide a relative direction.
  25577. * @param result Defines the vector to store the result in
  25578. */
  25579. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25580. /**
  25581. * Gets a camera constructor for a given camera type
  25582. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25583. * @param name The name of the camera the result will be able to instantiate
  25584. * @param scene The scene the result will construct the camera in
  25585. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25586. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25587. * @returns a factory method to construc the camera
  25588. */
  25589. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25590. /**
  25591. * Compute the world matrix of the camera.
  25592. * @returns the camera workd matrix
  25593. */
  25594. computeWorldMatrix(): Matrix;
  25595. /**
  25596. * Parse a JSON and creates the camera from the parsed information
  25597. * @param parsedCamera The JSON to parse
  25598. * @param scene The scene to instantiate the camera in
  25599. * @returns the newly constructed camera
  25600. */
  25601. static Parse(parsedCamera: any, scene: Scene): Camera;
  25602. }
  25603. }
  25604. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25605. import { Nullable } from "babylonjs/types";
  25606. import { Scene } from "babylonjs/scene";
  25607. import { Vector4 } from "babylonjs/Maths/math.vector";
  25608. import { Mesh } from "babylonjs/Meshes/mesh";
  25609. /**
  25610. * Class containing static functions to help procedurally build meshes
  25611. */
  25612. export class DiscBuilder {
  25613. /**
  25614. * Creates a plane polygonal mesh. By default, this is a disc
  25615. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25616. * * 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
  25617. * * 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
  25618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25621. * @param name defines the name of the mesh
  25622. * @param options defines the options used to create the mesh
  25623. * @param scene defines the hosting scene
  25624. * @returns the plane polygonal mesh
  25625. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25626. */
  25627. static CreateDisc(name: string, options: {
  25628. radius?: number;
  25629. tessellation?: number;
  25630. arc?: number;
  25631. updatable?: boolean;
  25632. sideOrientation?: number;
  25633. frontUVs?: Vector4;
  25634. backUVs?: Vector4;
  25635. }, scene?: Nullable<Scene>): Mesh;
  25636. }
  25637. }
  25638. declare module "babylonjs/Particles/solidParticleSystem" {
  25639. import { Vector3 } from "babylonjs/Maths/math.vector";
  25640. import { Mesh } from "babylonjs/Meshes/mesh";
  25641. import { Scene, IDisposable } from "babylonjs/scene";
  25642. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25643. /**
  25644. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25645. *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.
  25646. * The SPS is also a particle system. It provides some methods to manage the particles.
  25647. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25648. *
  25649. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25650. */
  25651. export class SolidParticleSystem implements IDisposable {
  25652. /**
  25653. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25654. * Example : var p = SPS.particles[i];
  25655. */
  25656. particles: SolidParticle[];
  25657. /**
  25658. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25659. */
  25660. nbParticles: number;
  25661. /**
  25662. * If the particles must ever face the camera (default false). Useful for planar particles.
  25663. */
  25664. billboard: boolean;
  25665. /**
  25666. * Recompute normals when adding a shape
  25667. */
  25668. recomputeNormals: boolean;
  25669. /**
  25670. * This a counter ofr your own usage. It's not set by any SPS functions.
  25671. */
  25672. counter: number;
  25673. /**
  25674. * The SPS name. This name is also given to the underlying mesh.
  25675. */
  25676. name: string;
  25677. /**
  25678. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25679. */
  25680. mesh: Mesh;
  25681. /**
  25682. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25683. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25684. */
  25685. vars: any;
  25686. /**
  25687. * This array is populated when the SPS is set as 'pickable'.
  25688. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25689. * Each element of this array is an object `{idx: int, faceId: int}`.
  25690. * `idx` is the picked particle index in the `SPS.particles` array
  25691. * `faceId` is the picked face index counted within this particle.
  25692. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25693. */
  25694. pickedParticles: {
  25695. idx: number;
  25696. faceId: number;
  25697. }[];
  25698. /**
  25699. * This array is populated when `enableDepthSort` is set to true.
  25700. * Each element of this array is an instance of the class DepthSortedParticle.
  25701. */
  25702. depthSortedParticles: DepthSortedParticle[];
  25703. /**
  25704. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25705. * @hidden
  25706. */
  25707. _bSphereOnly: boolean;
  25708. /**
  25709. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25710. * @hidden
  25711. */
  25712. _bSphereRadiusFactor: number;
  25713. private _scene;
  25714. private _positions;
  25715. private _indices;
  25716. private _normals;
  25717. private _colors;
  25718. private _uvs;
  25719. private _indices32;
  25720. private _positions32;
  25721. private _normals32;
  25722. private _fixedNormal32;
  25723. private _colors32;
  25724. private _uvs32;
  25725. private _index;
  25726. private _updatable;
  25727. private _pickable;
  25728. private _isVisibilityBoxLocked;
  25729. private _alwaysVisible;
  25730. private _depthSort;
  25731. private _shapeCounter;
  25732. private _copy;
  25733. private _color;
  25734. private _computeParticleColor;
  25735. private _computeParticleTexture;
  25736. private _computeParticleRotation;
  25737. private _computeParticleVertex;
  25738. private _computeBoundingBox;
  25739. private _depthSortParticles;
  25740. private _camera;
  25741. private _mustUnrotateFixedNormals;
  25742. private _particlesIntersect;
  25743. private _needs32Bits;
  25744. /**
  25745. * Creates a SPS (Solid Particle System) object.
  25746. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25747. * @param scene (Scene) is the scene in which the SPS is added.
  25748. * @param options defines the options of the sps e.g.
  25749. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25750. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25751. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25752. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25753. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25754. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25755. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25756. */
  25757. constructor(name: string, scene: Scene, options?: {
  25758. updatable?: boolean;
  25759. isPickable?: boolean;
  25760. enableDepthSort?: boolean;
  25761. particleIntersection?: boolean;
  25762. boundingSphereOnly?: boolean;
  25763. bSphereRadiusFactor?: number;
  25764. });
  25765. /**
  25766. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25767. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25768. * @returns the created mesh
  25769. */
  25770. buildMesh(): Mesh;
  25771. /**
  25772. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25773. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25774. * Thus the particles generated from `digest()` have their property `position` set yet.
  25775. * @param mesh ( Mesh ) is the mesh to be digested
  25776. * @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
  25777. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25778. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25779. * @returns the current SPS
  25780. */
  25781. digest(mesh: Mesh, options?: {
  25782. facetNb?: number;
  25783. number?: number;
  25784. delta?: number;
  25785. }): SolidParticleSystem;
  25786. private _unrotateFixedNormals;
  25787. private _resetCopy;
  25788. private _meshBuilder;
  25789. private _posToShape;
  25790. private _uvsToShapeUV;
  25791. private _addParticle;
  25792. /**
  25793. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25794. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25795. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25796. * @param nb (positive integer) the number of particles to be created from this model
  25797. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25798. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25799. * @returns the number of shapes in the system
  25800. */
  25801. addShape(mesh: Mesh, nb: number, options?: {
  25802. positionFunction?: any;
  25803. vertexFunction?: any;
  25804. }): number;
  25805. private _rebuildParticle;
  25806. /**
  25807. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25808. * @returns the SPS.
  25809. */
  25810. rebuildMesh(): SolidParticleSystem;
  25811. /**
  25812. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25813. * This method calls `updateParticle()` for each particle of the SPS.
  25814. * For an animated SPS, it is usually called within the render loop.
  25815. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25816. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25817. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25818. * @returns the SPS.
  25819. */
  25820. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25821. /**
  25822. * Disposes the SPS.
  25823. */
  25824. dispose(): void;
  25825. /**
  25826. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25827. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25828. * @returns the SPS.
  25829. */
  25830. refreshVisibleSize(): SolidParticleSystem;
  25831. /**
  25832. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25833. * @param size the size (float) of the visibility box
  25834. * note : this doesn't lock the SPS mesh bounding box.
  25835. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25836. */
  25837. setVisibilityBox(size: number): void;
  25838. /**
  25839. * Gets whether the SPS as always visible or not
  25840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25841. */
  25842. /**
  25843. * Sets the SPS as always visible or not
  25844. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25845. */
  25846. isAlwaysVisible: boolean;
  25847. /**
  25848. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25849. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25850. */
  25851. /**
  25852. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25853. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25854. */
  25855. isVisibilityBoxLocked: boolean;
  25856. /**
  25857. * Tells to `setParticles()` to compute the particle rotations or not.
  25858. * Default value : true. The SPS is faster when it's set to false.
  25859. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25860. */
  25861. /**
  25862. * Gets if `setParticles()` computes the particle rotations or not.
  25863. * Default value : true. The SPS is faster when it's set to false.
  25864. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25865. */
  25866. computeParticleRotation: boolean;
  25867. /**
  25868. * Tells to `setParticles()` to compute the particle colors or not.
  25869. * Default value : true. The SPS is faster when it's set to false.
  25870. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25871. */
  25872. /**
  25873. * Gets if `setParticles()` computes the particle colors or not.
  25874. * Default value : true. The SPS is faster when it's set to false.
  25875. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25876. */
  25877. computeParticleColor: boolean;
  25878. /**
  25879. * Gets if `setParticles()` computes the particle textures or not.
  25880. * Default value : true. The SPS is faster when it's set to false.
  25881. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25882. */
  25883. computeParticleTexture: boolean;
  25884. /**
  25885. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25886. * Default value : false. The SPS is faster when it's set to false.
  25887. * Note : the particle custom vertex positions aren't stored values.
  25888. */
  25889. /**
  25890. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25891. * Default value : false. The SPS is faster when it's set to false.
  25892. * Note : the particle custom vertex positions aren't stored values.
  25893. */
  25894. computeParticleVertex: boolean;
  25895. /**
  25896. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25897. */
  25898. /**
  25899. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25900. */
  25901. computeBoundingBox: boolean;
  25902. /**
  25903. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25904. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25905. * Default : `true`
  25906. */
  25907. /**
  25908. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25909. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25910. * Default : `true`
  25911. */
  25912. depthSortParticles: boolean;
  25913. /**
  25914. * This function does nothing. It may be overwritten to set all the particle first values.
  25915. * The SPS doesn't call this function, you may have to call it by your own.
  25916. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25917. */
  25918. initParticles(): void;
  25919. /**
  25920. * This function does nothing. It may be overwritten to recycle a particle.
  25921. * The SPS doesn't call this function, you may have to call it by your own.
  25922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25923. * @param particle The particle to recycle
  25924. * @returns the recycled particle
  25925. */
  25926. recycleParticle(particle: SolidParticle): SolidParticle;
  25927. /**
  25928. * Updates a particle : this function should be overwritten by the user.
  25929. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25930. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25931. * @example : just set a particle position or velocity and recycle conditions
  25932. * @param particle The particle to update
  25933. * @returns the updated particle
  25934. */
  25935. updateParticle(particle: SolidParticle): SolidParticle;
  25936. /**
  25937. * Updates a vertex of a particle : it can be overwritten by the user.
  25938. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25939. * @param particle the current particle
  25940. * @param vertex the current index of the current particle
  25941. * @param pt the index of the current vertex in the particle shape
  25942. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25943. * @example : just set a vertex particle position
  25944. * @returns the updated vertex
  25945. */
  25946. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25947. /**
  25948. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25949. * This does nothing and may be overwritten by the user.
  25950. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25951. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25952. * @param update the boolean update value actually passed to setParticles()
  25953. */
  25954. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25955. /**
  25956. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25957. * This will be passed three parameters.
  25958. * This does nothing and may be overwritten by the user.
  25959. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25960. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25961. * @param update the boolean update value actually passed to setParticles()
  25962. */
  25963. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25964. }
  25965. }
  25966. declare module "babylonjs/Particles/solidParticle" {
  25967. import { Nullable } from "babylonjs/types";
  25968. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25969. import { Color4 } from "babylonjs/Maths/math.color";
  25970. import { Mesh } from "babylonjs/Meshes/mesh";
  25971. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25972. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25973. import { Plane } from "babylonjs/Maths/math.plane";
  25974. /**
  25975. * Represents one particle of a solid particle system.
  25976. */
  25977. export class SolidParticle {
  25978. /**
  25979. * particle global index
  25980. */
  25981. idx: number;
  25982. /**
  25983. * The color of the particle
  25984. */
  25985. color: Nullable<Color4>;
  25986. /**
  25987. * The world space position of the particle.
  25988. */
  25989. position: Vector3;
  25990. /**
  25991. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25992. */
  25993. rotation: Vector3;
  25994. /**
  25995. * The world space rotation quaternion of the particle.
  25996. */
  25997. rotationQuaternion: Nullable<Quaternion>;
  25998. /**
  25999. * The scaling of the particle.
  26000. */
  26001. scaling: Vector3;
  26002. /**
  26003. * The uvs of the particle.
  26004. */
  26005. uvs: Vector4;
  26006. /**
  26007. * The current speed of the particle.
  26008. */
  26009. velocity: Vector3;
  26010. /**
  26011. * The pivot point in the particle local space.
  26012. */
  26013. pivot: Vector3;
  26014. /**
  26015. * Must the particle be translated from its pivot point in its local space ?
  26016. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26017. * Default : false
  26018. */
  26019. translateFromPivot: boolean;
  26020. /**
  26021. * Is the particle active or not ?
  26022. */
  26023. alive: boolean;
  26024. /**
  26025. * Is the particle visible or not ?
  26026. */
  26027. isVisible: boolean;
  26028. /**
  26029. * Index of this particle in the global "positions" array (Internal use)
  26030. * @hidden
  26031. */
  26032. _pos: number;
  26033. /**
  26034. * @hidden Index of this particle in the global "indices" array (Internal use)
  26035. */
  26036. _ind: number;
  26037. /**
  26038. * @hidden ModelShape of this particle (Internal use)
  26039. */
  26040. _model: ModelShape;
  26041. /**
  26042. * ModelShape id of this particle
  26043. */
  26044. shapeId: number;
  26045. /**
  26046. * Index of the particle in its shape id (Internal use)
  26047. */
  26048. idxInShape: number;
  26049. /**
  26050. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26051. */
  26052. _modelBoundingInfo: BoundingInfo;
  26053. /**
  26054. * @hidden Particle BoundingInfo object (Internal use)
  26055. */
  26056. _boundingInfo: BoundingInfo;
  26057. /**
  26058. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26059. */
  26060. _sps: SolidParticleSystem;
  26061. /**
  26062. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26063. */
  26064. _stillInvisible: boolean;
  26065. /**
  26066. * @hidden Last computed particle rotation matrix
  26067. */
  26068. _rotationMatrix: number[];
  26069. /**
  26070. * Parent particle Id, if any.
  26071. * Default null.
  26072. */
  26073. parentId: Nullable<number>;
  26074. /**
  26075. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26076. * The possible values are :
  26077. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26078. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26079. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26080. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26081. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26082. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26083. * */
  26084. cullingStrategy: number;
  26085. /**
  26086. * @hidden Internal global position in the SPS.
  26087. */
  26088. _globalPosition: Vector3;
  26089. /**
  26090. * Creates a Solid Particle object.
  26091. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26092. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26093. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26094. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26095. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26096. * @param shapeId (integer) is the model shape identifier in the SPS.
  26097. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26098. * @param sps defines the sps it is associated to
  26099. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26100. */
  26101. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26102. /**
  26103. * Legacy support, changed scale to scaling
  26104. */
  26105. /**
  26106. * Legacy support, changed scale to scaling
  26107. */
  26108. scale: Vector3;
  26109. /**
  26110. * Legacy support, changed quaternion to rotationQuaternion
  26111. */
  26112. /**
  26113. * Legacy support, changed quaternion to rotationQuaternion
  26114. */
  26115. quaternion: Nullable<Quaternion>;
  26116. /**
  26117. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26118. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26119. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26120. * @returns true if it intersects
  26121. */
  26122. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26123. /**
  26124. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26125. * A particle is in the frustum if its bounding box intersects the frustum
  26126. * @param frustumPlanes defines the frustum to test
  26127. * @returns true if the particle is in the frustum planes
  26128. */
  26129. isInFrustum(frustumPlanes: Plane[]): boolean;
  26130. /**
  26131. * get the rotation matrix of the particle
  26132. * @hidden
  26133. */
  26134. getRotationMatrix(m: Matrix): void;
  26135. }
  26136. /**
  26137. * Represents the shape of the model used by one particle of a solid particle system.
  26138. * SPS internal tool, don't use it manually.
  26139. */
  26140. export class ModelShape {
  26141. /**
  26142. * The shape id
  26143. * @hidden
  26144. */
  26145. shapeID: number;
  26146. /**
  26147. * flat array of model positions (internal use)
  26148. * @hidden
  26149. */
  26150. _shape: Vector3[];
  26151. /**
  26152. * flat array of model UVs (internal use)
  26153. * @hidden
  26154. */
  26155. _shapeUV: number[];
  26156. /**
  26157. * length of the shape in the model indices array (internal use)
  26158. * @hidden
  26159. */
  26160. _indicesLength: number;
  26161. /**
  26162. * Custom position function (internal use)
  26163. * @hidden
  26164. */
  26165. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26166. /**
  26167. * Custom vertex function (internal use)
  26168. * @hidden
  26169. */
  26170. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26171. /**
  26172. * 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.
  26173. * SPS internal tool, don't use it manually.
  26174. * @hidden
  26175. */
  26176. 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>);
  26177. }
  26178. /**
  26179. * Represents a Depth Sorted Particle in the solid particle system.
  26180. */
  26181. export class DepthSortedParticle {
  26182. /**
  26183. * Index of the particle in the "indices" array
  26184. */
  26185. ind: number;
  26186. /**
  26187. * Length of the particle shape in the "indices" array
  26188. */
  26189. indicesLength: number;
  26190. /**
  26191. * Squared distance from the particle to the camera
  26192. */
  26193. sqDistance: number;
  26194. }
  26195. }
  26196. declare module "babylonjs/Collisions/meshCollisionData" {
  26197. import { Collider } from "babylonjs/Collisions/collider";
  26198. import { Vector3 } from "babylonjs/Maths/math.vector";
  26199. import { Nullable } from "babylonjs/types";
  26200. import { Observer } from "babylonjs/Misc/observable";
  26201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26202. /**
  26203. * @hidden
  26204. */
  26205. export class _MeshCollisionData {
  26206. _checkCollisions: boolean;
  26207. _collisionMask: number;
  26208. _collisionGroup: number;
  26209. _collider: Nullable<Collider>;
  26210. _oldPositionForCollisions: Vector3;
  26211. _diffPositionForCollisions: Vector3;
  26212. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26213. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26214. }
  26215. }
  26216. declare module "babylonjs/Meshes/abstractMesh" {
  26217. import { Observable } from "babylonjs/Misc/observable";
  26218. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26219. import { Camera } from "babylonjs/Cameras/camera";
  26220. import { Scene, IDisposable } from "babylonjs/scene";
  26221. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26222. import { Node } from "babylonjs/node";
  26223. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26224. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26227. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26228. import { Material } from "babylonjs/Materials/material";
  26229. import { Light } from "babylonjs/Lights/light";
  26230. import { Skeleton } from "babylonjs/Bones/skeleton";
  26231. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26232. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26233. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26234. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26235. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26236. import { Plane } from "babylonjs/Maths/math.plane";
  26237. import { Ray } from "babylonjs/Culling/ray";
  26238. import { Collider } from "babylonjs/Collisions/collider";
  26239. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26240. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26241. /** @hidden */
  26242. class _FacetDataStorage {
  26243. facetPositions: Vector3[];
  26244. facetNormals: Vector3[];
  26245. facetPartitioning: number[][];
  26246. facetNb: number;
  26247. partitioningSubdivisions: number;
  26248. partitioningBBoxRatio: number;
  26249. facetDataEnabled: boolean;
  26250. facetParameters: any;
  26251. bbSize: Vector3;
  26252. subDiv: {
  26253. max: number;
  26254. X: number;
  26255. Y: number;
  26256. Z: number;
  26257. };
  26258. facetDepthSort: boolean;
  26259. facetDepthSortEnabled: boolean;
  26260. depthSortedIndices: IndicesArray;
  26261. depthSortedFacets: {
  26262. ind: number;
  26263. sqDistance: number;
  26264. }[];
  26265. facetDepthSortFunction: (f1: {
  26266. ind: number;
  26267. sqDistance: number;
  26268. }, f2: {
  26269. ind: number;
  26270. sqDistance: number;
  26271. }) => number;
  26272. facetDepthSortFrom: Vector3;
  26273. facetDepthSortOrigin: Vector3;
  26274. invertedMatrix: Matrix;
  26275. }
  26276. /**
  26277. * @hidden
  26278. **/
  26279. class _InternalAbstractMeshDataInfo {
  26280. _hasVertexAlpha: boolean;
  26281. _useVertexColors: boolean;
  26282. _numBoneInfluencers: number;
  26283. _applyFog: boolean;
  26284. _receiveShadows: boolean;
  26285. _facetData: _FacetDataStorage;
  26286. _visibility: number;
  26287. _skeleton: Nullable<Skeleton>;
  26288. _layerMask: number;
  26289. _computeBonesUsingShaders: boolean;
  26290. _isActive: boolean;
  26291. _onlyForInstances: boolean;
  26292. _isActiveIntermediate: boolean;
  26293. _onlyForInstancesIntermediate: boolean;
  26294. }
  26295. /**
  26296. * Class used to store all common mesh properties
  26297. */
  26298. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26299. /** No occlusion */
  26300. static OCCLUSION_TYPE_NONE: number;
  26301. /** Occlusion set to optimisitic */
  26302. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26303. /** Occlusion set to strict */
  26304. static OCCLUSION_TYPE_STRICT: number;
  26305. /** Use an accurante occlusion algorithm */
  26306. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26307. /** Use a conservative occlusion algorithm */
  26308. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26309. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26310. * Test order :
  26311. * Is the bounding sphere outside the frustum ?
  26312. * If not, are the bounding box vertices outside the frustum ?
  26313. * It not, then the cullable object is in the frustum.
  26314. */
  26315. static readonly CULLINGSTRATEGY_STANDARD: number;
  26316. /** Culling strategy : Bounding Sphere Only.
  26317. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26318. * It's also less accurate than the standard because some not visible objects can still be selected.
  26319. * Test : is the bounding sphere outside the frustum ?
  26320. * If not, then the cullable object is in the frustum.
  26321. */
  26322. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26323. /** Culling strategy : Optimistic Inclusion.
  26324. * This in an inclusion test first, then the standard exclusion test.
  26325. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26326. * 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.
  26327. * Anyway, it's as accurate as the standard strategy.
  26328. * Test :
  26329. * Is the cullable object bounding sphere center in the frustum ?
  26330. * If not, apply the default culling strategy.
  26331. */
  26332. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26333. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26334. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26335. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26336. * 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.
  26337. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26338. * Test :
  26339. * Is the cullable object bounding sphere center in the frustum ?
  26340. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26341. */
  26342. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26343. /**
  26344. * No billboard
  26345. */
  26346. static readonly BILLBOARDMODE_NONE: number;
  26347. /** Billboard on X axis */
  26348. static readonly BILLBOARDMODE_X: number;
  26349. /** Billboard on Y axis */
  26350. static readonly BILLBOARDMODE_Y: number;
  26351. /** Billboard on Z axis */
  26352. static readonly BILLBOARDMODE_Z: number;
  26353. /** Billboard on all axes */
  26354. static readonly BILLBOARDMODE_ALL: number;
  26355. /** Billboard on using position instead of orientation */
  26356. static readonly BILLBOARDMODE_USE_POSITION: number;
  26357. /** @hidden */
  26358. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26359. /**
  26360. * The culling strategy to use to check whether the mesh must be rendered or not.
  26361. * This value can be changed at any time and will be used on the next render mesh selection.
  26362. * The possible values are :
  26363. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26364. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26365. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26366. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26367. * Please read each static variable documentation to get details about the culling process.
  26368. * */
  26369. cullingStrategy: number;
  26370. /**
  26371. * Gets the number of facets in the mesh
  26372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26373. */
  26374. readonly facetNb: number;
  26375. /**
  26376. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26378. */
  26379. partitioningSubdivisions: number;
  26380. /**
  26381. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26382. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26384. */
  26385. partitioningBBoxRatio: number;
  26386. /**
  26387. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26388. * Works only for updatable meshes.
  26389. * Doesn't work with multi-materials
  26390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26391. */
  26392. mustDepthSortFacets: boolean;
  26393. /**
  26394. * The location (Vector3) where the facet depth sort must be computed from.
  26395. * By default, the active camera position.
  26396. * Used only when facet depth sort is enabled
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26398. */
  26399. facetDepthSortFrom: Vector3;
  26400. /**
  26401. * gets a boolean indicating if facetData is enabled
  26402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26403. */
  26404. readonly isFacetDataEnabled: boolean;
  26405. /** @hidden */
  26406. _updateNonUniformScalingState(value: boolean): boolean;
  26407. /**
  26408. * An event triggered when this mesh collides with another one
  26409. */
  26410. onCollideObservable: Observable<AbstractMesh>;
  26411. /** Set a function to call when this mesh collides with another one */
  26412. onCollide: () => void;
  26413. /**
  26414. * An event triggered when the collision's position changes
  26415. */
  26416. onCollisionPositionChangeObservable: Observable<Vector3>;
  26417. /** Set a function to call when the collision's position changes */
  26418. onCollisionPositionChange: () => void;
  26419. /**
  26420. * An event triggered when material is changed
  26421. */
  26422. onMaterialChangedObservable: Observable<AbstractMesh>;
  26423. /**
  26424. * Gets or sets the orientation for POV movement & rotation
  26425. */
  26426. definedFacingForward: boolean;
  26427. /** @hidden */
  26428. _occlusionQuery: Nullable<WebGLQuery>;
  26429. /** @hidden */
  26430. _renderingGroup: Nullable<RenderingGroup>;
  26431. /**
  26432. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26433. */
  26434. /**
  26435. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26436. */
  26437. visibility: number;
  26438. /** Gets or sets the alpha index used to sort transparent meshes
  26439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26440. */
  26441. alphaIndex: number;
  26442. /**
  26443. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26444. */
  26445. isVisible: boolean;
  26446. /**
  26447. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26448. */
  26449. isPickable: boolean;
  26450. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26451. showSubMeshesBoundingBox: boolean;
  26452. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26453. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26454. */
  26455. isBlocker: boolean;
  26456. /**
  26457. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26458. */
  26459. enablePointerMoveEvents: boolean;
  26460. /**
  26461. * Specifies the rendering group id for this mesh (0 by default)
  26462. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26463. */
  26464. renderingGroupId: number;
  26465. private _material;
  26466. /** Gets or sets current material */
  26467. material: Nullable<Material>;
  26468. /**
  26469. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26470. * @see http://doc.babylonjs.com/babylon101/shadows
  26471. */
  26472. receiveShadows: boolean;
  26473. /** Defines color to use when rendering outline */
  26474. outlineColor: Color3;
  26475. /** Define width to use when rendering outline */
  26476. outlineWidth: number;
  26477. /** Defines color to use when rendering overlay */
  26478. overlayColor: Color3;
  26479. /** Defines alpha to use when rendering overlay */
  26480. overlayAlpha: number;
  26481. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26482. hasVertexAlpha: boolean;
  26483. /** 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) */
  26484. useVertexColors: boolean;
  26485. /**
  26486. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26487. */
  26488. computeBonesUsingShaders: boolean;
  26489. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26490. numBoneInfluencers: number;
  26491. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26492. applyFog: boolean;
  26493. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26494. useOctreeForRenderingSelection: boolean;
  26495. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26496. useOctreeForPicking: boolean;
  26497. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26498. useOctreeForCollisions: boolean;
  26499. /**
  26500. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26501. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26502. */
  26503. layerMask: number;
  26504. /**
  26505. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26506. */
  26507. alwaysSelectAsActiveMesh: boolean;
  26508. /**
  26509. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26510. */
  26511. doNotSyncBoundingInfo: boolean;
  26512. /**
  26513. * Gets or sets the current action manager
  26514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26515. */
  26516. actionManager: Nullable<AbstractActionManager>;
  26517. private _meshCollisionData;
  26518. /**
  26519. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26521. */
  26522. ellipsoid: Vector3;
  26523. /**
  26524. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26526. */
  26527. ellipsoidOffset: Vector3;
  26528. /**
  26529. * Gets or sets a collision mask used to mask collisions (default is -1).
  26530. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26531. */
  26532. collisionMask: number;
  26533. /**
  26534. * Gets or sets the current collision group mask (-1 by default).
  26535. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26536. */
  26537. collisionGroup: number;
  26538. /**
  26539. * Defines edge width used when edgesRenderer is enabled
  26540. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26541. */
  26542. edgesWidth: number;
  26543. /**
  26544. * Defines edge color used when edgesRenderer is enabled
  26545. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26546. */
  26547. edgesColor: Color4;
  26548. /** @hidden */
  26549. _edgesRenderer: Nullable<IEdgesRenderer>;
  26550. /** @hidden */
  26551. _masterMesh: Nullable<AbstractMesh>;
  26552. /** @hidden */
  26553. _boundingInfo: Nullable<BoundingInfo>;
  26554. /** @hidden */
  26555. _renderId: number;
  26556. /**
  26557. * Gets or sets the list of subMeshes
  26558. * @see http://doc.babylonjs.com/how_to/multi_materials
  26559. */
  26560. subMeshes: SubMesh[];
  26561. /** @hidden */
  26562. _intersectionsInProgress: AbstractMesh[];
  26563. /** @hidden */
  26564. _unIndexed: boolean;
  26565. /** @hidden */
  26566. _lightSources: Light[];
  26567. /** Gets the list of lights affecting that mesh */
  26568. readonly lightSources: Light[];
  26569. /** @hidden */
  26570. readonly _positions: Nullable<Vector3[]>;
  26571. /** @hidden */
  26572. _waitingData: {
  26573. lods: Nullable<any>;
  26574. actions: Nullable<any>;
  26575. freezeWorldMatrix: Nullable<boolean>;
  26576. };
  26577. /** @hidden */
  26578. _bonesTransformMatrices: Nullable<Float32Array>;
  26579. /** @hidden */
  26580. _transformMatrixTexture: Nullable<RawTexture>;
  26581. /**
  26582. * Gets or sets a skeleton to apply skining transformations
  26583. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26584. */
  26585. skeleton: Nullable<Skeleton>;
  26586. /**
  26587. * An event triggered when the mesh is rebuilt.
  26588. */
  26589. onRebuildObservable: Observable<AbstractMesh>;
  26590. /**
  26591. * Creates a new AbstractMesh
  26592. * @param name defines the name of the mesh
  26593. * @param scene defines the hosting scene
  26594. */
  26595. constructor(name: string, scene?: Nullable<Scene>);
  26596. /**
  26597. * Returns the string "AbstractMesh"
  26598. * @returns "AbstractMesh"
  26599. */
  26600. getClassName(): string;
  26601. /**
  26602. * Gets a string representation of the current mesh
  26603. * @param fullDetails defines a boolean indicating if full details must be included
  26604. * @returns a string representation of the current mesh
  26605. */
  26606. toString(fullDetails?: boolean): string;
  26607. /**
  26608. * @hidden
  26609. */
  26610. protected _getEffectiveParent(): Nullable<Node>;
  26611. /** @hidden */
  26612. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26613. /** @hidden */
  26614. _rebuild(): void;
  26615. /** @hidden */
  26616. _resyncLightSources(): void;
  26617. /** @hidden */
  26618. _resyncLighSource(light: Light): void;
  26619. /** @hidden */
  26620. _unBindEffect(): void;
  26621. /** @hidden */
  26622. _removeLightSource(light: Light): void;
  26623. private _markSubMeshesAsDirty;
  26624. /** @hidden */
  26625. _markSubMeshesAsLightDirty(): void;
  26626. /** @hidden */
  26627. _markSubMeshesAsAttributesDirty(): void;
  26628. /** @hidden */
  26629. _markSubMeshesAsMiscDirty(): void;
  26630. /**
  26631. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26632. */
  26633. scaling: Vector3;
  26634. /**
  26635. * Returns true if the mesh is blocked. Implemented by child classes
  26636. */
  26637. readonly isBlocked: boolean;
  26638. /**
  26639. * Returns the mesh itself by default. Implemented by child classes
  26640. * @param camera defines the camera to use to pick the right LOD level
  26641. * @returns the currentAbstractMesh
  26642. */
  26643. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26644. /**
  26645. * Returns 0 by default. Implemented by child classes
  26646. * @returns an integer
  26647. */
  26648. getTotalVertices(): number;
  26649. /**
  26650. * Returns a positive integer : the total number of indices in this mesh geometry.
  26651. * @returns the numner of indices or zero if the mesh has no geometry.
  26652. */
  26653. getTotalIndices(): number;
  26654. /**
  26655. * Returns null by default. Implemented by child classes
  26656. * @returns null
  26657. */
  26658. getIndices(): Nullable<IndicesArray>;
  26659. /**
  26660. * Returns the array of the requested vertex data kind. Implemented by child classes
  26661. * @param kind defines the vertex data kind to use
  26662. * @returns null
  26663. */
  26664. getVerticesData(kind: string): Nullable<FloatArray>;
  26665. /**
  26666. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26667. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26668. * Note that a new underlying VertexBuffer object is created each call.
  26669. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26670. * @param kind defines vertex data kind:
  26671. * * VertexBuffer.PositionKind
  26672. * * VertexBuffer.UVKind
  26673. * * VertexBuffer.UV2Kind
  26674. * * VertexBuffer.UV3Kind
  26675. * * VertexBuffer.UV4Kind
  26676. * * VertexBuffer.UV5Kind
  26677. * * VertexBuffer.UV6Kind
  26678. * * VertexBuffer.ColorKind
  26679. * * VertexBuffer.MatricesIndicesKind
  26680. * * VertexBuffer.MatricesIndicesExtraKind
  26681. * * VertexBuffer.MatricesWeightsKind
  26682. * * VertexBuffer.MatricesWeightsExtraKind
  26683. * @param data defines the data source
  26684. * @param updatable defines if the data must be flagged as updatable (or static)
  26685. * @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
  26686. * @returns the current mesh
  26687. */
  26688. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26689. /**
  26690. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26691. * If the mesh has no geometry, it is simply returned as it is.
  26692. * @param kind defines vertex data kind:
  26693. * * VertexBuffer.PositionKind
  26694. * * VertexBuffer.UVKind
  26695. * * VertexBuffer.UV2Kind
  26696. * * VertexBuffer.UV3Kind
  26697. * * VertexBuffer.UV4Kind
  26698. * * VertexBuffer.UV5Kind
  26699. * * VertexBuffer.UV6Kind
  26700. * * VertexBuffer.ColorKind
  26701. * * VertexBuffer.MatricesIndicesKind
  26702. * * VertexBuffer.MatricesIndicesExtraKind
  26703. * * VertexBuffer.MatricesWeightsKind
  26704. * * VertexBuffer.MatricesWeightsExtraKind
  26705. * @param data defines the data source
  26706. * @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
  26707. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26708. * @returns the current mesh
  26709. */
  26710. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26711. /**
  26712. * Sets the mesh indices,
  26713. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26714. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26715. * @param totalVertices Defines the total number of vertices
  26716. * @returns the current mesh
  26717. */
  26718. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26719. /**
  26720. * Gets a boolean indicating if specific vertex data is present
  26721. * @param kind defines the vertex data kind to use
  26722. * @returns true is data kind is present
  26723. */
  26724. isVerticesDataPresent(kind: string): boolean;
  26725. /**
  26726. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26727. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26728. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26729. * @returns a BoundingInfo
  26730. */
  26731. getBoundingInfo(): BoundingInfo;
  26732. /**
  26733. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26734. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26735. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26736. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26737. * @returns the current mesh
  26738. */
  26739. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26740. /**
  26741. * Overwrite the current bounding info
  26742. * @param boundingInfo defines the new bounding info
  26743. * @returns the current mesh
  26744. */
  26745. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26746. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26747. readonly useBones: boolean;
  26748. /** @hidden */
  26749. _preActivate(): void;
  26750. /** @hidden */
  26751. _preActivateForIntermediateRendering(renderId: number): void;
  26752. /** @hidden */
  26753. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26754. /** @hidden */
  26755. _postActivate(): void;
  26756. /** @hidden */
  26757. _freeze(): void;
  26758. /** @hidden */
  26759. _unFreeze(): void;
  26760. /**
  26761. * Gets the current world matrix
  26762. * @returns a Matrix
  26763. */
  26764. getWorldMatrix(): Matrix;
  26765. /** @hidden */
  26766. _getWorldMatrixDeterminant(): number;
  26767. /**
  26768. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26769. */
  26770. readonly isAnInstance: boolean;
  26771. /**
  26772. * Gets a boolean indicating if this mesh has instances
  26773. */
  26774. readonly hasInstances: boolean;
  26775. /**
  26776. * Perform relative position change from the point of view of behind the front of the mesh.
  26777. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26778. * Supports definition of mesh facing forward or backward
  26779. * @param amountRight defines the distance on the right axis
  26780. * @param amountUp defines the distance on the up axis
  26781. * @param amountForward defines the distance on the forward axis
  26782. * @returns the current mesh
  26783. */
  26784. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26785. /**
  26786. * Calculate relative position change from the point of view of behind the front of the mesh.
  26787. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26788. * Supports definition of mesh facing forward or backward
  26789. * @param amountRight defines the distance on the right axis
  26790. * @param amountUp defines the distance on the up axis
  26791. * @param amountForward defines the distance on the forward axis
  26792. * @returns the new displacement vector
  26793. */
  26794. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26795. /**
  26796. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26797. * Supports definition of mesh facing forward or backward
  26798. * @param flipBack defines the flip
  26799. * @param twirlClockwise defines the twirl
  26800. * @param tiltRight defines the tilt
  26801. * @returns the current mesh
  26802. */
  26803. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26804. /**
  26805. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26806. * Supports definition of mesh facing forward or backward.
  26807. * @param flipBack defines the flip
  26808. * @param twirlClockwise defines the twirl
  26809. * @param tiltRight defines the tilt
  26810. * @returns the new rotation vector
  26811. */
  26812. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26813. /**
  26814. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26815. * This means the mesh underlying bounding box and sphere are recomputed.
  26816. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26817. * @returns the current mesh
  26818. */
  26819. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26820. /** @hidden */
  26821. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26822. /** @hidden */
  26823. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26824. /** @hidden */
  26825. _updateBoundingInfo(): AbstractMesh;
  26826. /** @hidden */
  26827. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26828. /** @hidden */
  26829. protected _afterComputeWorldMatrix(): void;
  26830. /** @hidden */
  26831. readonly _effectiveMesh: AbstractMesh;
  26832. /**
  26833. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26834. * A mesh is in the frustum if its bounding box intersects the frustum
  26835. * @param frustumPlanes defines the frustum to test
  26836. * @returns true if the mesh is in the frustum planes
  26837. */
  26838. isInFrustum(frustumPlanes: Plane[]): boolean;
  26839. /**
  26840. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26841. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26842. * @param frustumPlanes defines the frustum to test
  26843. * @returns true if the mesh is completely in the frustum planes
  26844. */
  26845. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26846. /**
  26847. * True if the mesh intersects another mesh or a SolidParticle object
  26848. * @param mesh defines a target mesh or SolidParticle to test
  26849. * @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)
  26850. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26851. * @returns true if there is an intersection
  26852. */
  26853. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26854. /**
  26855. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26856. * @param point defines the point to test
  26857. * @returns true if there is an intersection
  26858. */
  26859. intersectsPoint(point: Vector3): boolean;
  26860. /**
  26861. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26863. */
  26864. checkCollisions: boolean;
  26865. /**
  26866. * Gets Collider object used to compute collisions (not physics)
  26867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26868. */
  26869. readonly collider: Nullable<Collider>;
  26870. /**
  26871. * Move the mesh using collision engine
  26872. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26873. * @param displacement defines the requested displacement vector
  26874. * @returns the current mesh
  26875. */
  26876. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26877. private _onCollisionPositionChange;
  26878. /** @hidden */
  26879. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26880. /** @hidden */
  26881. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26882. /** @hidden */
  26883. _checkCollision(collider: Collider): AbstractMesh;
  26884. /** @hidden */
  26885. _generatePointsArray(): boolean;
  26886. /**
  26887. * Checks if the passed Ray intersects with the mesh
  26888. * @param ray defines the ray to use
  26889. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26890. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26891. * @returns the picking info
  26892. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26893. */
  26894. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26895. /**
  26896. * Clones the current mesh
  26897. * @param name defines the mesh name
  26898. * @param newParent defines the new mesh parent
  26899. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26900. * @returns the new mesh
  26901. */
  26902. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26903. /**
  26904. * Disposes all the submeshes of the current meshnp
  26905. * @returns the current mesh
  26906. */
  26907. releaseSubMeshes(): AbstractMesh;
  26908. /**
  26909. * Releases resources associated with this abstract mesh.
  26910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26912. */
  26913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26914. /**
  26915. * Adds the passed mesh as a child to the current mesh
  26916. * @param mesh defines the child mesh
  26917. * @returns the current mesh
  26918. */
  26919. addChild(mesh: AbstractMesh): AbstractMesh;
  26920. /**
  26921. * Removes the passed mesh from the current mesh children list
  26922. * @param mesh defines the child mesh
  26923. * @returns the current mesh
  26924. */
  26925. removeChild(mesh: AbstractMesh): AbstractMesh;
  26926. /** @hidden */
  26927. private _initFacetData;
  26928. /**
  26929. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26930. * This method can be called within the render loop.
  26931. * 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
  26932. * @returns the current mesh
  26933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26934. */
  26935. updateFacetData(): AbstractMesh;
  26936. /**
  26937. * Returns the facetLocalNormals array.
  26938. * The normals are expressed in the mesh local spac
  26939. * @returns an array of Vector3
  26940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26941. */
  26942. getFacetLocalNormals(): Vector3[];
  26943. /**
  26944. * Returns the facetLocalPositions array.
  26945. * The facet positions are expressed in the mesh local space
  26946. * @returns an array of Vector3
  26947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26948. */
  26949. getFacetLocalPositions(): Vector3[];
  26950. /**
  26951. * Returns the facetLocalPartioning array
  26952. * @returns an array of array of numbers
  26953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26954. */
  26955. getFacetLocalPartitioning(): number[][];
  26956. /**
  26957. * Returns the i-th facet position in the world system.
  26958. * This method allocates a new Vector3 per call
  26959. * @param i defines the facet index
  26960. * @returns a new Vector3
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26962. */
  26963. getFacetPosition(i: number): Vector3;
  26964. /**
  26965. * Sets the reference Vector3 with the i-th facet position in the world system
  26966. * @param i defines the facet index
  26967. * @param ref defines the target vector
  26968. * @returns the current mesh
  26969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26970. */
  26971. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26972. /**
  26973. * Returns the i-th facet normal in the world system.
  26974. * This method allocates a new Vector3 per call
  26975. * @param i defines the facet index
  26976. * @returns a new Vector3
  26977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26978. */
  26979. getFacetNormal(i: number): Vector3;
  26980. /**
  26981. * Sets the reference Vector3 with the i-th facet normal in the world system
  26982. * @param i defines the facet index
  26983. * @param ref defines the target vector
  26984. * @returns the current mesh
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26986. */
  26987. getFacetNormalToRef(i: number, ref: Vector3): this;
  26988. /**
  26989. * 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)
  26990. * @param x defines x coordinate
  26991. * @param y defines y coordinate
  26992. * @param z defines z coordinate
  26993. * @returns the array of facet indexes
  26994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26995. */
  26996. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26997. /**
  26998. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26999. * @param projected sets as the (x,y,z) world projection on the facet
  27000. * @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
  27001. * @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
  27002. * @param x defines x coordinate
  27003. * @param y defines y coordinate
  27004. * @param z defines z coordinate
  27005. * @returns the face index if found (or null instead)
  27006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27007. */
  27008. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27009. /**
  27010. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27011. * @param projected sets as the (x,y,z) local projection on the facet
  27012. * @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
  27013. * @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
  27014. * @param x defines x coordinate
  27015. * @param y defines y coordinate
  27016. * @param z defines z coordinate
  27017. * @returns the face index if found (or null instead)
  27018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27019. */
  27020. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27021. /**
  27022. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27023. * @returns the parameters
  27024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27025. */
  27026. getFacetDataParameters(): any;
  27027. /**
  27028. * Disables the feature FacetData and frees the related memory
  27029. * @returns the current mesh
  27030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27031. */
  27032. disableFacetData(): AbstractMesh;
  27033. /**
  27034. * Updates the AbstractMesh indices array
  27035. * @param indices defines the data source
  27036. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27037. * @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)
  27038. * @returns the current mesh
  27039. */
  27040. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27041. /**
  27042. * Creates new normals data for the mesh
  27043. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27044. * @returns the current mesh
  27045. */
  27046. createNormals(updatable: boolean): AbstractMesh;
  27047. /**
  27048. * Align the mesh with a normal
  27049. * @param normal defines the normal to use
  27050. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27051. * @returns the current mesh
  27052. */
  27053. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27054. /** @hidden */
  27055. _checkOcclusionQuery(): boolean;
  27056. /**
  27057. * Disables the mesh edge rendering mode
  27058. * @returns the currentAbstractMesh
  27059. */
  27060. disableEdgesRendering(): AbstractMesh;
  27061. /**
  27062. * Enables the edge rendering mode on the mesh.
  27063. * This mode makes the mesh edges visible
  27064. * @param epsilon defines the maximal distance between two angles to detect a face
  27065. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27066. * @returns the currentAbstractMesh
  27067. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27068. */
  27069. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27070. }
  27071. }
  27072. declare module "babylonjs/Actions/actionEvent" {
  27073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27074. import { Nullable } from "babylonjs/types";
  27075. import { Sprite } from "babylonjs/Sprites/sprite";
  27076. import { Scene } from "babylonjs/scene";
  27077. import { Vector2 } from "babylonjs/Maths/math.vector";
  27078. /**
  27079. * Interface used to define ActionEvent
  27080. */
  27081. export interface IActionEvent {
  27082. /** The mesh or sprite that triggered the action */
  27083. source: any;
  27084. /** The X mouse cursor position at the time of the event */
  27085. pointerX: number;
  27086. /** The Y mouse cursor position at the time of the event */
  27087. pointerY: number;
  27088. /** The mesh that is currently pointed at (can be null) */
  27089. meshUnderPointer: Nullable<AbstractMesh>;
  27090. /** the original (browser) event that triggered the ActionEvent */
  27091. sourceEvent?: any;
  27092. /** additional data for the event */
  27093. additionalData?: any;
  27094. }
  27095. /**
  27096. * ActionEvent is the event being sent when an action is triggered.
  27097. */
  27098. export class ActionEvent implements IActionEvent {
  27099. /** The mesh or sprite that triggered the action */
  27100. source: any;
  27101. /** The X mouse cursor position at the time of the event */
  27102. pointerX: number;
  27103. /** The Y mouse cursor position at the time of the event */
  27104. pointerY: number;
  27105. /** The mesh that is currently pointed at (can be null) */
  27106. meshUnderPointer: Nullable<AbstractMesh>;
  27107. /** the original (browser) event that triggered the ActionEvent */
  27108. sourceEvent?: any;
  27109. /** additional data for the event */
  27110. additionalData?: any;
  27111. /**
  27112. * Creates a new ActionEvent
  27113. * @param source The mesh or sprite that triggered the action
  27114. * @param pointerX The X mouse cursor position at the time of the event
  27115. * @param pointerY The Y mouse cursor position at the time of the event
  27116. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27117. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27118. * @param additionalData additional data for the event
  27119. */
  27120. constructor(
  27121. /** The mesh or sprite that triggered the action */
  27122. source: any,
  27123. /** The X mouse cursor position at the time of the event */
  27124. pointerX: number,
  27125. /** The Y mouse cursor position at the time of the event */
  27126. pointerY: number,
  27127. /** The mesh that is currently pointed at (can be null) */
  27128. meshUnderPointer: Nullable<AbstractMesh>,
  27129. /** the original (browser) event that triggered the ActionEvent */
  27130. sourceEvent?: any,
  27131. /** additional data for the event */
  27132. additionalData?: any);
  27133. /**
  27134. * Helper function to auto-create an ActionEvent from a source mesh.
  27135. * @param source The source mesh that triggered the event
  27136. * @param evt The original (browser) event
  27137. * @param additionalData additional data for the event
  27138. * @returns the new ActionEvent
  27139. */
  27140. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27141. /**
  27142. * Helper function to auto-create an ActionEvent from a source sprite
  27143. * @param source The source sprite that triggered the event
  27144. * @param scene Scene associated with the sprite
  27145. * @param evt The original (browser) event
  27146. * @param additionalData additional data for the event
  27147. * @returns the new ActionEvent
  27148. */
  27149. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27150. /**
  27151. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27152. * @param scene the scene where the event occurred
  27153. * @param evt The original (browser) event
  27154. * @returns the new ActionEvent
  27155. */
  27156. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27157. /**
  27158. * Helper function to auto-create an ActionEvent from a primitive
  27159. * @param prim defines the target primitive
  27160. * @param pointerPos defines the pointer position
  27161. * @param evt The original (browser) event
  27162. * @param additionalData additional data for the event
  27163. * @returns the new ActionEvent
  27164. */
  27165. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27166. }
  27167. }
  27168. declare module "babylonjs/Actions/abstractActionManager" {
  27169. import { IDisposable } from "babylonjs/scene";
  27170. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27171. import { IAction } from "babylonjs/Actions/action";
  27172. import { Nullable } from "babylonjs/types";
  27173. /**
  27174. * Abstract class used to decouple action Manager from scene and meshes.
  27175. * Do not instantiate.
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27177. */
  27178. export abstract class AbstractActionManager implements IDisposable {
  27179. /** Gets the list of active triggers */
  27180. static Triggers: {
  27181. [key: string]: number;
  27182. };
  27183. /** Gets the cursor to use when hovering items */
  27184. hoverCursor: string;
  27185. /** Gets the list of actions */
  27186. actions: IAction[];
  27187. /**
  27188. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27189. */
  27190. isRecursive: boolean;
  27191. /**
  27192. * Releases all associated resources
  27193. */
  27194. abstract dispose(): void;
  27195. /**
  27196. * Does this action manager has pointer triggers
  27197. */
  27198. abstract readonly hasPointerTriggers: boolean;
  27199. /**
  27200. * Does this action manager has pick triggers
  27201. */
  27202. abstract readonly hasPickTriggers: boolean;
  27203. /**
  27204. * Process a specific trigger
  27205. * @param trigger defines the trigger to process
  27206. * @param evt defines the event details to be processed
  27207. */
  27208. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27209. /**
  27210. * Does this action manager handles actions of any of the given triggers
  27211. * @param triggers defines the triggers to be tested
  27212. * @return a boolean indicating whether one (or more) of the triggers is handled
  27213. */
  27214. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27215. /**
  27216. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27217. * speed.
  27218. * @param triggerA defines the trigger to be tested
  27219. * @param triggerB defines the trigger to be tested
  27220. * @return a boolean indicating whether one (or more) of the triggers is handled
  27221. */
  27222. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27223. /**
  27224. * Does this action manager handles actions of a given trigger
  27225. * @param trigger defines the trigger to be tested
  27226. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27227. * @return whether the trigger is handled
  27228. */
  27229. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27230. /**
  27231. * Serialize this manager to a JSON object
  27232. * @param name defines the property name to store this manager
  27233. * @returns a JSON representation of this manager
  27234. */
  27235. abstract serialize(name: string): any;
  27236. /**
  27237. * Registers an action to this action manager
  27238. * @param action defines the action to be registered
  27239. * @return the action amended (prepared) after registration
  27240. */
  27241. abstract registerAction(action: IAction): Nullable<IAction>;
  27242. /**
  27243. * Unregisters an action to this action manager
  27244. * @param action defines the action to be unregistered
  27245. * @return a boolean indicating whether the action has been unregistered
  27246. */
  27247. abstract unregisterAction(action: IAction): Boolean;
  27248. /**
  27249. * Does exist one action manager with at least one trigger
  27250. **/
  27251. static readonly HasTriggers: boolean;
  27252. /**
  27253. * Does exist one action manager with at least one pick trigger
  27254. **/
  27255. static readonly HasPickTriggers: boolean;
  27256. /**
  27257. * Does exist one action manager that handles actions of a given trigger
  27258. * @param trigger defines the trigger to be tested
  27259. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27260. **/
  27261. static HasSpecificTrigger(trigger: number): boolean;
  27262. }
  27263. }
  27264. declare module "babylonjs/node" {
  27265. import { Scene } from "babylonjs/scene";
  27266. import { Nullable } from "babylonjs/types";
  27267. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27268. import { Engine } from "babylonjs/Engines/engine";
  27269. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27270. import { Observable } from "babylonjs/Misc/observable";
  27271. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27272. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27273. import { Animatable } from "babylonjs/Animations/animatable";
  27274. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27275. import { Animation } from "babylonjs/Animations/animation";
  27276. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27278. /**
  27279. * Defines how a node can be built from a string name.
  27280. */
  27281. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27282. /**
  27283. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27284. */
  27285. export class Node implements IBehaviorAware<Node> {
  27286. /** @hidden */
  27287. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27288. private static _NodeConstructors;
  27289. /**
  27290. * Add a new node constructor
  27291. * @param type defines the type name of the node to construct
  27292. * @param constructorFunc defines the constructor function
  27293. */
  27294. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27295. /**
  27296. * Returns a node constructor based on type name
  27297. * @param type defines the type name
  27298. * @param name defines the new node name
  27299. * @param scene defines the hosting scene
  27300. * @param options defines optional options to transmit to constructors
  27301. * @returns the new constructor or null
  27302. */
  27303. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27304. /**
  27305. * Gets or sets the name of the node
  27306. */
  27307. name: string;
  27308. /**
  27309. * Gets or sets the id of the node
  27310. */
  27311. id: string;
  27312. /**
  27313. * Gets or sets the unique id of the node
  27314. */
  27315. uniqueId: number;
  27316. /**
  27317. * Gets or sets a string used to store user defined state for the node
  27318. */
  27319. state: string;
  27320. /**
  27321. * Gets or sets an object used to store user defined information for the node
  27322. */
  27323. metadata: any;
  27324. /**
  27325. * For internal use only. Please do not use.
  27326. */
  27327. reservedDataStore: any;
  27328. /**
  27329. * List of inspectable custom properties (used by the Inspector)
  27330. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27331. */
  27332. inspectableCustomProperties: IInspectable[];
  27333. /**
  27334. * Gets or sets a boolean used to define if the node must be serialized
  27335. */
  27336. doNotSerialize: boolean;
  27337. /** @hidden */
  27338. _isDisposed: boolean;
  27339. /**
  27340. * Gets a list of Animations associated with the node
  27341. */
  27342. animations: import("babylonjs/Animations/animation").Animation[];
  27343. protected _ranges: {
  27344. [name: string]: Nullable<AnimationRange>;
  27345. };
  27346. /**
  27347. * Callback raised when the node is ready to be used
  27348. */
  27349. onReady: Nullable<(node: Node) => void>;
  27350. private _isEnabled;
  27351. private _isParentEnabled;
  27352. private _isReady;
  27353. /** @hidden */
  27354. _currentRenderId: number;
  27355. private _parentUpdateId;
  27356. /** @hidden */
  27357. _childUpdateId: number;
  27358. /** @hidden */
  27359. _waitingParentId: Nullable<string>;
  27360. /** @hidden */
  27361. _scene: Scene;
  27362. /** @hidden */
  27363. _cache: any;
  27364. private _parentNode;
  27365. private _children;
  27366. /** @hidden */
  27367. _worldMatrix: Matrix;
  27368. /** @hidden */
  27369. _worldMatrixDeterminant: number;
  27370. /** @hidden */
  27371. _worldMatrixDeterminantIsDirty: boolean;
  27372. /** @hidden */
  27373. private _sceneRootNodesIndex;
  27374. /**
  27375. * Gets a boolean indicating if the node has been disposed
  27376. * @returns true if the node was disposed
  27377. */
  27378. isDisposed(): boolean;
  27379. /**
  27380. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27381. * @see https://doc.babylonjs.com/how_to/parenting
  27382. */
  27383. parent: Nullable<Node>;
  27384. private addToSceneRootNodes;
  27385. private removeFromSceneRootNodes;
  27386. private _animationPropertiesOverride;
  27387. /**
  27388. * Gets or sets the animation properties override
  27389. */
  27390. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27391. /**
  27392. * Gets a string idenfifying the name of the class
  27393. * @returns "Node" string
  27394. */
  27395. getClassName(): string;
  27396. /** @hidden */
  27397. readonly _isNode: boolean;
  27398. /**
  27399. * An event triggered when the mesh is disposed
  27400. */
  27401. onDisposeObservable: Observable<Node>;
  27402. private _onDisposeObserver;
  27403. /**
  27404. * Sets a callback that will be raised when the node will be disposed
  27405. */
  27406. onDispose: () => void;
  27407. /**
  27408. * Creates a new Node
  27409. * @param name the name and id to be given to this node
  27410. * @param scene the scene this node will be added to
  27411. * @param addToRootNodes the node will be added to scene.rootNodes
  27412. */
  27413. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27414. /**
  27415. * Gets the scene of the node
  27416. * @returns a scene
  27417. */
  27418. getScene(): Scene;
  27419. /**
  27420. * Gets the engine of the node
  27421. * @returns a Engine
  27422. */
  27423. getEngine(): Engine;
  27424. private _behaviors;
  27425. /**
  27426. * Attach a behavior to the node
  27427. * @see http://doc.babylonjs.com/features/behaviour
  27428. * @param behavior defines the behavior to attach
  27429. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27430. * @returns the current Node
  27431. */
  27432. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27433. /**
  27434. * Remove an attached behavior
  27435. * @see http://doc.babylonjs.com/features/behaviour
  27436. * @param behavior defines the behavior to attach
  27437. * @returns the current Node
  27438. */
  27439. removeBehavior(behavior: Behavior<Node>): Node;
  27440. /**
  27441. * Gets the list of attached behaviors
  27442. * @see http://doc.babylonjs.com/features/behaviour
  27443. */
  27444. readonly behaviors: Behavior<Node>[];
  27445. /**
  27446. * Gets an attached behavior by name
  27447. * @param name defines the name of the behavior to look for
  27448. * @see http://doc.babylonjs.com/features/behaviour
  27449. * @returns null if behavior was not found else the requested behavior
  27450. */
  27451. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27452. /**
  27453. * Returns the latest update of the World matrix
  27454. * @returns a Matrix
  27455. */
  27456. getWorldMatrix(): Matrix;
  27457. /** @hidden */
  27458. _getWorldMatrixDeterminant(): number;
  27459. /**
  27460. * Returns directly the latest state of the mesh World matrix.
  27461. * A Matrix is returned.
  27462. */
  27463. readonly worldMatrixFromCache: Matrix;
  27464. /** @hidden */
  27465. _initCache(): void;
  27466. /** @hidden */
  27467. updateCache(force?: boolean): void;
  27468. /** @hidden */
  27469. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27470. /** @hidden */
  27471. _updateCache(ignoreParentClass?: boolean): void;
  27472. /** @hidden */
  27473. _isSynchronized(): boolean;
  27474. /** @hidden */
  27475. _markSyncedWithParent(): void;
  27476. /** @hidden */
  27477. isSynchronizedWithParent(): boolean;
  27478. /** @hidden */
  27479. isSynchronized(): boolean;
  27480. /**
  27481. * Is this node ready to be used/rendered
  27482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27483. * @return true if the node is ready
  27484. */
  27485. isReady(completeCheck?: boolean): boolean;
  27486. /**
  27487. * Is this node enabled?
  27488. * 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
  27489. * @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
  27490. * @return whether this node (and its parent) is enabled
  27491. */
  27492. isEnabled(checkAncestors?: boolean): boolean;
  27493. /** @hidden */
  27494. protected _syncParentEnabledState(): void;
  27495. /**
  27496. * Set the enabled state of this node
  27497. * @param value defines the new enabled state
  27498. */
  27499. setEnabled(value: boolean): void;
  27500. /**
  27501. * Is this node a descendant of the given node?
  27502. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27503. * @param ancestor defines the parent node to inspect
  27504. * @returns a boolean indicating if this node is a descendant of the given node
  27505. */
  27506. isDescendantOf(ancestor: Node): boolean;
  27507. /** @hidden */
  27508. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27509. /**
  27510. * Will return all nodes that have this node as ascendant
  27511. * @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
  27512. * @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
  27513. * @return all children nodes of all types
  27514. */
  27515. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27516. /**
  27517. * Get all child-meshes of this node
  27518. * @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)
  27519. * @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
  27520. * @returns an array of AbstractMesh
  27521. */
  27522. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27523. /**
  27524. * Get all direct children of this node
  27525. * @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
  27526. * @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)
  27527. * @returns an array of Node
  27528. */
  27529. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27530. /** @hidden */
  27531. _setReady(state: boolean): void;
  27532. /**
  27533. * Get an animation by name
  27534. * @param name defines the name of the animation to look for
  27535. * @returns null if not found else the requested animation
  27536. */
  27537. getAnimationByName(name: string): Nullable<Animation>;
  27538. /**
  27539. * Creates an animation range for this node
  27540. * @param name defines the name of the range
  27541. * @param from defines the starting key
  27542. * @param to defines the end key
  27543. */
  27544. createAnimationRange(name: string, from: number, to: number): void;
  27545. /**
  27546. * Delete a specific animation range
  27547. * @param name defines the name of the range to delete
  27548. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27549. */
  27550. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27551. /**
  27552. * Get an animation range by name
  27553. * @param name defines the name of the animation range to look for
  27554. * @returns null if not found else the requested animation range
  27555. */
  27556. getAnimationRange(name: string): Nullable<AnimationRange>;
  27557. /**
  27558. * Gets the list of all animation ranges defined on this node
  27559. * @returns an array
  27560. */
  27561. getAnimationRanges(): Nullable<AnimationRange>[];
  27562. /**
  27563. * Will start the animation sequence
  27564. * @param name defines the range frames for animation sequence
  27565. * @param loop defines if the animation should loop (false by default)
  27566. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27567. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27568. * @returns the object created for this animation. If range does not exist, it will return null
  27569. */
  27570. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27571. /**
  27572. * Serialize animation ranges into a JSON compatible object
  27573. * @returns serialization object
  27574. */
  27575. serializeAnimationRanges(): any;
  27576. /**
  27577. * Computes the world matrix of the node
  27578. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27579. * @returns the world matrix
  27580. */
  27581. computeWorldMatrix(force?: boolean): Matrix;
  27582. /**
  27583. * Releases resources associated with this node.
  27584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27586. */
  27587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27588. /**
  27589. * Parse animation range data from a serialization object and store them into a given node
  27590. * @param node defines where to store the animation ranges
  27591. * @param parsedNode defines the serialization object to read data from
  27592. * @param scene defines the hosting scene
  27593. */
  27594. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27595. /**
  27596. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27597. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27598. * @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
  27599. * @returns the new bounding vectors
  27600. */
  27601. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27602. min: Vector3;
  27603. max: Vector3;
  27604. };
  27605. }
  27606. }
  27607. declare module "babylonjs/Animations/animation" {
  27608. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27609. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27610. import { Color3 } from "babylonjs/Maths/math.color";
  27611. import { Nullable } from "babylonjs/types";
  27612. import { Scene } from "babylonjs/scene";
  27613. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27614. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27615. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27616. import { Node } from "babylonjs/node";
  27617. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27618. import { Size } from "babylonjs/Maths/math.size";
  27619. import { Animatable } from "babylonjs/Animations/animatable";
  27620. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27621. /**
  27622. * @hidden
  27623. */
  27624. export class _IAnimationState {
  27625. key: number;
  27626. repeatCount: number;
  27627. workValue?: any;
  27628. loopMode?: number;
  27629. offsetValue?: any;
  27630. highLimitValue?: any;
  27631. }
  27632. /**
  27633. * Class used to store any kind of animation
  27634. */
  27635. export class Animation {
  27636. /**Name of the animation */
  27637. name: string;
  27638. /**Property to animate */
  27639. targetProperty: string;
  27640. /**The frames per second of the animation */
  27641. framePerSecond: number;
  27642. /**The data type of the animation */
  27643. dataType: number;
  27644. /**The loop mode of the animation */
  27645. loopMode?: number | undefined;
  27646. /**Specifies if blending should be enabled */
  27647. enableBlending?: boolean | undefined;
  27648. /**
  27649. * Use matrix interpolation instead of using direct key value when animating matrices
  27650. */
  27651. static AllowMatricesInterpolation: boolean;
  27652. /**
  27653. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27654. */
  27655. static AllowMatrixDecomposeForInterpolation: boolean;
  27656. /**
  27657. * Stores the key frames of the animation
  27658. */
  27659. private _keys;
  27660. /**
  27661. * Stores the easing function of the animation
  27662. */
  27663. private _easingFunction;
  27664. /**
  27665. * @hidden Internal use only
  27666. */
  27667. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27668. /**
  27669. * The set of event that will be linked to this animation
  27670. */
  27671. private _events;
  27672. /**
  27673. * Stores an array of target property paths
  27674. */
  27675. targetPropertyPath: string[];
  27676. /**
  27677. * Stores the blending speed of the animation
  27678. */
  27679. blendingSpeed: number;
  27680. /**
  27681. * Stores the animation ranges for the animation
  27682. */
  27683. private _ranges;
  27684. /**
  27685. * @hidden Internal use
  27686. */
  27687. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27688. /**
  27689. * Sets up an animation
  27690. * @param property The property to animate
  27691. * @param animationType The animation type to apply
  27692. * @param framePerSecond The frames per second of the animation
  27693. * @param easingFunction The easing function used in the animation
  27694. * @returns The created animation
  27695. */
  27696. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27697. /**
  27698. * Create and start an animation on a node
  27699. * @param name defines the name of the global animation that will be run on all nodes
  27700. * @param node defines the root node where the animation will take place
  27701. * @param targetProperty defines property to animate
  27702. * @param framePerSecond defines the number of frame per second yo use
  27703. * @param totalFrame defines the number of frames in total
  27704. * @param from defines the initial value
  27705. * @param to defines the final value
  27706. * @param loopMode defines which loop mode you want to use (off by default)
  27707. * @param easingFunction defines the easing function to use (linear by default)
  27708. * @param onAnimationEnd defines the callback to call when animation end
  27709. * @returns the animatable created for this animation
  27710. */
  27711. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27712. /**
  27713. * Create and start an animation on a node and its descendants
  27714. * @param name defines the name of the global animation that will be run on all nodes
  27715. * @param node defines the root node where the animation will take place
  27716. * @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
  27717. * @param targetProperty defines property to animate
  27718. * @param framePerSecond defines the number of frame per second to use
  27719. * @param totalFrame defines the number of frames in total
  27720. * @param from defines the initial value
  27721. * @param to defines the final value
  27722. * @param loopMode defines which loop mode you want to use (off by default)
  27723. * @param easingFunction defines the easing function to use (linear by default)
  27724. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27725. * @returns the list of animatables created for all nodes
  27726. * @example https://www.babylonjs-playground.com/#MH0VLI
  27727. */
  27728. 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[]>;
  27729. /**
  27730. * Creates a new animation, merges it with the existing animations and starts it
  27731. * @param name Name of the animation
  27732. * @param node Node which contains the scene that begins the animations
  27733. * @param targetProperty Specifies which property to animate
  27734. * @param framePerSecond The frames per second of the animation
  27735. * @param totalFrame The total number of frames
  27736. * @param from The frame at the beginning of the animation
  27737. * @param to The frame at the end of the animation
  27738. * @param loopMode Specifies the loop mode of the animation
  27739. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27740. * @param onAnimationEnd Callback to run once the animation is complete
  27741. * @returns Nullable animation
  27742. */
  27743. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27744. /**
  27745. * Transition property of an host to the target Value
  27746. * @param property The property to transition
  27747. * @param targetValue The target Value of the property
  27748. * @param host The object where the property to animate belongs
  27749. * @param scene Scene used to run the animation
  27750. * @param frameRate Framerate (in frame/s) to use
  27751. * @param transition The transition type we want to use
  27752. * @param duration The duration of the animation, in milliseconds
  27753. * @param onAnimationEnd Callback trigger at the end of the animation
  27754. * @returns Nullable animation
  27755. */
  27756. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27757. /**
  27758. * Return the array of runtime animations currently using this animation
  27759. */
  27760. readonly runtimeAnimations: RuntimeAnimation[];
  27761. /**
  27762. * Specifies if any of the runtime animations are currently running
  27763. */
  27764. readonly hasRunningRuntimeAnimations: boolean;
  27765. /**
  27766. * Initializes the animation
  27767. * @param name Name of the animation
  27768. * @param targetProperty Property to animate
  27769. * @param framePerSecond The frames per second of the animation
  27770. * @param dataType The data type of the animation
  27771. * @param loopMode The loop mode of the animation
  27772. * @param enableBlending Specifies if blending should be enabled
  27773. */
  27774. constructor(
  27775. /**Name of the animation */
  27776. name: string,
  27777. /**Property to animate */
  27778. targetProperty: string,
  27779. /**The frames per second of the animation */
  27780. framePerSecond: number,
  27781. /**The data type of the animation */
  27782. dataType: number,
  27783. /**The loop mode of the animation */
  27784. loopMode?: number | undefined,
  27785. /**Specifies if blending should be enabled */
  27786. enableBlending?: boolean | undefined);
  27787. /**
  27788. * Converts the animation to a string
  27789. * @param fullDetails support for multiple levels of logging within scene loading
  27790. * @returns String form of the animation
  27791. */
  27792. toString(fullDetails?: boolean): string;
  27793. /**
  27794. * Add an event to this animation
  27795. * @param event Event to add
  27796. */
  27797. addEvent(event: AnimationEvent): void;
  27798. /**
  27799. * Remove all events found at the given frame
  27800. * @param frame The frame to remove events from
  27801. */
  27802. removeEvents(frame: number): void;
  27803. /**
  27804. * Retrieves all the events from the animation
  27805. * @returns Events from the animation
  27806. */
  27807. getEvents(): AnimationEvent[];
  27808. /**
  27809. * Creates an animation range
  27810. * @param name Name of the animation range
  27811. * @param from Starting frame of the animation range
  27812. * @param to Ending frame of the animation
  27813. */
  27814. createRange(name: string, from: number, to: number): void;
  27815. /**
  27816. * Deletes an animation range by name
  27817. * @param name Name of the animation range to delete
  27818. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27819. */
  27820. deleteRange(name: string, deleteFrames?: boolean): void;
  27821. /**
  27822. * Gets the animation range by name, or null if not defined
  27823. * @param name Name of the animation range
  27824. * @returns Nullable animation range
  27825. */
  27826. getRange(name: string): Nullable<AnimationRange>;
  27827. /**
  27828. * Gets the key frames from the animation
  27829. * @returns The key frames of the animation
  27830. */
  27831. getKeys(): Array<IAnimationKey>;
  27832. /**
  27833. * Gets the highest frame rate of the animation
  27834. * @returns Highest frame rate of the animation
  27835. */
  27836. getHighestFrame(): number;
  27837. /**
  27838. * Gets the easing function of the animation
  27839. * @returns Easing function of the animation
  27840. */
  27841. getEasingFunction(): IEasingFunction;
  27842. /**
  27843. * Sets the easing function of the animation
  27844. * @param easingFunction A custom mathematical formula for animation
  27845. */
  27846. setEasingFunction(easingFunction: EasingFunction): void;
  27847. /**
  27848. * Interpolates a scalar linearly
  27849. * @param startValue Start value of the animation curve
  27850. * @param endValue End value of the animation curve
  27851. * @param gradient Scalar amount to interpolate
  27852. * @returns Interpolated scalar value
  27853. */
  27854. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27855. /**
  27856. * Interpolates a scalar cubically
  27857. * @param startValue Start value of the animation curve
  27858. * @param outTangent End tangent of the animation
  27859. * @param endValue End value of the animation curve
  27860. * @param inTangent Start tangent of the animation curve
  27861. * @param gradient Scalar amount to interpolate
  27862. * @returns Interpolated scalar value
  27863. */
  27864. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27865. /**
  27866. * Interpolates a quaternion using a spherical linear interpolation
  27867. * @param startValue Start value of the animation curve
  27868. * @param endValue End value of the animation curve
  27869. * @param gradient Scalar amount to interpolate
  27870. * @returns Interpolated quaternion value
  27871. */
  27872. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27873. /**
  27874. * Interpolates a quaternion cubically
  27875. * @param startValue Start value of the animation curve
  27876. * @param outTangent End tangent of the animation curve
  27877. * @param endValue End value of the animation curve
  27878. * @param inTangent Start tangent of the animation curve
  27879. * @param gradient Scalar amount to interpolate
  27880. * @returns Interpolated quaternion value
  27881. */
  27882. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27883. /**
  27884. * Interpolates a Vector3 linearl
  27885. * @param startValue Start value of the animation curve
  27886. * @param endValue End value of the animation curve
  27887. * @param gradient Scalar amount to interpolate
  27888. * @returns Interpolated scalar value
  27889. */
  27890. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27891. /**
  27892. * Interpolates a Vector3 cubically
  27893. * @param startValue Start value of the animation curve
  27894. * @param outTangent End tangent of the animation
  27895. * @param endValue End value of the animation curve
  27896. * @param inTangent Start tangent of the animation curve
  27897. * @param gradient Scalar amount to interpolate
  27898. * @returns InterpolatedVector3 value
  27899. */
  27900. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27901. /**
  27902. * Interpolates a Vector2 linearly
  27903. * @param startValue Start value of the animation curve
  27904. * @param endValue End value of the animation curve
  27905. * @param gradient Scalar amount to interpolate
  27906. * @returns Interpolated Vector2 value
  27907. */
  27908. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27909. /**
  27910. * Interpolates a Vector2 cubically
  27911. * @param startValue Start value of the animation curve
  27912. * @param outTangent End tangent of the animation
  27913. * @param endValue End value of the animation curve
  27914. * @param inTangent Start tangent of the animation curve
  27915. * @param gradient Scalar amount to interpolate
  27916. * @returns Interpolated Vector2 value
  27917. */
  27918. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27919. /**
  27920. * Interpolates a size linearly
  27921. * @param startValue Start value of the animation curve
  27922. * @param endValue End value of the animation curve
  27923. * @param gradient Scalar amount to interpolate
  27924. * @returns Interpolated Size value
  27925. */
  27926. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27927. /**
  27928. * Interpolates a Color3 linearly
  27929. * @param startValue Start value of the animation curve
  27930. * @param endValue End value of the animation curve
  27931. * @param gradient Scalar amount to interpolate
  27932. * @returns Interpolated Color3 value
  27933. */
  27934. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27935. /**
  27936. * @hidden Internal use only
  27937. */
  27938. _getKeyValue(value: any): any;
  27939. /**
  27940. * @hidden Internal use only
  27941. */
  27942. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27943. /**
  27944. * Defines the function to use to interpolate matrices
  27945. * @param startValue defines the start matrix
  27946. * @param endValue defines the end matrix
  27947. * @param gradient defines the gradient between both matrices
  27948. * @param result defines an optional target matrix where to store the interpolation
  27949. * @returns the interpolated matrix
  27950. */
  27951. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27952. /**
  27953. * Makes a copy of the animation
  27954. * @returns Cloned animation
  27955. */
  27956. clone(): Animation;
  27957. /**
  27958. * Sets the key frames of the animation
  27959. * @param values The animation key frames to set
  27960. */
  27961. setKeys(values: Array<IAnimationKey>): void;
  27962. /**
  27963. * Serializes the animation to an object
  27964. * @returns Serialized object
  27965. */
  27966. serialize(): any;
  27967. /**
  27968. * Float animation type
  27969. */
  27970. private static _ANIMATIONTYPE_FLOAT;
  27971. /**
  27972. * Vector3 animation type
  27973. */
  27974. private static _ANIMATIONTYPE_VECTOR3;
  27975. /**
  27976. * Quaternion animation type
  27977. */
  27978. private static _ANIMATIONTYPE_QUATERNION;
  27979. /**
  27980. * Matrix animation type
  27981. */
  27982. private static _ANIMATIONTYPE_MATRIX;
  27983. /**
  27984. * Color3 animation type
  27985. */
  27986. private static _ANIMATIONTYPE_COLOR3;
  27987. /**
  27988. * Vector2 animation type
  27989. */
  27990. private static _ANIMATIONTYPE_VECTOR2;
  27991. /**
  27992. * Size animation type
  27993. */
  27994. private static _ANIMATIONTYPE_SIZE;
  27995. /**
  27996. * Relative Loop Mode
  27997. */
  27998. private static _ANIMATIONLOOPMODE_RELATIVE;
  27999. /**
  28000. * Cycle Loop Mode
  28001. */
  28002. private static _ANIMATIONLOOPMODE_CYCLE;
  28003. /**
  28004. * Constant Loop Mode
  28005. */
  28006. private static _ANIMATIONLOOPMODE_CONSTANT;
  28007. /**
  28008. * Get the float animation type
  28009. */
  28010. static readonly ANIMATIONTYPE_FLOAT: number;
  28011. /**
  28012. * Get the Vector3 animation type
  28013. */
  28014. static readonly ANIMATIONTYPE_VECTOR3: number;
  28015. /**
  28016. * Get the Vector2 animation type
  28017. */
  28018. static readonly ANIMATIONTYPE_VECTOR2: number;
  28019. /**
  28020. * Get the Size animation type
  28021. */
  28022. static readonly ANIMATIONTYPE_SIZE: number;
  28023. /**
  28024. * Get the Quaternion animation type
  28025. */
  28026. static readonly ANIMATIONTYPE_QUATERNION: number;
  28027. /**
  28028. * Get the Matrix animation type
  28029. */
  28030. static readonly ANIMATIONTYPE_MATRIX: number;
  28031. /**
  28032. * Get the Color3 animation type
  28033. */
  28034. static readonly ANIMATIONTYPE_COLOR3: number;
  28035. /**
  28036. * Get the Relative Loop Mode
  28037. */
  28038. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28039. /**
  28040. * Get the Cycle Loop Mode
  28041. */
  28042. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28043. /**
  28044. * Get the Constant Loop Mode
  28045. */
  28046. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28047. /** @hidden */
  28048. static _UniversalLerp(left: any, right: any, amount: number): any;
  28049. /**
  28050. * Parses an animation object and creates an animation
  28051. * @param parsedAnimation Parsed animation object
  28052. * @returns Animation object
  28053. */
  28054. static Parse(parsedAnimation: any): Animation;
  28055. /**
  28056. * Appends the serialized animations from the source animations
  28057. * @param source Source containing the animations
  28058. * @param destination Target to store the animations
  28059. */
  28060. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28061. }
  28062. }
  28063. declare module "babylonjs/Animations/animatable.interface" {
  28064. import { Nullable } from "babylonjs/types";
  28065. import { Animation } from "babylonjs/Animations/animation";
  28066. /**
  28067. * Interface containing an array of animations
  28068. */
  28069. export interface IAnimatable {
  28070. /**
  28071. * Array of animations
  28072. */
  28073. animations: Nullable<Array<Animation>>;
  28074. }
  28075. }
  28076. declare module "babylonjs/Materials/fresnelParameters" {
  28077. import { Color3 } from "babylonjs/Maths/math.color";
  28078. /**
  28079. * This represents all the required information to add a fresnel effect on a material:
  28080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28081. */
  28082. export class FresnelParameters {
  28083. private _isEnabled;
  28084. /**
  28085. * Define if the fresnel effect is enable or not.
  28086. */
  28087. isEnabled: boolean;
  28088. /**
  28089. * Define the color used on edges (grazing angle)
  28090. */
  28091. leftColor: Color3;
  28092. /**
  28093. * Define the color used on center
  28094. */
  28095. rightColor: Color3;
  28096. /**
  28097. * Define bias applied to computed fresnel term
  28098. */
  28099. bias: number;
  28100. /**
  28101. * Defined the power exponent applied to fresnel term
  28102. */
  28103. power: number;
  28104. /**
  28105. * Clones the current fresnel and its valuues
  28106. * @returns a clone fresnel configuration
  28107. */
  28108. clone(): FresnelParameters;
  28109. /**
  28110. * Serializes the current fresnel parameters to a JSON representation.
  28111. * @return the JSON serialization
  28112. */
  28113. serialize(): any;
  28114. /**
  28115. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28116. * @param parsedFresnelParameters Define the JSON representation
  28117. * @returns the parsed parameters
  28118. */
  28119. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28120. }
  28121. }
  28122. declare module "babylonjs/Misc/decorators" {
  28123. import { Nullable } from "babylonjs/types";
  28124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28125. import { Scene } from "babylonjs/scene";
  28126. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28127. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28128. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28129. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28130. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28131. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28132. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28133. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28134. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28135. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28136. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28137. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28138. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28139. /**
  28140. * Decorator used to define property that can be serialized as reference to a camera
  28141. * @param sourceName defines the name of the property to decorate
  28142. */
  28143. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28144. /**
  28145. * Class used to help serialization objects
  28146. */
  28147. export class SerializationHelper {
  28148. /** @hidden */
  28149. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28150. /** @hidden */
  28151. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28152. /** @hidden */
  28153. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28154. /** @hidden */
  28155. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28156. /**
  28157. * Appends the serialized animations from the source animations
  28158. * @param source Source containing the animations
  28159. * @param destination Target to store the animations
  28160. */
  28161. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28162. /**
  28163. * Static function used to serialized a specific entity
  28164. * @param entity defines the entity to serialize
  28165. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28166. * @returns a JSON compatible object representing the serialization of the entity
  28167. */
  28168. static Serialize<T>(entity: T, serializationObject?: any): any;
  28169. /**
  28170. * Creates a new entity from a serialization data object
  28171. * @param creationFunction defines a function used to instanciated the new entity
  28172. * @param source defines the source serialization data
  28173. * @param scene defines the hosting scene
  28174. * @param rootUrl defines the root url for resources
  28175. * @returns a new entity
  28176. */
  28177. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28178. /**
  28179. * Clones an object
  28180. * @param creationFunction defines the function used to instanciate the new object
  28181. * @param source defines the source object
  28182. * @returns the cloned object
  28183. */
  28184. static Clone<T>(creationFunction: () => T, source: T): T;
  28185. /**
  28186. * Instanciates a new object based on a source one (some data will be shared between both object)
  28187. * @param creationFunction defines the function used to instanciate the new object
  28188. * @param source defines the source object
  28189. * @returns the new object
  28190. */
  28191. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28192. }
  28193. }
  28194. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28195. import { Nullable } from "babylonjs/types";
  28196. /**
  28197. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28198. */
  28199. export interface CubeMapInfo {
  28200. /**
  28201. * The pixel array for the front face.
  28202. * This is stored in format, left to right, up to down format.
  28203. */
  28204. front: Nullable<ArrayBufferView>;
  28205. /**
  28206. * The pixel array for the back face.
  28207. * This is stored in format, left to right, up to down format.
  28208. */
  28209. back: Nullable<ArrayBufferView>;
  28210. /**
  28211. * The pixel array for the left face.
  28212. * This is stored in format, left to right, up to down format.
  28213. */
  28214. left: Nullable<ArrayBufferView>;
  28215. /**
  28216. * The pixel array for the right face.
  28217. * This is stored in format, left to right, up to down format.
  28218. */
  28219. right: Nullable<ArrayBufferView>;
  28220. /**
  28221. * The pixel array for the up face.
  28222. * This is stored in format, left to right, up to down format.
  28223. */
  28224. up: Nullable<ArrayBufferView>;
  28225. /**
  28226. * The pixel array for the down face.
  28227. * This is stored in format, left to right, up to down format.
  28228. */
  28229. down: Nullable<ArrayBufferView>;
  28230. /**
  28231. * The size of the cubemap stored.
  28232. *
  28233. * Each faces will be size * size pixels.
  28234. */
  28235. size: number;
  28236. /**
  28237. * The format of the texture.
  28238. *
  28239. * RGBA, RGB.
  28240. */
  28241. format: number;
  28242. /**
  28243. * The type of the texture data.
  28244. *
  28245. * UNSIGNED_INT, FLOAT.
  28246. */
  28247. type: number;
  28248. /**
  28249. * Specifies whether the texture is in gamma space.
  28250. */
  28251. gammaSpace: boolean;
  28252. }
  28253. /**
  28254. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28255. */
  28256. export class PanoramaToCubeMapTools {
  28257. private static FACE_FRONT;
  28258. private static FACE_BACK;
  28259. private static FACE_RIGHT;
  28260. private static FACE_LEFT;
  28261. private static FACE_DOWN;
  28262. private static FACE_UP;
  28263. /**
  28264. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28265. *
  28266. * @param float32Array The source data.
  28267. * @param inputWidth The width of the input panorama.
  28268. * @param inputHeight The height of the input panorama.
  28269. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28270. * @return The cubemap data
  28271. */
  28272. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28273. private static CreateCubemapTexture;
  28274. private static CalcProjectionSpherical;
  28275. }
  28276. }
  28277. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28278. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28280. import { Nullable } from "babylonjs/types";
  28281. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28282. /**
  28283. * Helper class dealing with the extraction of spherical polynomial dataArray
  28284. * from a cube map.
  28285. */
  28286. export class CubeMapToSphericalPolynomialTools {
  28287. private static FileFaces;
  28288. /**
  28289. * Converts a texture to the according Spherical Polynomial data.
  28290. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28291. *
  28292. * @param texture The texture to extract the information from.
  28293. * @return The Spherical Polynomial data.
  28294. */
  28295. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28296. /**
  28297. * Converts a cubemap to the according Spherical Polynomial data.
  28298. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28299. *
  28300. * @param cubeInfo The Cube map to extract the information from.
  28301. * @return The Spherical Polynomial data.
  28302. */
  28303. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28304. }
  28305. }
  28306. declare module "babylonjs/Misc/guid" {
  28307. /**
  28308. * Class used to manipulate GUIDs
  28309. */
  28310. export class GUID {
  28311. /**
  28312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28313. * Be aware Math.random() could cause collisions, but:
  28314. * "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"
  28315. * @returns a pseudo random id
  28316. */
  28317. static RandomId(): string;
  28318. }
  28319. }
  28320. declare module "babylonjs/Materials/Textures/baseTexture" {
  28321. import { Observable } from "babylonjs/Misc/observable";
  28322. import { Nullable } from "babylonjs/types";
  28323. import { Scene } from "babylonjs/scene";
  28324. import { Matrix } from "babylonjs/Maths/math.vector";
  28325. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28328. import { ISize } from "babylonjs/Maths/math.size";
  28329. /**
  28330. * Base class of all the textures in babylon.
  28331. * It groups all the common properties the materials, post process, lights... might need
  28332. * in order to make a correct use of the texture.
  28333. */
  28334. export class BaseTexture implements IAnimatable {
  28335. /**
  28336. * Default anisotropic filtering level for the application.
  28337. * It is set to 4 as a good tradeoff between perf and quality.
  28338. */
  28339. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28340. /**
  28341. * Gets or sets the unique id of the texture
  28342. */
  28343. uniqueId: number;
  28344. /**
  28345. * Define the name of the texture.
  28346. */
  28347. name: string;
  28348. /**
  28349. * Gets or sets an object used to store user defined information.
  28350. */
  28351. metadata: any;
  28352. /**
  28353. * For internal use only. Please do not use.
  28354. */
  28355. reservedDataStore: any;
  28356. private _hasAlpha;
  28357. /**
  28358. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28359. */
  28360. hasAlpha: boolean;
  28361. /**
  28362. * Defines if the alpha value should be determined via the rgb values.
  28363. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28364. */
  28365. getAlphaFromRGB: boolean;
  28366. /**
  28367. * Intensity or strength of the texture.
  28368. * It is commonly used by materials to fine tune the intensity of the texture
  28369. */
  28370. level: number;
  28371. /**
  28372. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28373. * This is part of the texture as textures usually maps to one uv set.
  28374. */
  28375. coordinatesIndex: number;
  28376. private _coordinatesMode;
  28377. /**
  28378. * How a texture is mapped.
  28379. *
  28380. * | Value | Type | Description |
  28381. * | ----- | ----------------------------------- | ----------- |
  28382. * | 0 | EXPLICIT_MODE | |
  28383. * | 1 | SPHERICAL_MODE | |
  28384. * | 2 | PLANAR_MODE | |
  28385. * | 3 | CUBIC_MODE | |
  28386. * | 4 | PROJECTION_MODE | |
  28387. * | 5 | SKYBOX_MODE | |
  28388. * | 6 | INVCUBIC_MODE | |
  28389. * | 7 | EQUIRECTANGULAR_MODE | |
  28390. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28391. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28392. */
  28393. coordinatesMode: number;
  28394. /**
  28395. * | Value | Type | Description |
  28396. * | ----- | ------------------ | ----------- |
  28397. * | 0 | CLAMP_ADDRESSMODE | |
  28398. * | 1 | WRAP_ADDRESSMODE | |
  28399. * | 2 | MIRROR_ADDRESSMODE | |
  28400. */
  28401. wrapU: number;
  28402. /**
  28403. * | Value | Type | Description |
  28404. * | ----- | ------------------ | ----------- |
  28405. * | 0 | CLAMP_ADDRESSMODE | |
  28406. * | 1 | WRAP_ADDRESSMODE | |
  28407. * | 2 | MIRROR_ADDRESSMODE | |
  28408. */
  28409. wrapV: number;
  28410. /**
  28411. * | Value | Type | Description |
  28412. * | ----- | ------------------ | ----------- |
  28413. * | 0 | CLAMP_ADDRESSMODE | |
  28414. * | 1 | WRAP_ADDRESSMODE | |
  28415. * | 2 | MIRROR_ADDRESSMODE | |
  28416. */
  28417. wrapR: number;
  28418. /**
  28419. * With compliant hardware and browser (supporting anisotropic filtering)
  28420. * this defines the level of anisotropic filtering in the texture.
  28421. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28422. */
  28423. anisotropicFilteringLevel: number;
  28424. /**
  28425. * Define if the texture is a cube texture or if false a 2d texture.
  28426. */
  28427. isCube: boolean;
  28428. /**
  28429. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28430. */
  28431. is3D: boolean;
  28432. /**
  28433. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28434. * HDR texture are usually stored in linear space.
  28435. * This only impacts the PBR and Background materials
  28436. */
  28437. gammaSpace: boolean;
  28438. /**
  28439. * Gets whether or not the texture contains RGBD data.
  28440. */
  28441. readonly isRGBD: boolean;
  28442. /**
  28443. * Is Z inverted in the texture (useful in a cube texture).
  28444. */
  28445. invertZ: boolean;
  28446. /**
  28447. * Are mip maps generated for this texture or not.
  28448. */
  28449. readonly noMipmap: boolean;
  28450. /**
  28451. * @hidden
  28452. */
  28453. lodLevelInAlpha: boolean;
  28454. /**
  28455. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28456. */
  28457. lodGenerationOffset: number;
  28458. /**
  28459. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28460. */
  28461. lodGenerationScale: number;
  28462. /**
  28463. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28464. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28465. * average roughness values.
  28466. */
  28467. linearSpecularLOD: boolean;
  28468. /**
  28469. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28470. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28471. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28472. */
  28473. irradianceTexture: Nullable<BaseTexture>;
  28474. /**
  28475. * Define if the texture is a render target.
  28476. */
  28477. isRenderTarget: boolean;
  28478. /**
  28479. * Define the unique id of the texture in the scene.
  28480. */
  28481. readonly uid: string;
  28482. /**
  28483. * Return a string representation of the texture.
  28484. * @returns the texture as a string
  28485. */
  28486. toString(): string;
  28487. /**
  28488. * Get the class name of the texture.
  28489. * @returns "BaseTexture"
  28490. */
  28491. getClassName(): string;
  28492. /**
  28493. * Define the list of animation attached to the texture.
  28494. */
  28495. animations: import("babylonjs/Animations/animation").Animation[];
  28496. /**
  28497. * An event triggered when the texture is disposed.
  28498. */
  28499. onDisposeObservable: Observable<BaseTexture>;
  28500. private _onDisposeObserver;
  28501. /**
  28502. * Callback triggered when the texture has been disposed.
  28503. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28504. */
  28505. onDispose: () => void;
  28506. /**
  28507. * Define the current state of the loading sequence when in delayed load mode.
  28508. */
  28509. delayLoadState: number;
  28510. private _scene;
  28511. /** @hidden */
  28512. _texture: Nullable<InternalTexture>;
  28513. private _uid;
  28514. /**
  28515. * Define if the texture is preventinga material to render or not.
  28516. * If not and the texture is not ready, the engine will use a default black texture instead.
  28517. */
  28518. readonly isBlocking: boolean;
  28519. /**
  28520. * Instantiates a new BaseTexture.
  28521. * Base class of all the textures in babylon.
  28522. * It groups all the common properties the materials, post process, lights... might need
  28523. * in order to make a correct use of the texture.
  28524. * @param scene Define the scene the texture blongs to
  28525. */
  28526. constructor(scene: Nullable<Scene>);
  28527. /**
  28528. * Get the scene the texture belongs to.
  28529. * @returns the scene or null if undefined
  28530. */
  28531. getScene(): Nullable<Scene>;
  28532. /**
  28533. * Get the texture transform matrix used to offset tile the texture for istance.
  28534. * @returns the transformation matrix
  28535. */
  28536. getTextureMatrix(): Matrix;
  28537. /**
  28538. * Get the texture reflection matrix used to rotate/transform the reflection.
  28539. * @returns the reflection matrix
  28540. */
  28541. getReflectionTextureMatrix(): Matrix;
  28542. /**
  28543. * Get the underlying lower level texture from Babylon.
  28544. * @returns the insternal texture
  28545. */
  28546. getInternalTexture(): Nullable<InternalTexture>;
  28547. /**
  28548. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28549. * @returns true if ready or not blocking
  28550. */
  28551. isReadyOrNotBlocking(): boolean;
  28552. /**
  28553. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28554. * @returns true if fully ready
  28555. */
  28556. isReady(): boolean;
  28557. private _cachedSize;
  28558. /**
  28559. * Get the size of the texture.
  28560. * @returns the texture size.
  28561. */
  28562. getSize(): ISize;
  28563. /**
  28564. * Get the base size of the texture.
  28565. * It can be different from the size if the texture has been resized for POT for instance
  28566. * @returns the base size
  28567. */
  28568. getBaseSize(): ISize;
  28569. /**
  28570. * Update the sampling mode of the texture.
  28571. * Default is Trilinear mode.
  28572. *
  28573. * | Value | Type | Description |
  28574. * | ----- | ------------------ | ----------- |
  28575. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28576. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28577. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28578. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28579. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28580. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28581. * | 7 | NEAREST_LINEAR | |
  28582. * | 8 | NEAREST_NEAREST | |
  28583. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28584. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28585. * | 11 | LINEAR_LINEAR | |
  28586. * | 12 | LINEAR_NEAREST | |
  28587. *
  28588. * > _mag_: magnification filter (close to the viewer)
  28589. * > _min_: minification filter (far from the viewer)
  28590. * > _mip_: filter used between mip map levels
  28591. *@param samplingMode Define the new sampling mode of the texture
  28592. */
  28593. updateSamplingMode(samplingMode: number): void;
  28594. /**
  28595. * Scales the texture if is `canRescale()`
  28596. * @param ratio the resize factor we want to use to rescale
  28597. */
  28598. scale(ratio: number): void;
  28599. /**
  28600. * Get if the texture can rescale.
  28601. */
  28602. readonly canRescale: boolean;
  28603. /** @hidden */
  28604. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28605. /** @hidden */
  28606. _rebuild(): void;
  28607. /**
  28608. * Triggers the load sequence in delayed load mode.
  28609. */
  28610. delayLoad(): void;
  28611. /**
  28612. * Clones the texture.
  28613. * @returns the cloned texture
  28614. */
  28615. clone(): Nullable<BaseTexture>;
  28616. /**
  28617. * Get the texture underlying type (INT, FLOAT...)
  28618. */
  28619. readonly textureType: number;
  28620. /**
  28621. * Get the texture underlying format (RGB, RGBA...)
  28622. */
  28623. readonly textureFormat: number;
  28624. /**
  28625. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28626. * This will returns an RGBA array buffer containing either in values (0-255) or
  28627. * float values (0-1) depending of the underlying buffer type.
  28628. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28629. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28630. * @param buffer defines a user defined buffer to fill with data (can be null)
  28631. * @returns The Array buffer containing the pixels data.
  28632. */
  28633. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28634. /**
  28635. * Release and destroy the underlying lower level texture aka internalTexture.
  28636. */
  28637. releaseInternalTexture(): void;
  28638. /**
  28639. * Get the polynomial representation of the texture data.
  28640. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28641. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28642. */
  28643. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28644. /** @hidden */
  28645. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28646. /** @hidden */
  28647. readonly _lodTextureMid: Nullable<BaseTexture>;
  28648. /** @hidden */
  28649. readonly _lodTextureLow: Nullable<BaseTexture>;
  28650. /**
  28651. * Dispose the texture and release its associated resources.
  28652. */
  28653. dispose(): void;
  28654. /**
  28655. * Serialize the texture into a JSON representation that can be parsed later on.
  28656. * @returns the JSON representation of the texture
  28657. */
  28658. serialize(): any;
  28659. /**
  28660. * Helper function to be called back once a list of texture contains only ready textures.
  28661. * @param textures Define the list of textures to wait for
  28662. * @param callback Define the callback triggered once the entire list will be ready
  28663. */
  28664. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28665. }
  28666. }
  28667. declare module "babylonjs/Materials/Textures/internalTexture" {
  28668. import { Observable } from "babylonjs/Misc/observable";
  28669. import { Nullable, int } from "babylonjs/types";
  28670. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28671. import { Engine } from "babylonjs/Engines/engine";
  28672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28673. /**
  28674. * Class used to store data associated with WebGL texture data for the engine
  28675. * This class should not be used directly
  28676. */
  28677. export class InternalTexture {
  28678. /** @hidden */
  28679. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28680. /**
  28681. * The source of the texture data is unknown
  28682. */
  28683. static DATASOURCE_UNKNOWN: number;
  28684. /**
  28685. * Texture data comes from an URL
  28686. */
  28687. static DATASOURCE_URL: number;
  28688. /**
  28689. * Texture data is only used for temporary storage
  28690. */
  28691. static DATASOURCE_TEMP: number;
  28692. /**
  28693. * Texture data comes from raw data (ArrayBuffer)
  28694. */
  28695. static DATASOURCE_RAW: number;
  28696. /**
  28697. * Texture content is dynamic (video or dynamic texture)
  28698. */
  28699. static DATASOURCE_DYNAMIC: number;
  28700. /**
  28701. * Texture content is generated by rendering to it
  28702. */
  28703. static DATASOURCE_RENDERTARGET: number;
  28704. /**
  28705. * Texture content is part of a multi render target process
  28706. */
  28707. static DATASOURCE_MULTIRENDERTARGET: number;
  28708. /**
  28709. * Texture data comes from a cube data file
  28710. */
  28711. static DATASOURCE_CUBE: number;
  28712. /**
  28713. * Texture data comes from a raw cube data
  28714. */
  28715. static DATASOURCE_CUBERAW: number;
  28716. /**
  28717. * Texture data come from a prefiltered cube data file
  28718. */
  28719. static DATASOURCE_CUBEPREFILTERED: number;
  28720. /**
  28721. * Texture content is raw 3D data
  28722. */
  28723. static DATASOURCE_RAW3D: number;
  28724. /**
  28725. * Texture content is a depth texture
  28726. */
  28727. static DATASOURCE_DEPTHTEXTURE: number;
  28728. /**
  28729. * Texture data comes from a raw cube data encoded with RGBD
  28730. */
  28731. static DATASOURCE_CUBERAW_RGBD: number;
  28732. /**
  28733. * Defines if the texture is ready
  28734. */
  28735. isReady: boolean;
  28736. /**
  28737. * Defines if the texture is a cube texture
  28738. */
  28739. isCube: boolean;
  28740. /**
  28741. * Defines if the texture contains 3D data
  28742. */
  28743. is3D: boolean;
  28744. /**
  28745. * Defines if the texture contains multiview data
  28746. */
  28747. isMultiview: boolean;
  28748. /**
  28749. * Gets the URL used to load this texture
  28750. */
  28751. url: string;
  28752. /**
  28753. * Gets the sampling mode of the texture
  28754. */
  28755. samplingMode: number;
  28756. /**
  28757. * Gets a boolean indicating if the texture needs mipmaps generation
  28758. */
  28759. generateMipMaps: boolean;
  28760. /**
  28761. * Gets the number of samples used by the texture (WebGL2+ only)
  28762. */
  28763. samples: number;
  28764. /**
  28765. * Gets the type of the texture (int, float...)
  28766. */
  28767. type: number;
  28768. /**
  28769. * Gets the format of the texture (RGB, RGBA...)
  28770. */
  28771. format: number;
  28772. /**
  28773. * Observable called when the texture is loaded
  28774. */
  28775. onLoadedObservable: Observable<InternalTexture>;
  28776. /**
  28777. * Gets the width of the texture
  28778. */
  28779. width: number;
  28780. /**
  28781. * Gets the height of the texture
  28782. */
  28783. height: number;
  28784. /**
  28785. * Gets the depth of the texture
  28786. */
  28787. depth: number;
  28788. /**
  28789. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28790. */
  28791. baseWidth: number;
  28792. /**
  28793. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28794. */
  28795. baseHeight: number;
  28796. /**
  28797. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28798. */
  28799. baseDepth: number;
  28800. /**
  28801. * Gets a boolean indicating if the texture is inverted on Y axis
  28802. */
  28803. invertY: boolean;
  28804. /** @hidden */
  28805. _invertVScale: boolean;
  28806. /** @hidden */
  28807. _associatedChannel: number;
  28808. /** @hidden */
  28809. _dataSource: number;
  28810. /** @hidden */
  28811. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28812. /** @hidden */
  28813. _bufferView: Nullable<ArrayBufferView>;
  28814. /** @hidden */
  28815. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28816. /** @hidden */
  28817. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28818. /** @hidden */
  28819. _size: number;
  28820. /** @hidden */
  28821. _extension: string;
  28822. /** @hidden */
  28823. _files: Nullable<string[]>;
  28824. /** @hidden */
  28825. _workingCanvas: Nullable<HTMLCanvasElement>;
  28826. /** @hidden */
  28827. _workingContext: Nullable<CanvasRenderingContext2D>;
  28828. /** @hidden */
  28829. _framebuffer: Nullable<WebGLFramebuffer>;
  28830. /** @hidden */
  28831. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28832. /** @hidden */
  28833. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28834. /** @hidden */
  28835. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28836. /** @hidden */
  28837. _attachments: Nullable<number[]>;
  28838. /** @hidden */
  28839. _cachedCoordinatesMode: Nullable<number>;
  28840. /** @hidden */
  28841. _cachedWrapU: Nullable<number>;
  28842. /** @hidden */
  28843. _cachedWrapV: Nullable<number>;
  28844. /** @hidden */
  28845. _cachedWrapR: Nullable<number>;
  28846. /** @hidden */
  28847. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28848. /** @hidden */
  28849. _isDisabled: boolean;
  28850. /** @hidden */
  28851. _compression: Nullable<string>;
  28852. /** @hidden */
  28853. _generateStencilBuffer: boolean;
  28854. /** @hidden */
  28855. _generateDepthBuffer: boolean;
  28856. /** @hidden */
  28857. _comparisonFunction: number;
  28858. /** @hidden */
  28859. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28860. /** @hidden */
  28861. _lodGenerationScale: number;
  28862. /** @hidden */
  28863. _lodGenerationOffset: number;
  28864. /** @hidden */
  28865. _colorTextureArray: Nullable<WebGLTexture>;
  28866. /** @hidden */
  28867. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28868. /** @hidden */
  28869. _lodTextureHigh: Nullable<BaseTexture>;
  28870. /** @hidden */
  28871. _lodTextureMid: Nullable<BaseTexture>;
  28872. /** @hidden */
  28873. _lodTextureLow: Nullable<BaseTexture>;
  28874. /** @hidden */
  28875. _isRGBD: boolean;
  28876. /** @hidden */
  28877. _linearSpecularLOD: boolean;
  28878. /** @hidden */
  28879. _irradianceTexture: Nullable<BaseTexture>;
  28880. /** @hidden */
  28881. _webGLTexture: Nullable<WebGLTexture>;
  28882. /** @hidden */
  28883. _references: number;
  28884. private _engine;
  28885. /**
  28886. * Gets the Engine the texture belongs to.
  28887. * @returns The babylon engine
  28888. */
  28889. getEngine(): Engine;
  28890. /**
  28891. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28892. */
  28893. readonly dataSource: number;
  28894. /**
  28895. * Creates a new InternalTexture
  28896. * @param engine defines the engine to use
  28897. * @param dataSource defines the type of data that will be used
  28898. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28899. */
  28900. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28901. /**
  28902. * Increments the number of references (ie. the number of Texture that point to it)
  28903. */
  28904. incrementReferences(): void;
  28905. /**
  28906. * Change the size of the texture (not the size of the content)
  28907. * @param width defines the new width
  28908. * @param height defines the new height
  28909. * @param depth defines the new depth (1 by default)
  28910. */
  28911. updateSize(width: int, height: int, depth?: int): void;
  28912. /** @hidden */
  28913. _rebuild(): void;
  28914. /** @hidden */
  28915. _swapAndDie(target: InternalTexture): void;
  28916. /**
  28917. * Dispose the current allocated resources
  28918. */
  28919. dispose(): void;
  28920. }
  28921. }
  28922. declare module "babylonjs/Materials/effect" {
  28923. import { Observable } from "babylonjs/Misc/observable";
  28924. import { Nullable } from "babylonjs/types";
  28925. import { IDisposable } from "babylonjs/scene";
  28926. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28927. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28928. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28929. import { Engine } from "babylonjs/Engines/engine";
  28930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28935. /**
  28936. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28937. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28938. */
  28939. export class EffectFallbacks {
  28940. private _defines;
  28941. private _currentRank;
  28942. private _maxRank;
  28943. private _mesh;
  28944. /**
  28945. * Removes the fallback from the bound mesh.
  28946. */
  28947. unBindMesh(): void;
  28948. /**
  28949. * Adds a fallback on the specified property.
  28950. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28951. * @param define The name of the define in the shader
  28952. */
  28953. addFallback(rank: number, define: string): void;
  28954. /**
  28955. * Sets the mesh to use CPU skinning when needing to fallback.
  28956. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28957. * @param mesh The mesh to use the fallbacks.
  28958. */
  28959. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28960. /**
  28961. * Checks to see if more fallbacks are still availible.
  28962. */
  28963. readonly isMoreFallbacks: boolean;
  28964. /**
  28965. * Removes the defines that should be removed when falling back.
  28966. * @param currentDefines defines the current define statements for the shader.
  28967. * @param effect defines the current effect we try to compile
  28968. * @returns The resulting defines with defines of the current rank removed.
  28969. */
  28970. reduce(currentDefines: string, effect: Effect): string;
  28971. }
  28972. /**
  28973. * Options to be used when creating an effect.
  28974. */
  28975. export class EffectCreationOptions {
  28976. /**
  28977. * Atrributes that will be used in the shader.
  28978. */
  28979. attributes: string[];
  28980. /**
  28981. * Uniform varible names that will be set in the shader.
  28982. */
  28983. uniformsNames: string[];
  28984. /**
  28985. * Uniform buffer varible names that will be set in the shader.
  28986. */
  28987. uniformBuffersNames: string[];
  28988. /**
  28989. * Sampler texture variable names that will be set in the shader.
  28990. */
  28991. samplers: string[];
  28992. /**
  28993. * Define statements that will be set in the shader.
  28994. */
  28995. defines: any;
  28996. /**
  28997. * Possible fallbacks for this effect to improve performance when needed.
  28998. */
  28999. fallbacks: Nullable<EffectFallbacks>;
  29000. /**
  29001. * Callback that will be called when the shader is compiled.
  29002. */
  29003. onCompiled: Nullable<(effect: Effect) => void>;
  29004. /**
  29005. * Callback that will be called if an error occurs during shader compilation.
  29006. */
  29007. onError: Nullable<(effect: Effect, errors: string) => void>;
  29008. /**
  29009. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29010. */
  29011. indexParameters: any;
  29012. /**
  29013. * Max number of lights that can be used in the shader.
  29014. */
  29015. maxSimultaneousLights: number;
  29016. /**
  29017. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29018. */
  29019. transformFeedbackVaryings: Nullable<string[]>;
  29020. }
  29021. /**
  29022. * Effect containing vertex and fragment shader that can be executed on an object.
  29023. */
  29024. export class Effect implements IDisposable {
  29025. /**
  29026. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29027. */
  29028. static ShadersRepository: string;
  29029. /**
  29030. * Name of the effect.
  29031. */
  29032. name: any;
  29033. /**
  29034. * String container all the define statements that should be set on the shader.
  29035. */
  29036. defines: string;
  29037. /**
  29038. * Callback that will be called when the shader is compiled.
  29039. */
  29040. onCompiled: Nullable<(effect: Effect) => void>;
  29041. /**
  29042. * Callback that will be called if an error occurs during shader compilation.
  29043. */
  29044. onError: Nullable<(effect: Effect, errors: string) => void>;
  29045. /**
  29046. * Callback that will be called when effect is bound.
  29047. */
  29048. onBind: Nullable<(effect: Effect) => void>;
  29049. /**
  29050. * Unique ID of the effect.
  29051. */
  29052. uniqueId: number;
  29053. /**
  29054. * Observable that will be called when the shader is compiled.
  29055. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29056. */
  29057. onCompileObservable: Observable<Effect>;
  29058. /**
  29059. * Observable that will be called if an error occurs during shader compilation.
  29060. */
  29061. onErrorObservable: Observable<Effect>;
  29062. /** @hidden */
  29063. _onBindObservable: Nullable<Observable<Effect>>;
  29064. /**
  29065. * Observable that will be called when effect is bound.
  29066. */
  29067. readonly onBindObservable: Observable<Effect>;
  29068. /** @hidden */
  29069. _bonesComputationForcedToCPU: boolean;
  29070. private static _uniqueIdSeed;
  29071. private _engine;
  29072. private _uniformBuffersNames;
  29073. private _uniformsNames;
  29074. private _samplerList;
  29075. private _samplers;
  29076. private _isReady;
  29077. private _compilationError;
  29078. private _attributesNames;
  29079. private _attributes;
  29080. private _uniforms;
  29081. /**
  29082. * Key for the effect.
  29083. * @hidden
  29084. */
  29085. _key: string;
  29086. private _indexParameters;
  29087. private _fallbacks;
  29088. private _vertexSourceCode;
  29089. private _fragmentSourceCode;
  29090. private _vertexSourceCodeOverride;
  29091. private _fragmentSourceCodeOverride;
  29092. private _transformFeedbackVaryings;
  29093. /**
  29094. * Compiled shader to webGL program.
  29095. * @hidden
  29096. */
  29097. _pipelineContext: Nullable<IPipelineContext>;
  29098. private _valueCache;
  29099. private static _baseCache;
  29100. /**
  29101. * Instantiates an effect.
  29102. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29103. * @param baseName Name of the effect.
  29104. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29105. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29106. * @param samplers List of sampler variables that will be passed to the shader.
  29107. * @param engine Engine to be used to render the effect
  29108. * @param defines Define statements to be added to the shader.
  29109. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29110. * @param onCompiled Callback that will be called when the shader is compiled.
  29111. * @param onError Callback that will be called if an error occurs during shader compilation.
  29112. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29113. */
  29114. 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);
  29115. private _useFinalCode;
  29116. /**
  29117. * Unique key for this effect
  29118. */
  29119. readonly key: string;
  29120. /**
  29121. * If the effect has been compiled and prepared.
  29122. * @returns if the effect is compiled and prepared.
  29123. */
  29124. isReady(): boolean;
  29125. /**
  29126. * The engine the effect was initialized with.
  29127. * @returns the engine.
  29128. */
  29129. getEngine(): Engine;
  29130. /**
  29131. * The pipeline context for this effect
  29132. * @returns the associated pipeline context
  29133. */
  29134. getPipelineContext(): Nullable<IPipelineContext>;
  29135. /**
  29136. * The set of names of attribute variables for the shader.
  29137. * @returns An array of attribute names.
  29138. */
  29139. getAttributesNames(): string[];
  29140. /**
  29141. * Returns the attribute at the given index.
  29142. * @param index The index of the attribute.
  29143. * @returns The location of the attribute.
  29144. */
  29145. getAttributeLocation(index: number): number;
  29146. /**
  29147. * Returns the attribute based on the name of the variable.
  29148. * @param name of the attribute to look up.
  29149. * @returns the attribute location.
  29150. */
  29151. getAttributeLocationByName(name: string): number;
  29152. /**
  29153. * The number of attributes.
  29154. * @returns the numnber of attributes.
  29155. */
  29156. getAttributesCount(): number;
  29157. /**
  29158. * Gets the index of a uniform variable.
  29159. * @param uniformName of the uniform to look up.
  29160. * @returns the index.
  29161. */
  29162. getUniformIndex(uniformName: string): number;
  29163. /**
  29164. * Returns the attribute based on the name of the variable.
  29165. * @param uniformName of the uniform to look up.
  29166. * @returns the location of the uniform.
  29167. */
  29168. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29169. /**
  29170. * Returns an array of sampler variable names
  29171. * @returns The array of sampler variable neames.
  29172. */
  29173. getSamplers(): string[];
  29174. /**
  29175. * The error from the last compilation.
  29176. * @returns the error string.
  29177. */
  29178. getCompilationError(): string;
  29179. /**
  29180. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29181. * @param func The callback to be used.
  29182. */
  29183. executeWhenCompiled(func: (effect: Effect) => void): void;
  29184. private _checkIsReady;
  29185. /** @hidden */
  29186. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29187. /** @hidden */
  29188. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29189. /** @hidden */
  29190. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29191. /**
  29192. * Recompiles the webGL program
  29193. * @param vertexSourceCode The source code for the vertex shader.
  29194. * @param fragmentSourceCode The source code for the fragment shader.
  29195. * @param onCompiled Callback called when completed.
  29196. * @param onError Callback called on error.
  29197. * @hidden
  29198. */
  29199. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29200. /**
  29201. * Prepares the effect
  29202. * @hidden
  29203. */
  29204. _prepareEffect(): void;
  29205. private _processCompilationErrors;
  29206. /**
  29207. * Checks if the effect is supported. (Must be called after compilation)
  29208. */
  29209. readonly isSupported: boolean;
  29210. /**
  29211. * Binds a texture to the engine to be used as output of the shader.
  29212. * @param channel Name of the output variable.
  29213. * @param texture Texture to bind.
  29214. * @hidden
  29215. */
  29216. _bindTexture(channel: string, texture: InternalTexture): void;
  29217. /**
  29218. * Sets a texture on the engine to be used in the shader.
  29219. * @param channel Name of the sampler variable.
  29220. * @param texture Texture to set.
  29221. */
  29222. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29223. /**
  29224. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29225. * @param channel Name of the sampler variable.
  29226. * @param texture Texture to set.
  29227. */
  29228. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29229. /**
  29230. * Sets an array of textures on the engine to be used in the shader.
  29231. * @param channel Name of the variable.
  29232. * @param textures Textures to set.
  29233. */
  29234. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29235. /**
  29236. * 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)
  29237. * @param channel Name of the sampler variable.
  29238. * @param postProcess Post process to get the input texture from.
  29239. */
  29240. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29241. /**
  29242. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29243. * 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)
  29244. * @param channel Name of the sampler variable.
  29245. * @param postProcess Post process to get the output texture from.
  29246. */
  29247. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29248. /** @hidden */
  29249. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29250. /** @hidden */
  29251. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29252. /** @hidden */
  29253. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29254. /** @hidden */
  29255. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29256. /**
  29257. * Binds a buffer to a uniform.
  29258. * @param buffer Buffer to bind.
  29259. * @param name Name of the uniform variable to bind to.
  29260. */
  29261. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29262. /**
  29263. * Binds block to a uniform.
  29264. * @param blockName Name of the block to bind.
  29265. * @param index Index to bind.
  29266. */
  29267. bindUniformBlock(blockName: string, index: number): void;
  29268. /**
  29269. * Sets an interger value on a uniform variable.
  29270. * @param uniformName Name of the variable.
  29271. * @param value Value to be set.
  29272. * @returns this effect.
  29273. */
  29274. setInt(uniformName: string, value: number): Effect;
  29275. /**
  29276. * Sets an int array on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setIntArray(uniformName: string, array: Int32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29303. /**
  29304. * Sets an float array on a uniform variable.
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29324. /**
  29325. * 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)
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29331. /**
  29332. * Sets an array on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param array array to be set.
  29335. * @returns this effect.
  29336. */
  29337. setArray(uniformName: string, array: number[]): Effect;
  29338. /**
  29339. * 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)
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setArray2(uniformName: string, array: number[]): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param array array to be set.
  29349. * @returns this effect.
  29350. */
  29351. setArray3(uniformName: string, array: number[]): Effect;
  29352. /**
  29353. * 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)
  29354. * @param uniformName Name of the variable.
  29355. * @param array array to be set.
  29356. * @returns this effect.
  29357. */
  29358. setArray4(uniformName: string, array: number[]): Effect;
  29359. /**
  29360. * Sets matrices on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param matrices matrices to be set.
  29363. * @returns this effect.
  29364. */
  29365. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29366. /**
  29367. * Sets matrix on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param matrix matrix to be set.
  29370. * @returns this effect.
  29371. */
  29372. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29373. /**
  29374. * 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)
  29375. * @param uniformName Name of the variable.
  29376. * @param matrix matrix to be set.
  29377. * @returns this effect.
  29378. */
  29379. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29380. /**
  29381. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29382. * @param uniformName Name of the variable.
  29383. * @param matrix matrix to be set.
  29384. * @returns this effect.
  29385. */
  29386. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29387. /**
  29388. * Sets a float on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param value value to be set.
  29391. * @returns this effect.
  29392. */
  29393. setFloat(uniformName: string, value: number): Effect;
  29394. /**
  29395. * Sets a boolean on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param bool value to be set.
  29398. * @returns this effect.
  29399. */
  29400. setBool(uniformName: string, bool: boolean): Effect;
  29401. /**
  29402. * Sets a Vector2 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param vector2 vector2 to be set.
  29405. * @returns this effect.
  29406. */
  29407. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29408. /**
  29409. * Sets a float2 on a uniform variable.
  29410. * @param uniformName Name of the variable.
  29411. * @param x First float in float2.
  29412. * @param y Second float in float2.
  29413. * @returns this effect.
  29414. */
  29415. setFloat2(uniformName: string, x: number, y: number): Effect;
  29416. /**
  29417. * Sets a Vector3 on a uniform variable.
  29418. * @param uniformName Name of the variable.
  29419. * @param vector3 Value to be set.
  29420. * @returns this effect.
  29421. */
  29422. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29423. /**
  29424. * Sets a float3 on a uniform variable.
  29425. * @param uniformName Name of the variable.
  29426. * @param x First float in float3.
  29427. * @param y Second float in float3.
  29428. * @param z Third float in float3.
  29429. * @returns this effect.
  29430. */
  29431. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29432. /**
  29433. * Sets a Vector4 on a uniform variable.
  29434. * @param uniformName Name of the variable.
  29435. * @param vector4 Value to be set.
  29436. * @returns this effect.
  29437. */
  29438. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29439. /**
  29440. * Sets a float4 on a uniform variable.
  29441. * @param uniformName Name of the variable.
  29442. * @param x First float in float4.
  29443. * @param y Second float in float4.
  29444. * @param z Third float in float4.
  29445. * @param w Fourth float in float4.
  29446. * @returns this effect.
  29447. */
  29448. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29449. /**
  29450. * Sets a Color3 on a uniform variable.
  29451. * @param uniformName Name of the variable.
  29452. * @param color3 Value to be set.
  29453. * @returns this effect.
  29454. */
  29455. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29456. /**
  29457. * Sets a Color4 on a uniform variable.
  29458. * @param uniformName Name of the variable.
  29459. * @param color3 Value to be set.
  29460. * @param alpha Alpha value to be set.
  29461. * @returns this effect.
  29462. */
  29463. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29464. /**
  29465. * Sets a Color4 on a uniform variable
  29466. * @param uniformName defines the name of the variable
  29467. * @param color4 defines the value to be set
  29468. * @returns this effect.
  29469. */
  29470. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29471. /** Release all associated resources */
  29472. dispose(): void;
  29473. /**
  29474. * This function will add a new shader to the shader store
  29475. * @param name the name of the shader
  29476. * @param pixelShader optional pixel shader content
  29477. * @param vertexShader optional vertex shader content
  29478. */
  29479. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29480. /**
  29481. * Store of each shader (The can be looked up using effect.key)
  29482. */
  29483. static ShadersStore: {
  29484. [key: string]: string;
  29485. };
  29486. /**
  29487. * Store of each included file for a shader (The can be looked up using effect.key)
  29488. */
  29489. static IncludesShadersStore: {
  29490. [key: string]: string;
  29491. };
  29492. /**
  29493. * Resets the cache of effects.
  29494. */
  29495. static ResetCache(): void;
  29496. }
  29497. }
  29498. declare module "babylonjs/Materials/uniformBuffer" {
  29499. import { Nullable, FloatArray } from "babylonjs/types";
  29500. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29501. import { Engine } from "babylonjs/Engines/engine";
  29502. import { Effect } from "babylonjs/Materials/effect";
  29503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29504. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29505. import { Color3 } from "babylonjs/Maths/math.color";
  29506. /**
  29507. * Uniform buffer objects.
  29508. *
  29509. * Handles blocks of uniform on the GPU.
  29510. *
  29511. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29512. *
  29513. * For more information, please refer to :
  29514. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29515. */
  29516. export class UniformBuffer {
  29517. private _engine;
  29518. private _buffer;
  29519. private _data;
  29520. private _bufferData;
  29521. private _dynamic?;
  29522. private _uniformLocations;
  29523. private _uniformSizes;
  29524. private _uniformLocationPointer;
  29525. private _needSync;
  29526. private _noUBO;
  29527. private _currentEffect;
  29528. private static _MAX_UNIFORM_SIZE;
  29529. private static _tempBuffer;
  29530. /**
  29531. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29532. * This is dynamic to allow compat with webgl 1 and 2.
  29533. * You will need to pass the name of the uniform as well as the value.
  29534. */
  29535. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29536. /**
  29537. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29538. * This is dynamic to allow compat with webgl 1 and 2.
  29539. * You will need to pass the name of the uniform as well as the value.
  29540. */
  29541. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29542. /**
  29543. * Lambda to Update a single float in a uniform buffer.
  29544. * This is dynamic to allow compat with webgl 1 and 2.
  29545. * You will need to pass the name of the uniform as well as the value.
  29546. */
  29547. updateFloat: (name: string, x: number) => void;
  29548. /**
  29549. * Lambda to Update a vec2 of float in a uniform buffer.
  29550. * This is dynamic to allow compat with webgl 1 and 2.
  29551. * You will need to pass the name of the uniform as well as the value.
  29552. */
  29553. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29554. /**
  29555. * Lambda to Update a vec3 of float in a uniform buffer.
  29556. * This is dynamic to allow compat with webgl 1 and 2.
  29557. * You will need to pass the name of the uniform as well as the value.
  29558. */
  29559. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29560. /**
  29561. * Lambda to Update a vec4 of float in a uniform buffer.
  29562. * This is dynamic to allow compat with webgl 1 and 2.
  29563. * You will need to pass the name of the uniform as well as the value.
  29564. */
  29565. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29566. /**
  29567. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29568. * This is dynamic to allow compat with webgl 1 and 2.
  29569. * You will need to pass the name of the uniform as well as the value.
  29570. */
  29571. updateMatrix: (name: string, mat: Matrix) => void;
  29572. /**
  29573. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29574. * This is dynamic to allow compat with webgl 1 and 2.
  29575. * You will need to pass the name of the uniform as well as the value.
  29576. */
  29577. updateVector3: (name: string, vector: Vector3) => void;
  29578. /**
  29579. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29580. * This is dynamic to allow compat with webgl 1 and 2.
  29581. * You will need to pass the name of the uniform as well as the value.
  29582. */
  29583. updateVector4: (name: string, vector: Vector4) => void;
  29584. /**
  29585. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29586. * This is dynamic to allow compat with webgl 1 and 2.
  29587. * You will need to pass the name of the uniform as well as the value.
  29588. */
  29589. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29590. /**
  29591. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29592. * This is dynamic to allow compat with webgl 1 and 2.
  29593. * You will need to pass the name of the uniform as well as the value.
  29594. */
  29595. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29596. /**
  29597. * Instantiates a new Uniform buffer objects.
  29598. *
  29599. * Handles blocks of uniform on the GPU.
  29600. *
  29601. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29602. *
  29603. * For more information, please refer to :
  29604. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29605. * @param engine Define the engine the buffer is associated with
  29606. * @param data Define the data contained in the buffer
  29607. * @param dynamic Define if the buffer is updatable
  29608. */
  29609. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29610. /**
  29611. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29612. * or just falling back on setUniformXXX calls.
  29613. */
  29614. readonly useUbo: boolean;
  29615. /**
  29616. * Indicates if the WebGL underlying uniform buffer is in sync
  29617. * with the javascript cache data.
  29618. */
  29619. readonly isSync: boolean;
  29620. /**
  29621. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29622. * Also, a dynamic UniformBuffer will disable cache verification and always
  29623. * update the underlying WebGL uniform buffer to the GPU.
  29624. * @returns if Dynamic, otherwise false
  29625. */
  29626. isDynamic(): boolean;
  29627. /**
  29628. * The data cache on JS side.
  29629. * @returns the underlying data as a float array
  29630. */
  29631. getData(): Float32Array;
  29632. /**
  29633. * The underlying WebGL Uniform buffer.
  29634. * @returns the webgl buffer
  29635. */
  29636. getBuffer(): Nullable<DataBuffer>;
  29637. /**
  29638. * std140 layout specifies how to align data within an UBO structure.
  29639. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29640. * for specs.
  29641. */
  29642. private _fillAlignment;
  29643. /**
  29644. * Adds an uniform in the buffer.
  29645. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29646. * for the layout to be correct !
  29647. * @param name Name of the uniform, as used in the uniform block in the shader.
  29648. * @param size Data size, or data directly.
  29649. */
  29650. addUniform(name: string, size: number | number[]): void;
  29651. /**
  29652. * Adds a Matrix 4x4 to the uniform buffer.
  29653. * @param name Name of the uniform, as used in the uniform block in the shader.
  29654. * @param mat A 4x4 matrix.
  29655. */
  29656. addMatrix(name: string, mat: Matrix): void;
  29657. /**
  29658. * Adds a vec2 to the uniform buffer.
  29659. * @param name Name of the uniform, as used in the uniform block in the shader.
  29660. * @param x Define the x component value of the vec2
  29661. * @param y Define the y component value of the vec2
  29662. */
  29663. addFloat2(name: string, x: number, y: number): void;
  29664. /**
  29665. * Adds a vec3 to the uniform buffer.
  29666. * @param name Name of the uniform, as used in the uniform block in the shader.
  29667. * @param x Define the x component value of the vec3
  29668. * @param y Define the y component value of the vec3
  29669. * @param z Define the z component value of the vec3
  29670. */
  29671. addFloat3(name: string, x: number, y: number, z: number): void;
  29672. /**
  29673. * Adds a vec3 to the uniform buffer.
  29674. * @param name Name of the uniform, as used in the uniform block in the shader.
  29675. * @param color Define the vec3 from a Color
  29676. */
  29677. addColor3(name: string, color: Color3): void;
  29678. /**
  29679. * Adds a vec4 to the uniform buffer.
  29680. * @param name Name of the uniform, as used in the uniform block in the shader.
  29681. * @param color Define the rgb components from a Color
  29682. * @param alpha Define the a component of the vec4
  29683. */
  29684. addColor4(name: string, color: Color3, alpha: number): void;
  29685. /**
  29686. * Adds a vec3 to the uniform buffer.
  29687. * @param name Name of the uniform, as used in the uniform block in the shader.
  29688. * @param vector Define the vec3 components from a Vector
  29689. */
  29690. addVector3(name: string, vector: Vector3): void;
  29691. /**
  29692. * Adds a Matrix 3x3 to the uniform buffer.
  29693. * @param name Name of the uniform, as used in the uniform block in the shader.
  29694. */
  29695. addMatrix3x3(name: string): void;
  29696. /**
  29697. * Adds a Matrix 2x2 to the uniform buffer.
  29698. * @param name Name of the uniform, as used in the uniform block in the shader.
  29699. */
  29700. addMatrix2x2(name: string): void;
  29701. /**
  29702. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29703. */
  29704. create(): void;
  29705. /** @hidden */
  29706. _rebuild(): void;
  29707. /**
  29708. * Updates the WebGL Uniform Buffer on the GPU.
  29709. * If the `dynamic` flag is set to true, no cache comparison is done.
  29710. * Otherwise, the buffer will be updated only if the cache differs.
  29711. */
  29712. update(): void;
  29713. /**
  29714. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29715. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29716. * @param data Define the flattened data
  29717. * @param size Define the size of the data.
  29718. */
  29719. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29720. private _valueCache;
  29721. private _cacheMatrix;
  29722. private _updateMatrix3x3ForUniform;
  29723. private _updateMatrix3x3ForEffect;
  29724. private _updateMatrix2x2ForEffect;
  29725. private _updateMatrix2x2ForUniform;
  29726. private _updateFloatForEffect;
  29727. private _updateFloatForUniform;
  29728. private _updateFloat2ForEffect;
  29729. private _updateFloat2ForUniform;
  29730. private _updateFloat3ForEffect;
  29731. private _updateFloat3ForUniform;
  29732. private _updateFloat4ForEffect;
  29733. private _updateFloat4ForUniform;
  29734. private _updateMatrixForEffect;
  29735. private _updateMatrixForUniform;
  29736. private _updateVector3ForEffect;
  29737. private _updateVector3ForUniform;
  29738. private _updateVector4ForEffect;
  29739. private _updateVector4ForUniform;
  29740. private _updateColor3ForEffect;
  29741. private _updateColor3ForUniform;
  29742. private _updateColor4ForEffect;
  29743. private _updateColor4ForUniform;
  29744. /**
  29745. * Sets a sampler uniform on the effect.
  29746. * @param name Define the name of the sampler.
  29747. * @param texture Define the texture to set in the sampler
  29748. */
  29749. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29750. /**
  29751. * Directly updates the value of the uniform in the cache AND on the GPU.
  29752. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29753. * @param data Define the flattened data
  29754. */
  29755. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29756. /**
  29757. * Binds this uniform buffer to an effect.
  29758. * @param effect Define the effect to bind the buffer to
  29759. * @param name Name of the uniform block in the shader.
  29760. */
  29761. bindToEffect(effect: Effect, name: string): void;
  29762. /**
  29763. * Disposes the uniform buffer.
  29764. */
  29765. dispose(): void;
  29766. }
  29767. }
  29768. declare module "babylonjs/Audio/analyser" {
  29769. import { Scene } from "babylonjs/scene";
  29770. /**
  29771. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29773. */
  29774. export class Analyser {
  29775. /**
  29776. * Gets or sets the smoothing
  29777. * @ignorenaming
  29778. */
  29779. SMOOTHING: number;
  29780. /**
  29781. * Gets or sets the FFT table size
  29782. * @ignorenaming
  29783. */
  29784. FFT_SIZE: number;
  29785. /**
  29786. * Gets or sets the bar graph amplitude
  29787. * @ignorenaming
  29788. */
  29789. BARGRAPHAMPLITUDE: number;
  29790. /**
  29791. * Gets or sets the position of the debug canvas
  29792. * @ignorenaming
  29793. */
  29794. DEBUGCANVASPOS: {
  29795. x: number;
  29796. y: number;
  29797. };
  29798. /**
  29799. * Gets or sets the debug canvas size
  29800. * @ignorenaming
  29801. */
  29802. DEBUGCANVASSIZE: {
  29803. width: number;
  29804. height: number;
  29805. };
  29806. private _byteFreqs;
  29807. private _byteTime;
  29808. private _floatFreqs;
  29809. private _webAudioAnalyser;
  29810. private _debugCanvas;
  29811. private _debugCanvasContext;
  29812. private _scene;
  29813. private _registerFunc;
  29814. private _audioEngine;
  29815. /**
  29816. * Creates a new analyser
  29817. * @param scene defines hosting scene
  29818. */
  29819. constructor(scene: Scene);
  29820. /**
  29821. * Get the number of data values you will have to play with for the visualization
  29822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29823. * @returns a number
  29824. */
  29825. getFrequencyBinCount(): number;
  29826. /**
  29827. * Gets the current frequency data as a byte array
  29828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29829. * @returns a Uint8Array
  29830. */
  29831. getByteFrequencyData(): Uint8Array;
  29832. /**
  29833. * Gets the current waveform as a byte array
  29834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29835. * @returns a Uint8Array
  29836. */
  29837. getByteTimeDomainData(): Uint8Array;
  29838. /**
  29839. * Gets the current frequency data as a float array
  29840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29841. * @returns a Float32Array
  29842. */
  29843. getFloatFrequencyData(): Float32Array;
  29844. /**
  29845. * Renders the debug canvas
  29846. */
  29847. drawDebugCanvas(): void;
  29848. /**
  29849. * Stops rendering the debug canvas and removes it
  29850. */
  29851. stopDebugCanvas(): void;
  29852. /**
  29853. * Connects two audio nodes
  29854. * @param inputAudioNode defines first node to connect
  29855. * @param outputAudioNode defines second node to connect
  29856. */
  29857. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29858. /**
  29859. * Releases all associated resources
  29860. */
  29861. dispose(): void;
  29862. }
  29863. }
  29864. declare module "babylonjs/Audio/audioEngine" {
  29865. import { IDisposable } from "babylonjs/scene";
  29866. import { Analyser } from "babylonjs/Audio/analyser";
  29867. import { Nullable } from "babylonjs/types";
  29868. import { Observable } from "babylonjs/Misc/observable";
  29869. /**
  29870. * This represents an audio engine and it is responsible
  29871. * to play, synchronize and analyse sounds throughout the application.
  29872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29873. */
  29874. export interface IAudioEngine extends IDisposable {
  29875. /**
  29876. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29877. */
  29878. readonly canUseWebAudio: boolean;
  29879. /**
  29880. * Gets the current AudioContext if available.
  29881. */
  29882. readonly audioContext: Nullable<AudioContext>;
  29883. /**
  29884. * The master gain node defines the global audio volume of your audio engine.
  29885. */
  29886. readonly masterGain: GainNode;
  29887. /**
  29888. * Gets whether or not mp3 are supported by your browser.
  29889. */
  29890. readonly isMP3supported: boolean;
  29891. /**
  29892. * Gets whether or not ogg are supported by your browser.
  29893. */
  29894. readonly isOGGsupported: boolean;
  29895. /**
  29896. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29897. * @ignoreNaming
  29898. */
  29899. WarnedWebAudioUnsupported: boolean;
  29900. /**
  29901. * Defines if the audio engine relies on a custom unlocked button.
  29902. * In this case, the embedded button will not be displayed.
  29903. */
  29904. useCustomUnlockedButton: boolean;
  29905. /**
  29906. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29907. */
  29908. readonly unlocked: boolean;
  29909. /**
  29910. * Event raised when audio has been unlocked on the browser.
  29911. */
  29912. onAudioUnlockedObservable: Observable<AudioEngine>;
  29913. /**
  29914. * Event raised when audio has been locked on the browser.
  29915. */
  29916. onAudioLockedObservable: Observable<AudioEngine>;
  29917. /**
  29918. * Flags the audio engine in Locked state.
  29919. * This happens due to new browser policies preventing audio to autoplay.
  29920. */
  29921. lock(): void;
  29922. /**
  29923. * Unlocks the audio engine once a user action has been done on the dom.
  29924. * This is helpful to resume play once browser policies have been satisfied.
  29925. */
  29926. unlock(): void;
  29927. }
  29928. /**
  29929. * This represents the default audio engine used in babylon.
  29930. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29932. */
  29933. export class AudioEngine implements IAudioEngine {
  29934. private _audioContext;
  29935. private _audioContextInitialized;
  29936. private _muteButton;
  29937. private _hostElement;
  29938. /**
  29939. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29940. */
  29941. canUseWebAudio: boolean;
  29942. /**
  29943. * The master gain node defines the global audio volume of your audio engine.
  29944. */
  29945. masterGain: GainNode;
  29946. /**
  29947. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29948. * @ignoreNaming
  29949. */
  29950. WarnedWebAudioUnsupported: boolean;
  29951. /**
  29952. * Gets whether or not mp3 are supported by your browser.
  29953. */
  29954. isMP3supported: boolean;
  29955. /**
  29956. * Gets whether or not ogg are supported by your browser.
  29957. */
  29958. isOGGsupported: boolean;
  29959. /**
  29960. * Gets whether audio has been unlocked on the device.
  29961. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29962. * a user interaction has happened.
  29963. */
  29964. unlocked: boolean;
  29965. /**
  29966. * Defines if the audio engine relies on a custom unlocked button.
  29967. * In this case, the embedded button will not be displayed.
  29968. */
  29969. useCustomUnlockedButton: boolean;
  29970. /**
  29971. * Event raised when audio has been unlocked on the browser.
  29972. */
  29973. onAudioUnlockedObservable: Observable<AudioEngine>;
  29974. /**
  29975. * Event raised when audio has been locked on the browser.
  29976. */
  29977. onAudioLockedObservable: Observable<AudioEngine>;
  29978. /**
  29979. * Gets the current AudioContext if available.
  29980. */
  29981. readonly audioContext: Nullable<AudioContext>;
  29982. private _connectedAnalyser;
  29983. /**
  29984. * Instantiates a new audio engine.
  29985. *
  29986. * There should be only one per page as some browsers restrict the number
  29987. * of audio contexts you can create.
  29988. * @param hostElement defines the host element where to display the mute icon if necessary
  29989. */
  29990. constructor(hostElement?: Nullable<HTMLElement>);
  29991. /**
  29992. * Flags the audio engine in Locked state.
  29993. * This happens due to new browser policies preventing audio to autoplay.
  29994. */
  29995. lock(): void;
  29996. /**
  29997. * Unlocks the audio engine once a user action has been done on the dom.
  29998. * This is helpful to resume play once browser policies have been satisfied.
  29999. */
  30000. unlock(): void;
  30001. private _resumeAudioContext;
  30002. private _initializeAudioContext;
  30003. private _tryToRun;
  30004. private _triggerRunningState;
  30005. private _triggerSuspendedState;
  30006. private _displayMuteButton;
  30007. private _moveButtonToTopLeft;
  30008. private _onResize;
  30009. private _hideMuteButton;
  30010. /**
  30011. * Destroy and release the resources associated with the audio ccontext.
  30012. */
  30013. dispose(): void;
  30014. /**
  30015. * Gets the global volume sets on the master gain.
  30016. * @returns the global volume if set or -1 otherwise
  30017. */
  30018. getGlobalVolume(): number;
  30019. /**
  30020. * Sets the global volume of your experience (sets on the master gain).
  30021. * @param newVolume Defines the new global volume of the application
  30022. */
  30023. setGlobalVolume(newVolume: number): void;
  30024. /**
  30025. * Connect the audio engine to an audio analyser allowing some amazing
  30026. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30028. * @param analyser The analyser to connect to the engine
  30029. */
  30030. connectToAnalyser(analyser: Analyser): void;
  30031. }
  30032. }
  30033. declare module "babylonjs/Loading/loadingScreen" {
  30034. /**
  30035. * Interface used to present a loading screen while loading a scene
  30036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30037. */
  30038. export interface ILoadingScreen {
  30039. /**
  30040. * Function called to display the loading screen
  30041. */
  30042. displayLoadingUI: () => void;
  30043. /**
  30044. * Function called to hide the loading screen
  30045. */
  30046. hideLoadingUI: () => void;
  30047. /**
  30048. * Gets or sets the color to use for the background
  30049. */
  30050. loadingUIBackgroundColor: string;
  30051. /**
  30052. * Gets or sets the text to display while loading
  30053. */
  30054. loadingUIText: string;
  30055. }
  30056. /**
  30057. * Class used for the default loading screen
  30058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30059. */
  30060. export class DefaultLoadingScreen implements ILoadingScreen {
  30061. private _renderingCanvas;
  30062. private _loadingText;
  30063. private _loadingDivBackgroundColor;
  30064. private _loadingDiv;
  30065. private _loadingTextDiv;
  30066. /** Gets or sets the logo url to use for the default loading screen */
  30067. static DefaultLogoUrl: string;
  30068. /** Gets or sets the spinner url to use for the default loading screen */
  30069. static DefaultSpinnerUrl: string;
  30070. /**
  30071. * Creates a new default loading screen
  30072. * @param _renderingCanvas defines the canvas used to render the scene
  30073. * @param _loadingText defines the default text to display
  30074. * @param _loadingDivBackgroundColor defines the default background color
  30075. */
  30076. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30077. /**
  30078. * Function called to display the loading screen
  30079. */
  30080. displayLoadingUI(): void;
  30081. /**
  30082. * Function called to hide the loading screen
  30083. */
  30084. hideLoadingUI(): void;
  30085. /**
  30086. * Gets or sets the text to display while loading
  30087. */
  30088. loadingUIText: string;
  30089. /**
  30090. * Gets or sets the color to use for the background
  30091. */
  30092. loadingUIBackgroundColor: string;
  30093. private _resizeLoadingUI;
  30094. }
  30095. }
  30096. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30097. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30098. import { Engine } from "babylonjs/Engines/engine";
  30099. import { Nullable } from "babylonjs/types";
  30100. /** @hidden */
  30101. export class WebGLPipelineContext implements IPipelineContext {
  30102. engine: Engine;
  30103. program: Nullable<WebGLProgram>;
  30104. context?: WebGLRenderingContext;
  30105. vertexShader?: WebGLShader;
  30106. fragmentShader?: WebGLShader;
  30107. isParallelCompiled: boolean;
  30108. onCompiled?: () => void;
  30109. transformFeedback?: WebGLTransformFeedback | null;
  30110. readonly isAsync: boolean;
  30111. readonly isReady: boolean;
  30112. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30113. }
  30114. }
  30115. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30117. /** @hidden */
  30118. export class WebGLDataBuffer extends DataBuffer {
  30119. private _buffer;
  30120. constructor(resource: WebGLBuffer);
  30121. readonly underlyingResource: any;
  30122. }
  30123. }
  30124. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30126. /** @hidden */
  30127. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30128. attributeProcessor(attribute: string): string;
  30129. varyingProcessor(varying: string, isFragment: boolean): string;
  30130. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30131. }
  30132. }
  30133. declare module "babylonjs/Misc/perfCounter" {
  30134. /**
  30135. * This class is used to track a performance counter which is number based.
  30136. * The user has access to many properties which give statistics of different nature.
  30137. *
  30138. * The implementer can track two kinds of Performance Counter: time and count.
  30139. * 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.
  30140. * 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.
  30141. */
  30142. export class PerfCounter {
  30143. /**
  30144. * Gets or sets a global boolean to turn on and off all the counters
  30145. */
  30146. static Enabled: boolean;
  30147. /**
  30148. * Returns the smallest value ever
  30149. */
  30150. readonly min: number;
  30151. /**
  30152. * Returns the biggest value ever
  30153. */
  30154. readonly max: number;
  30155. /**
  30156. * Returns the average value since the performance counter is running
  30157. */
  30158. readonly average: number;
  30159. /**
  30160. * Returns the average value of the last second the counter was monitored
  30161. */
  30162. readonly lastSecAverage: number;
  30163. /**
  30164. * Returns the current value
  30165. */
  30166. readonly current: number;
  30167. /**
  30168. * Gets the accumulated total
  30169. */
  30170. readonly total: number;
  30171. /**
  30172. * Gets the total value count
  30173. */
  30174. readonly count: number;
  30175. /**
  30176. * Creates a new counter
  30177. */
  30178. constructor();
  30179. /**
  30180. * Call this method to start monitoring a new frame.
  30181. * 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.
  30182. */
  30183. fetchNewFrame(): void;
  30184. /**
  30185. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30186. * @param newCount the count value to add to the monitored count
  30187. * @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.
  30188. */
  30189. addCount(newCount: number, fetchResult: boolean): void;
  30190. /**
  30191. * Start monitoring this performance counter
  30192. */
  30193. beginMonitoring(): void;
  30194. /**
  30195. * Compute the time lapsed since the previous beginMonitoring() call.
  30196. * @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
  30197. */
  30198. endMonitoring(newFrame?: boolean): void;
  30199. private _fetchResult;
  30200. private _startMonitoringTime;
  30201. private _min;
  30202. private _max;
  30203. private _average;
  30204. private _current;
  30205. private _totalValueCount;
  30206. private _totalAccumulated;
  30207. private _lastSecAverage;
  30208. private _lastSecAccumulated;
  30209. private _lastSecTime;
  30210. private _lastSecValueCount;
  30211. }
  30212. }
  30213. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30214. /**
  30215. * Interface for any object that can request an animation frame
  30216. */
  30217. export interface ICustomAnimationFrameRequester {
  30218. /**
  30219. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30220. */
  30221. renderFunction?: Function;
  30222. /**
  30223. * Called to request the next frame to render to
  30224. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30225. */
  30226. requestAnimationFrame: Function;
  30227. /**
  30228. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30229. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30230. */
  30231. requestID?: number;
  30232. }
  30233. }
  30234. declare module "babylonjs/Materials/Textures/videoTexture" {
  30235. import { Observable } from "babylonjs/Misc/observable";
  30236. import { Nullable } from "babylonjs/types";
  30237. import { Scene } from "babylonjs/scene";
  30238. import { Texture } from "babylonjs/Materials/Textures/texture";
  30239. /**
  30240. * Settings for finer control over video usage
  30241. */
  30242. export interface VideoTextureSettings {
  30243. /**
  30244. * Applies `autoplay` to video, if specified
  30245. */
  30246. autoPlay?: boolean;
  30247. /**
  30248. * Applies `loop` to video, if specified
  30249. */
  30250. loop?: boolean;
  30251. /**
  30252. * Automatically updates internal texture from video at every frame in the render loop
  30253. */
  30254. autoUpdateTexture: boolean;
  30255. /**
  30256. * Image src displayed during the video loading or until the user interacts with the video.
  30257. */
  30258. poster?: string;
  30259. }
  30260. /**
  30261. * If you want to display a video in your scene, this is the special texture for that.
  30262. * This special texture works similar to other textures, with the exception of a few parameters.
  30263. * @see https://doc.babylonjs.com/how_to/video_texture
  30264. */
  30265. export class VideoTexture extends Texture {
  30266. /**
  30267. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30268. */
  30269. readonly autoUpdateTexture: boolean;
  30270. /**
  30271. * The video instance used by the texture internally
  30272. */
  30273. readonly video: HTMLVideoElement;
  30274. private _onUserActionRequestedObservable;
  30275. /**
  30276. * Event triggerd when a dom action is required by the user to play the video.
  30277. * This happens due to recent changes in browser policies preventing video to auto start.
  30278. */
  30279. readonly onUserActionRequestedObservable: Observable<Texture>;
  30280. private _generateMipMaps;
  30281. private _engine;
  30282. private _stillImageCaptured;
  30283. private _displayingPosterTexture;
  30284. private _settings;
  30285. private _createInternalTextureOnEvent;
  30286. /**
  30287. * Creates a video texture.
  30288. * If you want to display a video in your scene, this is the special texture for that.
  30289. * This special texture works similar to other textures, with the exception of a few parameters.
  30290. * @see https://doc.babylonjs.com/how_to/video_texture
  30291. * @param name optional name, will detect from video source, if not defined
  30292. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30293. * @param scene is obviously the current scene.
  30294. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30295. * @param invertY is false by default but can be used to invert video on Y axis
  30296. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30297. * @param settings allows finer control over video usage
  30298. */
  30299. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30300. private _getName;
  30301. private _getVideo;
  30302. private _createInternalTexture;
  30303. private reset;
  30304. /**
  30305. * @hidden Internal method to initiate `update`.
  30306. */
  30307. _rebuild(): void;
  30308. /**
  30309. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30310. */
  30311. update(): void;
  30312. /**
  30313. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30314. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30315. */
  30316. updateTexture(isVisible: boolean): void;
  30317. protected _updateInternalTexture: () => void;
  30318. /**
  30319. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30320. * @param url New url.
  30321. */
  30322. updateURL(url: string): void;
  30323. /**
  30324. * Dispose the texture and release its associated resources.
  30325. */
  30326. dispose(): void;
  30327. /**
  30328. * Creates a video texture straight from a stream.
  30329. * @param scene Define the scene the texture should be created in
  30330. * @param stream Define the stream the texture should be created from
  30331. * @returns The created video texture as a promise
  30332. */
  30333. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30334. /**
  30335. * Creates a video texture straight from your WebCam video feed.
  30336. * @param scene Define the scene the texture should be created in
  30337. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30338. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30339. * @returns The created video texture as a promise
  30340. */
  30341. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30342. minWidth: number;
  30343. maxWidth: number;
  30344. minHeight: number;
  30345. maxHeight: number;
  30346. deviceId: string;
  30347. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30348. /**
  30349. * Creates a video texture straight from your WebCam video feed.
  30350. * @param scene Define the scene the texture should be created in
  30351. * @param onReady Define a callback to triggered once the texture will be ready
  30352. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30353. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30354. */
  30355. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30356. minWidth: number;
  30357. maxWidth: number;
  30358. minHeight: number;
  30359. maxHeight: number;
  30360. deviceId: string;
  30361. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30362. }
  30363. }
  30364. declare module "babylonjs/Engines/engine" {
  30365. import { Observable } from "babylonjs/Misc/observable";
  30366. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30367. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30368. import { Scene } from "babylonjs/scene";
  30369. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30370. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30371. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30375. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30376. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30377. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30378. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30379. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30380. import { WebRequest } from "babylonjs/Misc/webRequest";
  30381. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30382. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30383. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30384. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30385. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30386. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30387. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30388. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30389. import { Material } from "babylonjs/Materials/material";
  30390. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30391. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30392. /**
  30393. * Defines the interface used by objects containing a viewport (like a camera)
  30394. */
  30395. interface IViewportOwnerLike {
  30396. /**
  30397. * Gets or sets the viewport
  30398. */
  30399. viewport: IViewportLike;
  30400. }
  30401. /**
  30402. * Interface for attribute information associated with buffer instanciation
  30403. */
  30404. export class InstancingAttributeInfo {
  30405. /**
  30406. * Index/offset of the attribute in the vertex shader
  30407. */
  30408. index: number;
  30409. /**
  30410. * size of the attribute, 1, 2, 3 or 4
  30411. */
  30412. attributeSize: number;
  30413. /**
  30414. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30415. * default is FLOAT
  30416. */
  30417. attribyteType: number;
  30418. /**
  30419. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30420. */
  30421. normalized: boolean;
  30422. /**
  30423. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30424. */
  30425. offset: number;
  30426. /**
  30427. * Name of the GLSL attribute, for debugging purpose only
  30428. */
  30429. attributeName: string;
  30430. }
  30431. /**
  30432. * Define options used to create a depth texture
  30433. */
  30434. export class DepthTextureCreationOptions {
  30435. /** Specifies whether or not a stencil should be allocated in the texture */
  30436. generateStencil?: boolean;
  30437. /** Specifies whether or not bilinear filtering is enable on the texture */
  30438. bilinearFiltering?: boolean;
  30439. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30440. comparisonFunction?: number;
  30441. /** Specifies if the created texture is a cube texture */
  30442. isCube?: boolean;
  30443. }
  30444. /**
  30445. * Class used to describe the capabilities of the engine relatively to the current browser
  30446. */
  30447. export class EngineCapabilities {
  30448. /** Maximum textures units per fragment shader */
  30449. maxTexturesImageUnits: number;
  30450. /** Maximum texture units per vertex shader */
  30451. maxVertexTextureImageUnits: number;
  30452. /** Maximum textures units in the entire pipeline */
  30453. maxCombinedTexturesImageUnits: number;
  30454. /** Maximum texture size */
  30455. maxTextureSize: number;
  30456. /** Maximum cube texture size */
  30457. maxCubemapTextureSize: number;
  30458. /** Maximum render texture size */
  30459. maxRenderTextureSize: number;
  30460. /** Maximum number of vertex attributes */
  30461. maxVertexAttribs: number;
  30462. /** Maximum number of varyings */
  30463. maxVaryingVectors: number;
  30464. /** Maximum number of uniforms per vertex shader */
  30465. maxVertexUniformVectors: number;
  30466. /** Maximum number of uniforms per fragment shader */
  30467. maxFragmentUniformVectors: number;
  30468. /** Defines if standard derivates (dx/dy) are supported */
  30469. standardDerivatives: boolean;
  30470. /** Defines if s3tc texture compression is supported */
  30471. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30472. /** Defines if pvrtc texture compression is supported */
  30473. pvrtc: any;
  30474. /** Defines if etc1 texture compression is supported */
  30475. etc1: any;
  30476. /** Defines if etc2 texture compression is supported */
  30477. etc2: any;
  30478. /** Defines if astc texture compression is supported */
  30479. astc: any;
  30480. /** Defines if float textures are supported */
  30481. textureFloat: boolean;
  30482. /** Defines if vertex array objects are supported */
  30483. vertexArrayObject: boolean;
  30484. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30485. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30486. /** Gets the maximum level of anisotropy supported */
  30487. maxAnisotropy: number;
  30488. /** Defines if instancing is supported */
  30489. instancedArrays: boolean;
  30490. /** Defines if 32 bits indices are supported */
  30491. uintIndices: boolean;
  30492. /** Defines if high precision shaders are supported */
  30493. highPrecisionShaderSupported: boolean;
  30494. /** Defines if depth reading in the fragment shader is supported */
  30495. fragmentDepthSupported: boolean;
  30496. /** Defines if float texture linear filtering is supported*/
  30497. textureFloatLinearFiltering: boolean;
  30498. /** Defines if rendering to float textures is supported */
  30499. textureFloatRender: boolean;
  30500. /** Defines if half float textures are supported*/
  30501. textureHalfFloat: boolean;
  30502. /** Defines if half float texture linear filtering is supported*/
  30503. textureHalfFloatLinearFiltering: boolean;
  30504. /** Defines if rendering to half float textures is supported */
  30505. textureHalfFloatRender: boolean;
  30506. /** Defines if textureLOD shader command is supported */
  30507. textureLOD: boolean;
  30508. /** Defines if draw buffers extension is supported */
  30509. drawBuffersExtension: boolean;
  30510. /** Defines if depth textures are supported */
  30511. depthTextureExtension: boolean;
  30512. /** Defines if float color buffer are supported */
  30513. colorBufferFloat: boolean;
  30514. /** Gets disjoint timer query extension (null if not supported) */
  30515. timerQuery: EXT_disjoint_timer_query;
  30516. /** Defines if timestamp can be used with timer query */
  30517. canUseTimestampForTimerQuery: boolean;
  30518. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30519. multiview: any;
  30520. /** Function used to let the system compiles shaders in background */
  30521. parallelShaderCompile: {
  30522. COMPLETION_STATUS_KHR: number;
  30523. };
  30524. /** Max number of texture samples for MSAA */
  30525. maxMSAASamples: number;
  30526. }
  30527. /** Interface defining initialization parameters for Engine class */
  30528. export interface EngineOptions extends WebGLContextAttributes {
  30529. /**
  30530. * Defines if the engine should no exceed a specified device ratio
  30531. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30532. */
  30533. limitDeviceRatio?: number;
  30534. /**
  30535. * Defines if webvr should be enabled automatically
  30536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30537. */
  30538. autoEnableWebVR?: boolean;
  30539. /**
  30540. * Defines if webgl2 should be turned off even if supported
  30541. * @see http://doc.babylonjs.com/features/webgl2
  30542. */
  30543. disableWebGL2Support?: boolean;
  30544. /**
  30545. * Defines if webaudio should be initialized as well
  30546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30547. */
  30548. audioEngine?: boolean;
  30549. /**
  30550. * Defines if animations should run using a deterministic lock step
  30551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30552. */
  30553. deterministicLockstep?: boolean;
  30554. /** Defines the maximum steps to use with deterministic lock step mode */
  30555. lockstepMaxSteps?: number;
  30556. /**
  30557. * Defines that engine should ignore context lost events
  30558. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30559. */
  30560. doNotHandleContextLost?: boolean;
  30561. /**
  30562. * Defines that engine should ignore modifying touch action attribute and style
  30563. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30564. */
  30565. doNotHandleTouchAction?: boolean;
  30566. /**
  30567. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30568. */
  30569. useHighPrecisionFloats?: boolean;
  30570. }
  30571. /**
  30572. * Defines the interface used by display changed events
  30573. */
  30574. export interface IDisplayChangedEventArgs {
  30575. /** Gets the vrDisplay object (if any) */
  30576. vrDisplay: Nullable<any>;
  30577. /** Gets a boolean indicating if webVR is supported */
  30578. vrSupported: boolean;
  30579. }
  30580. /**
  30581. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30582. */
  30583. export class Engine {
  30584. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30585. static ExceptionList: ({
  30586. key: string;
  30587. capture: string;
  30588. captureConstraint: number;
  30589. targets: string[];
  30590. } | {
  30591. key: string;
  30592. capture: null;
  30593. captureConstraint: null;
  30594. targets: string[];
  30595. })[];
  30596. /** Gets the list of created engines */
  30597. static readonly Instances: Engine[];
  30598. /**
  30599. * Gets the latest created engine
  30600. */
  30601. static readonly LastCreatedEngine: Nullable<Engine>;
  30602. /**
  30603. * Gets the latest created scene
  30604. */
  30605. static readonly LastCreatedScene: Nullable<Scene>;
  30606. /**
  30607. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30608. * @param flag defines which part of the materials must be marked as dirty
  30609. * @param predicate defines a predicate used to filter which materials should be affected
  30610. */
  30611. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30612. /** @hidden */
  30613. static _TextureLoaders: IInternalTextureLoader[];
  30614. /** Defines that alpha blending is disabled */
  30615. static readonly ALPHA_DISABLE: number;
  30616. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30617. static readonly ALPHA_ADD: number;
  30618. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30619. static readonly ALPHA_COMBINE: number;
  30620. /** Defines that alpha blending to DEST - SRC * DEST */
  30621. static readonly ALPHA_SUBTRACT: number;
  30622. /** Defines that alpha blending to SRC * DEST */
  30623. static readonly ALPHA_MULTIPLY: number;
  30624. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30625. static readonly ALPHA_MAXIMIZED: number;
  30626. /** Defines that alpha blending to SRC + DEST */
  30627. static readonly ALPHA_ONEONE: number;
  30628. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30629. static readonly ALPHA_PREMULTIPLIED: number;
  30630. /**
  30631. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30632. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30633. */
  30634. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30635. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30636. static readonly ALPHA_INTERPOLATE: number;
  30637. /**
  30638. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30639. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30640. */
  30641. static readonly ALPHA_SCREENMODE: number;
  30642. /** Defines that the ressource is not delayed*/
  30643. static readonly DELAYLOADSTATE_NONE: number;
  30644. /** Defines that the ressource was successfully delay loaded */
  30645. static readonly DELAYLOADSTATE_LOADED: number;
  30646. /** Defines that the ressource is currently delay loading */
  30647. static readonly DELAYLOADSTATE_LOADING: number;
  30648. /** Defines that the ressource is delayed and has not started loading */
  30649. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30651. static readonly NEVER: number;
  30652. /** 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 */
  30653. static readonly ALWAYS: number;
  30654. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30655. static readonly LESS: number;
  30656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30657. static readonly EQUAL: number;
  30658. /** 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 */
  30659. static readonly LEQUAL: number;
  30660. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30661. static readonly GREATER: number;
  30662. /** 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 */
  30663. static readonly GEQUAL: number;
  30664. /** 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 */
  30665. static readonly NOTEQUAL: number;
  30666. /** Passed to stencilOperation to specify that stencil value must be kept */
  30667. static readonly KEEP: number;
  30668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30669. static readonly REPLACE: number;
  30670. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30671. static readonly INCR: number;
  30672. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30673. static readonly DECR: number;
  30674. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30675. static readonly INVERT: number;
  30676. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30677. static readonly INCR_WRAP: number;
  30678. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30679. static readonly DECR_WRAP: number;
  30680. /** Texture is not repeating outside of 0..1 UVs */
  30681. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30682. /** Texture is repeating outside of 0..1 UVs */
  30683. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30684. /** Texture is repeating and mirrored */
  30685. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30686. /** ALPHA */
  30687. static readonly TEXTUREFORMAT_ALPHA: number;
  30688. /** LUMINANCE */
  30689. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30690. /** LUMINANCE_ALPHA */
  30691. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30692. /** RGB */
  30693. static readonly TEXTUREFORMAT_RGB: number;
  30694. /** RGBA */
  30695. static readonly TEXTUREFORMAT_RGBA: number;
  30696. /** RED */
  30697. static readonly TEXTUREFORMAT_RED: number;
  30698. /** RED (2nd reference) */
  30699. static readonly TEXTUREFORMAT_R: number;
  30700. /** RG */
  30701. static readonly TEXTUREFORMAT_RG: number;
  30702. /** RED_INTEGER */
  30703. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30704. /** RED_INTEGER (2nd reference) */
  30705. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30706. /** RG_INTEGER */
  30707. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30708. /** RGB_INTEGER */
  30709. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30710. /** RGBA_INTEGER */
  30711. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30712. /** UNSIGNED_BYTE */
  30713. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30714. /** UNSIGNED_BYTE (2nd reference) */
  30715. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30716. /** FLOAT */
  30717. static readonly TEXTURETYPE_FLOAT: number;
  30718. /** HALF_FLOAT */
  30719. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30720. /** BYTE */
  30721. static readonly TEXTURETYPE_BYTE: number;
  30722. /** SHORT */
  30723. static readonly TEXTURETYPE_SHORT: number;
  30724. /** UNSIGNED_SHORT */
  30725. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30726. /** INT */
  30727. static readonly TEXTURETYPE_INT: number;
  30728. /** UNSIGNED_INT */
  30729. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30730. /** UNSIGNED_SHORT_4_4_4_4 */
  30731. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30732. /** UNSIGNED_SHORT_5_5_5_1 */
  30733. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30734. /** UNSIGNED_SHORT_5_6_5 */
  30735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30736. /** UNSIGNED_INT_2_10_10_10_REV */
  30737. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30738. /** UNSIGNED_INT_24_8 */
  30739. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30740. /** UNSIGNED_INT_10F_11F_11F_REV */
  30741. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30742. /** UNSIGNED_INT_5_9_9_9_REV */
  30743. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30744. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30745. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30746. /** nearest is mag = nearest and min = nearest and mip = linear */
  30747. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30748. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30749. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30750. /** Trilinear is mag = linear and min = linear and mip = linear */
  30751. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30752. /** nearest is mag = nearest and min = nearest and mip = linear */
  30753. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30754. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30755. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30756. /** Trilinear is mag = linear and min = linear and mip = linear */
  30757. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30758. /** mag = nearest and min = nearest and mip = nearest */
  30759. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30760. /** mag = nearest and min = linear and mip = nearest */
  30761. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30762. /** mag = nearest and min = linear and mip = linear */
  30763. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30764. /** mag = nearest and min = linear and mip = none */
  30765. static readonly TEXTURE_NEAREST_LINEAR: number;
  30766. /** mag = nearest and min = nearest and mip = none */
  30767. static readonly TEXTURE_NEAREST_NEAREST: number;
  30768. /** mag = linear and min = nearest and mip = nearest */
  30769. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30770. /** mag = linear and min = nearest and mip = linear */
  30771. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30772. /** mag = linear and min = linear and mip = none */
  30773. static readonly TEXTURE_LINEAR_LINEAR: number;
  30774. /** mag = linear and min = nearest and mip = none */
  30775. static readonly TEXTURE_LINEAR_NEAREST: number;
  30776. /** Explicit coordinates mode */
  30777. static readonly TEXTURE_EXPLICIT_MODE: number;
  30778. /** Spherical coordinates mode */
  30779. static readonly TEXTURE_SPHERICAL_MODE: number;
  30780. /** Planar coordinates mode */
  30781. static readonly TEXTURE_PLANAR_MODE: number;
  30782. /** Cubic coordinates mode */
  30783. static readonly TEXTURE_CUBIC_MODE: number;
  30784. /** Projection coordinates mode */
  30785. static readonly TEXTURE_PROJECTION_MODE: number;
  30786. /** Skybox coordinates mode */
  30787. static readonly TEXTURE_SKYBOX_MODE: number;
  30788. /** Inverse Cubic coordinates mode */
  30789. static readonly TEXTURE_INVCUBIC_MODE: number;
  30790. /** Equirectangular coordinates mode */
  30791. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30792. /** Equirectangular Fixed coordinates mode */
  30793. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30794. /** Equirectangular Fixed Mirrored coordinates mode */
  30795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30796. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30797. static readonly SCALEMODE_FLOOR: number;
  30798. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30799. static readonly SCALEMODE_NEAREST: number;
  30800. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30801. static readonly SCALEMODE_CEILING: number;
  30802. /**
  30803. * Returns the current npm package of the sdk
  30804. */
  30805. static readonly NpmPackage: string;
  30806. /**
  30807. * Returns the current version of the framework
  30808. */
  30809. static readonly Version: string;
  30810. /**
  30811. * Returns a string describing the current engine
  30812. */
  30813. readonly description: string;
  30814. /**
  30815. * Gets or sets the epsilon value used by collision engine
  30816. */
  30817. static CollisionsEpsilon: number;
  30818. /**
  30819. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30820. */
  30821. static ShadersRepository: string;
  30822. /**
  30823. * Method called to create the default loading screen.
  30824. * This can be overriden in your own app.
  30825. * @param canvas The rendering canvas element
  30826. * @returns The loading screen
  30827. */
  30828. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30829. /**
  30830. * Method called to create the default rescale post process on each engine.
  30831. */
  30832. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30833. /** @hidden */
  30834. _shaderProcessor: IShaderProcessor;
  30835. /**
  30836. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30837. */
  30838. forcePOTTextures: boolean;
  30839. /**
  30840. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30841. */
  30842. isFullscreen: boolean;
  30843. /**
  30844. * Gets a boolean indicating if the pointer is currently locked
  30845. */
  30846. isPointerLock: boolean;
  30847. /**
  30848. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30849. */
  30850. cullBackFaces: boolean;
  30851. /**
  30852. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30853. */
  30854. renderEvenInBackground: boolean;
  30855. /**
  30856. * Gets or sets a boolean indicating that cache can be kept between frames
  30857. */
  30858. preventCacheWipeBetweenFrames: boolean;
  30859. /**
  30860. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30861. **/
  30862. enableOfflineSupport: boolean;
  30863. /**
  30864. * 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)
  30865. **/
  30866. disableManifestCheck: boolean;
  30867. /**
  30868. * Gets the list of created scenes
  30869. */
  30870. scenes: Scene[];
  30871. /**
  30872. * Event raised when a new scene is created
  30873. */
  30874. onNewSceneAddedObservable: Observable<Scene>;
  30875. /**
  30876. * Gets the list of created postprocesses
  30877. */
  30878. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30879. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30880. validateShaderPrograms: boolean;
  30881. /**
  30882. * Observable event triggered each time the rendering canvas is resized
  30883. */
  30884. onResizeObservable: Observable<Engine>;
  30885. /**
  30886. * Observable event triggered each time the canvas loses focus
  30887. */
  30888. onCanvasBlurObservable: Observable<Engine>;
  30889. /**
  30890. * Observable event triggered each time the canvas gains focus
  30891. */
  30892. onCanvasFocusObservable: Observable<Engine>;
  30893. /**
  30894. * Observable event triggered each time the canvas receives pointerout event
  30895. */
  30896. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30897. /**
  30898. * Observable event triggered before each texture is initialized
  30899. */
  30900. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30901. /**
  30902. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30903. */
  30904. disableUniformBuffers: boolean;
  30905. /** @hidden */
  30906. _uniformBuffers: UniformBuffer[];
  30907. /**
  30908. * Gets a boolean indicating that the engine supports uniform buffers
  30909. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30910. */
  30911. readonly supportsUniformBuffers: boolean;
  30912. /**
  30913. * Observable raised when the engine begins a new frame
  30914. */
  30915. onBeginFrameObservable: Observable<Engine>;
  30916. /**
  30917. * If set, will be used to request the next animation frame for the render loop
  30918. */
  30919. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30920. /**
  30921. * Observable raised when the engine ends the current frame
  30922. */
  30923. onEndFrameObservable: Observable<Engine>;
  30924. /**
  30925. * Observable raised when the engine is about to compile a shader
  30926. */
  30927. onBeforeShaderCompilationObservable: Observable<Engine>;
  30928. /**
  30929. * Observable raised when the engine has jsut compiled a shader
  30930. */
  30931. onAfterShaderCompilationObservable: Observable<Engine>;
  30932. /** @hidden */
  30933. _gl: WebGLRenderingContext;
  30934. private _renderingCanvas;
  30935. private _windowIsBackground;
  30936. private _webGLVersion;
  30937. protected _highPrecisionShadersAllowed: boolean;
  30938. /** @hidden */
  30939. readonly _shouldUseHighPrecisionShader: boolean;
  30940. /**
  30941. * Gets a boolean indicating that only power of 2 textures are supported
  30942. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30943. */
  30944. readonly needPOTTextures: boolean;
  30945. /** @hidden */
  30946. _badOS: boolean;
  30947. /** @hidden */
  30948. _badDesktopOS: boolean;
  30949. /**
  30950. * Gets the audio engine
  30951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30952. * @ignorenaming
  30953. */
  30954. static audioEngine: IAudioEngine;
  30955. /**
  30956. * Default AudioEngine factory responsible of creating the Audio Engine.
  30957. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30958. */
  30959. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30960. /**
  30961. * Default offline support factory responsible of creating a tool used to store data locally.
  30962. * By default, this will create a Database object if the workload has been embedded.
  30963. */
  30964. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30965. private _onFocus;
  30966. private _onBlur;
  30967. private _onCanvasPointerOut;
  30968. private _onCanvasBlur;
  30969. private _onCanvasFocus;
  30970. private _onFullscreenChange;
  30971. private _onPointerLockChange;
  30972. private _hardwareScalingLevel;
  30973. /** @hidden */
  30974. _caps: EngineCapabilities;
  30975. private _pointerLockRequested;
  30976. private _isStencilEnable;
  30977. private _colorWrite;
  30978. private _loadingScreen;
  30979. /** @hidden */
  30980. _drawCalls: PerfCounter;
  30981. private _glVersion;
  30982. private _glRenderer;
  30983. private _glVendor;
  30984. private _videoTextureSupported;
  30985. private _renderingQueueLaunched;
  30986. private _activeRenderLoops;
  30987. private _deterministicLockstep;
  30988. private _lockstepMaxSteps;
  30989. /**
  30990. * Observable signaled when a context lost event is raised
  30991. */
  30992. onContextLostObservable: Observable<Engine>;
  30993. /**
  30994. * Observable signaled when a context restored event is raised
  30995. */
  30996. onContextRestoredObservable: Observable<Engine>;
  30997. private _onContextLost;
  30998. private _onContextRestored;
  30999. private _contextWasLost;
  31000. /** @hidden */
  31001. _doNotHandleContextLost: boolean;
  31002. /**
  31003. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31005. */
  31006. doNotHandleContextLost: boolean;
  31007. private _performanceMonitor;
  31008. private _fps;
  31009. private _deltaTime;
  31010. /**
  31011. * Turn this value on if you want to pause FPS computation when in background
  31012. */
  31013. disablePerformanceMonitorInBackground: boolean;
  31014. /**
  31015. * Gets the performance monitor attached to this engine
  31016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31017. */
  31018. readonly performanceMonitor: PerformanceMonitor;
  31019. /**
  31020. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31021. */
  31022. disableVertexArrayObjects: boolean;
  31023. /** @hidden */
  31024. protected _depthCullingState: _DepthCullingState;
  31025. /** @hidden */
  31026. protected _stencilState: _StencilState;
  31027. /** @hidden */
  31028. protected _alphaState: _AlphaState;
  31029. /** @hidden */
  31030. protected _alphaMode: number;
  31031. /** @hidden */
  31032. _internalTexturesCache: InternalTexture[];
  31033. /** @hidden */
  31034. protected _activeChannel: number;
  31035. private _currentTextureChannel;
  31036. /** @hidden */
  31037. protected _boundTexturesCache: {
  31038. [key: string]: Nullable<InternalTexture>;
  31039. };
  31040. /** @hidden */
  31041. protected _currentEffect: Nullable<Effect>;
  31042. /** @hidden */
  31043. protected _currentProgram: Nullable<WebGLProgram>;
  31044. private _compiledEffects;
  31045. private _vertexAttribArraysEnabled;
  31046. /** @hidden */
  31047. protected _cachedViewport: Nullable<IViewportLike>;
  31048. private _cachedVertexArrayObject;
  31049. /** @hidden */
  31050. protected _cachedVertexBuffers: any;
  31051. /** @hidden */
  31052. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31053. /** @hidden */
  31054. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31055. /** @hidden */
  31056. _currentRenderTarget: Nullable<InternalTexture>;
  31057. private _uintIndicesCurrentlySet;
  31058. private _currentBoundBuffer;
  31059. /** @hidden */
  31060. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31061. private _currentBufferPointers;
  31062. private _currentInstanceLocations;
  31063. private _currentInstanceBuffers;
  31064. private _textureUnits;
  31065. /** @hidden */
  31066. _workingCanvas: Nullable<HTMLCanvasElement>;
  31067. /** @hidden */
  31068. _workingContext: Nullable<CanvasRenderingContext2D>;
  31069. private _rescalePostProcess;
  31070. private _dummyFramebuffer;
  31071. private _externalData;
  31072. /** @hidden */
  31073. _bindedRenderFunction: any;
  31074. private _vaoRecordInProgress;
  31075. private _mustWipeVertexAttributes;
  31076. private _emptyTexture;
  31077. private _emptyCubeTexture;
  31078. private _emptyTexture3D;
  31079. /** @hidden */
  31080. _frameHandler: number;
  31081. private _nextFreeTextureSlots;
  31082. private _maxSimultaneousTextures;
  31083. private _activeRequests;
  31084. private _texturesSupported;
  31085. /** @hidden */
  31086. _textureFormatInUse: Nullable<string>;
  31087. /**
  31088. * Gets the list of texture formats supported
  31089. */
  31090. readonly texturesSupported: Array<string>;
  31091. /**
  31092. * Gets the list of texture formats in use
  31093. */
  31094. readonly textureFormatInUse: Nullable<string>;
  31095. /**
  31096. * Gets the current viewport
  31097. */
  31098. readonly currentViewport: Nullable<IViewportLike>;
  31099. /**
  31100. * Gets the default empty texture
  31101. */
  31102. readonly emptyTexture: InternalTexture;
  31103. /**
  31104. * Gets the default empty 3D texture
  31105. */
  31106. readonly emptyTexture3D: InternalTexture;
  31107. /**
  31108. * Gets the default empty cube texture
  31109. */
  31110. readonly emptyCubeTexture: InternalTexture;
  31111. /**
  31112. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31113. */
  31114. readonly premultipliedAlpha: boolean;
  31115. /**
  31116. * Creates a new engine
  31117. * @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
  31118. * @param antialias defines enable antialiasing (default: false)
  31119. * @param options defines further options to be sent to the getContext() function
  31120. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31121. */
  31122. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31123. /**
  31124. * Initializes a webVR display and starts listening to display change events
  31125. * The onVRDisplayChangedObservable will be notified upon these changes
  31126. * @returns The onVRDisplayChangedObservable
  31127. */
  31128. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31129. /** @hidden */
  31130. _prepareVRComponent(): void;
  31131. /** @hidden */
  31132. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31133. /** @hidden */
  31134. _submitVRFrame(): void;
  31135. /**
  31136. * Call this function to leave webVR mode
  31137. * Will do nothing if webVR is not supported or if there is no webVR device
  31138. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31139. */
  31140. disableVR(): void;
  31141. /**
  31142. * Gets a boolean indicating that the system is in VR mode and is presenting
  31143. * @returns true if VR mode is engaged
  31144. */
  31145. isVRPresenting(): boolean;
  31146. /** @hidden */
  31147. _requestVRFrame(): void;
  31148. private _disableTouchAction;
  31149. private _rebuildInternalTextures;
  31150. private _rebuildEffects;
  31151. /**
  31152. * Gets a boolean indicating if all created effects are ready
  31153. * @returns true if all effects are ready
  31154. */
  31155. areAllEffectsReady(): boolean;
  31156. private _rebuildBuffers;
  31157. private _initGLContext;
  31158. /**
  31159. * Gets version of the current webGL context
  31160. */
  31161. readonly webGLVersion: number;
  31162. /**
  31163. * Gets a string idenfifying the name of the class
  31164. * @returns "Engine" string
  31165. */
  31166. getClassName(): string;
  31167. /**
  31168. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31169. */
  31170. readonly isStencilEnable: boolean;
  31171. /** @hidden */
  31172. _prepareWorkingCanvas(): void;
  31173. /**
  31174. * Reset the texture cache to empty state
  31175. */
  31176. resetTextureCache(): void;
  31177. /**
  31178. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31180. * @returns true if engine is in deterministic lock step mode
  31181. */
  31182. isDeterministicLockStep(): boolean;
  31183. /**
  31184. * Gets the max steps when engine is running in deterministic lock step
  31185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31186. * @returns the max steps
  31187. */
  31188. getLockstepMaxSteps(): number;
  31189. /**
  31190. * Gets an object containing information about the current webGL context
  31191. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31192. */
  31193. getGlInfo(): {
  31194. vendor: string;
  31195. renderer: string;
  31196. version: string;
  31197. };
  31198. /**
  31199. * Gets current aspect ratio
  31200. * @param viewportOwner defines the camera to use to get the aspect ratio
  31201. * @param useScreen defines if screen size must be used (or the current render target if any)
  31202. * @returns a number defining the aspect ratio
  31203. */
  31204. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31205. /**
  31206. * Gets current screen aspect ratio
  31207. * @returns a number defining the aspect ratio
  31208. */
  31209. getScreenAspectRatio(): number;
  31210. /**
  31211. * Gets the current render width
  31212. * @param useScreen defines if screen size must be used (or the current render target if any)
  31213. * @returns a number defining the current render width
  31214. */
  31215. getRenderWidth(useScreen?: boolean): number;
  31216. /**
  31217. * Gets the current render height
  31218. * @param useScreen defines if screen size must be used (or the current render target if any)
  31219. * @returns a number defining the current render height
  31220. */
  31221. getRenderHeight(useScreen?: boolean): number;
  31222. /**
  31223. * Gets the HTML canvas attached with the current webGL context
  31224. * @returns a HTML canvas
  31225. */
  31226. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31227. /**
  31228. * Gets host window
  31229. * @returns the host window object
  31230. */
  31231. getHostWindow(): Window;
  31232. /**
  31233. * Gets host document
  31234. * @returns the host document object
  31235. */
  31236. getHostDocument(): Document;
  31237. /**
  31238. * Gets the client rect of the HTML canvas attached with the current webGL context
  31239. * @returns a client rectanglee
  31240. */
  31241. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31242. /**
  31243. * Defines the hardware scaling level.
  31244. * By default the hardware scaling level is computed from the window device ratio.
  31245. * 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.
  31246. * @param level defines the level to use
  31247. */
  31248. setHardwareScalingLevel(level: number): void;
  31249. /**
  31250. * Gets the current hardware scaling level.
  31251. * By default the hardware scaling level is computed from the window device ratio.
  31252. * 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.
  31253. * @returns a number indicating the current hardware scaling level
  31254. */
  31255. getHardwareScalingLevel(): number;
  31256. /**
  31257. * Gets the list of loaded textures
  31258. * @returns an array containing all loaded textures
  31259. */
  31260. getLoadedTexturesCache(): InternalTexture[];
  31261. /**
  31262. * Gets the object containing all engine capabilities
  31263. * @returns the EngineCapabilities object
  31264. */
  31265. getCaps(): EngineCapabilities;
  31266. /**
  31267. * Gets the current depth function
  31268. * @returns a number defining the depth function
  31269. */
  31270. getDepthFunction(): Nullable<number>;
  31271. /**
  31272. * Sets the current depth function
  31273. * @param depthFunc defines the function to use
  31274. */
  31275. setDepthFunction(depthFunc: number): void;
  31276. /**
  31277. * Sets the current depth function to GREATER
  31278. */
  31279. setDepthFunctionToGreater(): void;
  31280. /**
  31281. * Sets the current depth function to GEQUAL
  31282. */
  31283. setDepthFunctionToGreaterOrEqual(): void;
  31284. /**
  31285. * Sets the current depth function to LESS
  31286. */
  31287. setDepthFunctionToLess(): void;
  31288. private _cachedStencilBuffer;
  31289. private _cachedStencilFunction;
  31290. private _cachedStencilMask;
  31291. private _cachedStencilOperationPass;
  31292. private _cachedStencilOperationFail;
  31293. private _cachedStencilOperationDepthFail;
  31294. private _cachedStencilReference;
  31295. /**
  31296. * Caches the the state of the stencil buffer
  31297. */
  31298. cacheStencilState(): void;
  31299. /**
  31300. * Restores the state of the stencil buffer
  31301. */
  31302. restoreStencilState(): void;
  31303. /**
  31304. * Sets the current depth function to LEQUAL
  31305. */
  31306. setDepthFunctionToLessOrEqual(): void;
  31307. /**
  31308. * Gets a boolean indicating if stencil buffer is enabled
  31309. * @returns the current stencil buffer state
  31310. */
  31311. getStencilBuffer(): boolean;
  31312. /**
  31313. * Enable or disable the stencil buffer
  31314. * @param enable defines if the stencil buffer must be enabled or disabled
  31315. */
  31316. setStencilBuffer(enable: boolean): void;
  31317. /**
  31318. * Gets the current stencil mask
  31319. * @returns a number defining the new stencil mask to use
  31320. */
  31321. getStencilMask(): number;
  31322. /**
  31323. * Sets the current stencil mask
  31324. * @param mask defines the new stencil mask to use
  31325. */
  31326. setStencilMask(mask: number): void;
  31327. /**
  31328. * Gets the current stencil function
  31329. * @returns a number defining the stencil function to use
  31330. */
  31331. getStencilFunction(): number;
  31332. /**
  31333. * Gets the current stencil reference value
  31334. * @returns a number defining the stencil reference value to use
  31335. */
  31336. getStencilFunctionReference(): number;
  31337. /**
  31338. * Gets the current stencil mask
  31339. * @returns a number defining the stencil mask to use
  31340. */
  31341. getStencilFunctionMask(): number;
  31342. /**
  31343. * Sets the current stencil function
  31344. * @param stencilFunc defines the new stencil function to use
  31345. */
  31346. setStencilFunction(stencilFunc: number): void;
  31347. /**
  31348. * Sets the current stencil reference
  31349. * @param reference defines the new stencil reference to use
  31350. */
  31351. setStencilFunctionReference(reference: number): void;
  31352. /**
  31353. * Sets the current stencil mask
  31354. * @param mask defines the new stencil mask to use
  31355. */
  31356. setStencilFunctionMask(mask: number): void;
  31357. /**
  31358. * Gets the current stencil operation when stencil fails
  31359. * @returns a number defining stencil operation to use when stencil fails
  31360. */
  31361. getStencilOperationFail(): number;
  31362. /**
  31363. * Gets the current stencil operation when depth fails
  31364. * @returns a number defining stencil operation to use when depth fails
  31365. */
  31366. getStencilOperationDepthFail(): number;
  31367. /**
  31368. * Gets the current stencil operation when stencil passes
  31369. * @returns a number defining stencil operation to use when stencil passes
  31370. */
  31371. getStencilOperationPass(): number;
  31372. /**
  31373. * Sets the stencil operation to use when stencil fails
  31374. * @param operation defines the stencil operation to use when stencil fails
  31375. */
  31376. setStencilOperationFail(operation: number): void;
  31377. /**
  31378. * Sets the stencil operation to use when depth fails
  31379. * @param operation defines the stencil operation to use when depth fails
  31380. */
  31381. setStencilOperationDepthFail(operation: number): void;
  31382. /**
  31383. * Sets the stencil operation to use when stencil passes
  31384. * @param operation defines the stencil operation to use when stencil passes
  31385. */
  31386. setStencilOperationPass(operation: number): void;
  31387. /**
  31388. * Sets a boolean indicating if the dithering state is enabled or disabled
  31389. * @param value defines the dithering state
  31390. */
  31391. setDitheringState(value: boolean): void;
  31392. /**
  31393. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31394. * @param value defines the rasterizer state
  31395. */
  31396. setRasterizerState(value: boolean): void;
  31397. /**
  31398. * stop executing a render loop function and remove it from the execution array
  31399. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31400. */
  31401. stopRenderLoop(renderFunction?: () => void): void;
  31402. /** @hidden */
  31403. _renderLoop(): void;
  31404. /**
  31405. * Register and execute a render loop. The engine can have more than one render function
  31406. * @param renderFunction defines the function to continuously execute
  31407. */
  31408. runRenderLoop(renderFunction: () => void): void;
  31409. /**
  31410. * Toggle full screen mode
  31411. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31412. */
  31413. switchFullscreen(requestPointerLock: boolean): void;
  31414. /**
  31415. * Enters full screen mode
  31416. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31417. */
  31418. enterFullscreen(requestPointerLock: boolean): void;
  31419. /**
  31420. * Exits full screen mode
  31421. */
  31422. exitFullscreen(): void;
  31423. /**
  31424. * Enters Pointerlock mode
  31425. */
  31426. enterPointerlock(): void;
  31427. /**
  31428. * Exits Pointerlock mode
  31429. */
  31430. exitPointerlock(): void;
  31431. /**
  31432. * Clear the current render buffer or the current render target (if any is set up)
  31433. * @param color defines the color to use
  31434. * @param backBuffer defines if the back buffer must be cleared
  31435. * @param depth defines if the depth buffer must be cleared
  31436. * @param stencil defines if the stencil buffer must be cleared
  31437. */
  31438. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31439. /**
  31440. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31441. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31442. * @param y defines the y-coordinate of the corner of the clear rectangle
  31443. * @param width defines the width of the clear rectangle
  31444. * @param height defines the height of the clear rectangle
  31445. * @param clearColor defines the clear color
  31446. */
  31447. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31448. /**
  31449. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31450. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31451. * @param y defines the y-coordinate of the corner of the clear rectangle
  31452. * @param width defines the width of the clear rectangle
  31453. * @param height defines the height of the clear rectangle
  31454. */
  31455. enableScissor(x: number, y: number, width: number, height: number): void;
  31456. /**
  31457. * Disable previously set scissor test rectangle
  31458. */
  31459. disableScissor(): void;
  31460. private _viewportCached;
  31461. /** @hidden */
  31462. _viewport(x: number, y: number, width: number, height: number): void;
  31463. /**
  31464. * Set the WebGL's viewport
  31465. * @param viewport defines the viewport element to be used
  31466. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31467. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31468. */
  31469. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31470. /**
  31471. * Directly set the WebGL Viewport
  31472. * @param x defines the x coordinate of the viewport (in screen space)
  31473. * @param y defines the y coordinate of the viewport (in screen space)
  31474. * @param width defines the width of the viewport (in screen space)
  31475. * @param height defines the height of the viewport (in screen space)
  31476. * @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
  31477. */
  31478. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31479. /**
  31480. * Begin a new frame
  31481. */
  31482. beginFrame(): void;
  31483. /**
  31484. * Enf the current frame
  31485. */
  31486. endFrame(): void;
  31487. /**
  31488. * Resize the view according to the canvas' size
  31489. */
  31490. resize(): void;
  31491. /**
  31492. * Force a specific size of the canvas
  31493. * @param width defines the new canvas' width
  31494. * @param height defines the new canvas' height
  31495. */
  31496. setSize(width: number, height: number): void;
  31497. /**
  31498. * Binds the frame buffer to the specified texture.
  31499. * @param texture The texture to render to or null for the default canvas
  31500. * @param faceIndex The face of the texture to render to in case of cube texture
  31501. * @param requiredWidth The width of the target to render to
  31502. * @param requiredHeight The height of the target to render to
  31503. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31504. * @param depthStencilTexture The depth stencil texture to use to render
  31505. * @param lodLevel defines le lod level to bind to the frame buffer
  31506. */
  31507. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31508. /** @hidden */
  31509. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31510. /**
  31511. * Unbind the current render target texture from the webGL context
  31512. * @param texture defines the render target texture to unbind
  31513. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31514. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31515. */
  31516. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31517. /**
  31518. * Force the mipmap generation for the given render target texture
  31519. * @param texture defines the render target texture to use
  31520. */
  31521. generateMipMapsForCubemap(texture: InternalTexture): void;
  31522. /**
  31523. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31524. */
  31525. flushFramebuffer(): void;
  31526. /**
  31527. * Unbind the current render target and bind the default framebuffer
  31528. */
  31529. restoreDefaultFramebuffer(): void;
  31530. /**
  31531. * Create an uniform buffer
  31532. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31533. * @param elements defines the content of the uniform buffer
  31534. * @returns the webGL uniform buffer
  31535. */
  31536. createUniformBuffer(elements: FloatArray): DataBuffer;
  31537. /**
  31538. * Create a dynamic uniform buffer
  31539. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31540. * @param elements defines the content of the uniform buffer
  31541. * @returns the webGL uniform buffer
  31542. */
  31543. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31544. /**
  31545. * Update an existing uniform buffer
  31546. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31547. * @param uniformBuffer defines the target uniform buffer
  31548. * @param elements defines the content to update
  31549. * @param offset defines the offset in the uniform buffer where update should start
  31550. * @param count defines the size of the data to update
  31551. */
  31552. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31553. private _resetVertexBufferBinding;
  31554. /**
  31555. * Creates a vertex buffer
  31556. * @param data the data for the vertex buffer
  31557. * @returns the new WebGL static buffer
  31558. */
  31559. createVertexBuffer(data: DataArray): DataBuffer;
  31560. /**
  31561. * Creates a dynamic vertex buffer
  31562. * @param data the data for the dynamic vertex buffer
  31563. * @returns the new WebGL dynamic buffer
  31564. */
  31565. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31566. /**
  31567. * Update a dynamic index buffer
  31568. * @param indexBuffer defines the target index buffer
  31569. * @param indices defines the data to update
  31570. * @param offset defines the offset in the target index buffer where update should start
  31571. */
  31572. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31573. /**
  31574. * Updates a dynamic vertex buffer.
  31575. * @param vertexBuffer the vertex buffer to update
  31576. * @param data the data used to update the vertex buffer
  31577. * @param byteOffset the byte offset of the data
  31578. * @param byteLength the byte length of the data
  31579. */
  31580. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31581. private _resetIndexBufferBinding;
  31582. /**
  31583. * Creates a new index buffer
  31584. * @param indices defines the content of the index buffer
  31585. * @param updatable defines if the index buffer must be updatable
  31586. * @returns a new webGL buffer
  31587. */
  31588. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31589. /**
  31590. * Bind a webGL buffer to the webGL context
  31591. * @param buffer defines the buffer to bind
  31592. */
  31593. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31594. /**
  31595. * Bind an uniform buffer to the current webGL context
  31596. * @param buffer defines the buffer to bind
  31597. */
  31598. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31599. /**
  31600. * Bind a buffer to the current webGL context at a given location
  31601. * @param buffer defines the buffer to bind
  31602. * @param location defines the index where to bind the buffer
  31603. */
  31604. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31605. /**
  31606. * Bind a specific block at a given index in a specific shader program
  31607. * @param pipelineContext defines the pipeline context to use
  31608. * @param blockName defines the block name
  31609. * @param index defines the index where to bind the block
  31610. */
  31611. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31612. private bindIndexBuffer;
  31613. private bindBuffer;
  31614. /**
  31615. * update the bound buffer with the given data
  31616. * @param data defines the data to update
  31617. */
  31618. updateArrayBuffer(data: Float32Array): void;
  31619. private _vertexAttribPointer;
  31620. private _bindIndexBufferWithCache;
  31621. private _bindVertexBuffersAttributes;
  31622. /**
  31623. * Records a vertex array object
  31624. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31625. * @param vertexBuffers defines the list of vertex buffers to store
  31626. * @param indexBuffer defines the index buffer to store
  31627. * @param effect defines the effect to store
  31628. * @returns the new vertex array object
  31629. */
  31630. recordVertexArrayObject(vertexBuffers: {
  31631. [key: string]: VertexBuffer;
  31632. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31633. /**
  31634. * Bind a specific vertex array object
  31635. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31636. * @param vertexArrayObject defines the vertex array object to bind
  31637. * @param indexBuffer defines the index buffer to bind
  31638. */
  31639. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31640. /**
  31641. * Bind webGl buffers directly to the webGL context
  31642. * @param vertexBuffer defines the vertex buffer to bind
  31643. * @param indexBuffer defines the index buffer to bind
  31644. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31645. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31646. * @param effect defines the effect associated with the vertex buffer
  31647. */
  31648. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31649. private _unbindVertexArrayObject;
  31650. /**
  31651. * Bind a list of vertex buffers to the webGL context
  31652. * @param vertexBuffers defines the list of vertex buffers to bind
  31653. * @param indexBuffer defines the index buffer to bind
  31654. * @param effect defines the effect associated with the vertex buffers
  31655. */
  31656. bindBuffers(vertexBuffers: {
  31657. [key: string]: Nullable<VertexBuffer>;
  31658. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31659. /**
  31660. * Unbind all instance attributes
  31661. */
  31662. unbindInstanceAttributes(): void;
  31663. /**
  31664. * Release and free the memory of a vertex array object
  31665. * @param vao defines the vertex array object to delete
  31666. */
  31667. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31668. /** @hidden */
  31669. _releaseBuffer(buffer: DataBuffer): boolean;
  31670. /**
  31671. * Creates a webGL buffer to use with instanciation
  31672. * @param capacity defines the size of the buffer
  31673. * @returns the webGL buffer
  31674. */
  31675. createInstancesBuffer(capacity: number): DataBuffer;
  31676. /**
  31677. * Delete a webGL buffer used with instanciation
  31678. * @param buffer defines the webGL buffer to delete
  31679. */
  31680. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31681. /**
  31682. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31683. * @param instancesBuffer defines the webGL buffer to update and bind
  31684. * @param data defines the data to store in the buffer
  31685. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31686. */
  31687. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31688. /**
  31689. * Apply all cached states (depth, culling, stencil and alpha)
  31690. */
  31691. applyStates(): void;
  31692. /**
  31693. * Send a draw order
  31694. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31695. * @param indexStart defines the starting index
  31696. * @param indexCount defines the number of index to draw
  31697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31698. */
  31699. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31700. /**
  31701. * Draw a list of points
  31702. * @param verticesStart defines the index of first vertex to draw
  31703. * @param verticesCount defines the count of vertices to draw
  31704. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31705. */
  31706. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31707. /**
  31708. * Draw a list of unindexed primitives
  31709. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31710. * @param verticesStart defines the index of first vertex to draw
  31711. * @param verticesCount defines the count of vertices to draw
  31712. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31713. */
  31714. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31715. /**
  31716. * Draw a list of indexed primitives
  31717. * @param fillMode defines the primitive to use
  31718. * @param indexStart defines the starting index
  31719. * @param indexCount defines the number of index to draw
  31720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31721. */
  31722. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31723. /**
  31724. * Draw a list of unindexed primitives
  31725. * @param fillMode defines the primitive to use
  31726. * @param verticesStart defines the index of first vertex to draw
  31727. * @param verticesCount defines the count of vertices to draw
  31728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31729. */
  31730. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31731. private _drawMode;
  31732. /** @hidden */
  31733. _releaseEffect(effect: Effect): void;
  31734. /** @hidden */
  31735. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31736. /**
  31737. * Create a new effect (used to store vertex/fragment shaders)
  31738. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31739. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31740. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31741. * @param samplers defines an array of string used to represent textures
  31742. * @param defines defines the string containing the defines to use to compile the shaders
  31743. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31744. * @param onCompiled defines a function to call when the effect creation is successful
  31745. * @param onError defines a function to call when the effect creation has failed
  31746. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31747. * @returns the new Effect
  31748. */
  31749. 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;
  31750. private _compileShader;
  31751. private _compileRawShader;
  31752. /**
  31753. * Directly creates a webGL program
  31754. * @param pipelineContext defines the pipeline context to attach to
  31755. * @param vertexCode defines the vertex shader code to use
  31756. * @param fragmentCode defines the fragment shader code to use
  31757. * @param context defines the webGL context to use (if not set, the current one will be used)
  31758. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31759. * @returns the new webGL program
  31760. */
  31761. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31762. /**
  31763. * Creates a webGL program
  31764. * @param pipelineContext defines the pipeline context to attach to
  31765. * @param vertexCode defines the vertex shader code to use
  31766. * @param fragmentCode defines the fragment shader code to use
  31767. * @param defines defines the string containing the defines to use to compile the shaders
  31768. * @param context defines the webGL context to use (if not set, the current one will be used)
  31769. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31770. * @returns the new webGL program
  31771. */
  31772. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31773. /**
  31774. * Creates a new pipeline context
  31775. * @returns the new pipeline
  31776. */
  31777. createPipelineContext(): WebGLPipelineContext;
  31778. private _createShaderProgram;
  31779. private _finalizePipelineContext;
  31780. /** @hidden */
  31781. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31782. /** @hidden */
  31783. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31784. /** @hidden */
  31785. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31786. /**
  31787. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31788. * @param pipelineContext defines the pipeline context to use
  31789. * @param uniformsNames defines the list of uniform names
  31790. * @returns an array of webGL uniform locations
  31791. */
  31792. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31793. /**
  31794. * Gets the lsit of active attributes for a given webGL program
  31795. * @param pipelineContext defines the pipeline context to use
  31796. * @param attributesNames defines the list of attribute names to get
  31797. * @returns an array of indices indicating the offset of each attribute
  31798. */
  31799. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31800. /**
  31801. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31802. * @param effect defines the effect to activate
  31803. */
  31804. enableEffect(effect: Nullable<Effect>): void;
  31805. /**
  31806. * Set the value of an uniform to an array of int32
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param array defines the array of int32 to store
  31809. */
  31810. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31811. /**
  31812. * Set the value of an uniform to an array of int32 (stored as vec2)
  31813. * @param uniform defines the webGL uniform location where to store the value
  31814. * @param array defines the array of int32 to store
  31815. */
  31816. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31817. /**
  31818. * Set the value of an uniform to an array of int32 (stored as vec3)
  31819. * @param uniform defines the webGL uniform location where to store the value
  31820. * @param array defines the array of int32 to store
  31821. */
  31822. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31823. /**
  31824. * Set the value of an uniform to an array of int32 (stored as vec4)
  31825. * @param uniform defines the webGL uniform location where to store the value
  31826. * @param array defines the array of int32 to store
  31827. */
  31828. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31829. /**
  31830. * Set the value of an uniform to an array of float32
  31831. * @param uniform defines the webGL uniform location where to store the value
  31832. * @param array defines the array of float32 to store
  31833. */
  31834. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31835. /**
  31836. * Set the value of an uniform to an array of float32 (stored as vec2)
  31837. * @param uniform defines the webGL uniform location where to store the value
  31838. * @param array defines the array of float32 to store
  31839. */
  31840. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31841. /**
  31842. * Set the value of an uniform to an array of float32 (stored as vec3)
  31843. * @param uniform defines the webGL uniform location where to store the value
  31844. * @param array defines the array of float32 to store
  31845. */
  31846. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31847. /**
  31848. * Set the value of an uniform to an array of float32 (stored as vec4)
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param array defines the array of float32 to store
  31851. */
  31852. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31853. /**
  31854. * Set the value of an uniform to an array of number
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param array defines the array of number to store
  31857. */
  31858. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31859. /**
  31860. * Set the value of an uniform to an array of number (stored as vec2)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param array defines the array of number to store
  31863. */
  31864. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31865. /**
  31866. * Set the value of an uniform to an array of number (stored as vec3)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param array defines the array of number to store
  31869. */
  31870. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31871. /**
  31872. * Set the value of an uniform to an array of number (stored as vec4)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param array defines the array of number to store
  31875. */
  31876. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31877. /**
  31878. * Set the value of an uniform to an array of float32 (stored as matrices)
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param matrices defines the array of float32 to store
  31881. */
  31882. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31883. /**
  31884. * Set the value of an uniform to a matrix (3x3)
  31885. * @param uniform defines the webGL uniform location where to store the value
  31886. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31887. */
  31888. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31889. /**
  31890. * Set the value of an uniform to a matrix (2x2)
  31891. * @param uniform defines the webGL uniform location where to store the value
  31892. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31893. */
  31894. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31895. /**
  31896. * Set the value of an uniform to a number (int)
  31897. * @param uniform defines the webGL uniform location where to store the value
  31898. * @param value defines the int number to store
  31899. */
  31900. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31901. /**
  31902. * Set the value of an uniform to a number (float)
  31903. * @param uniform defines the webGL uniform location where to store the value
  31904. * @param value defines the float number to store
  31905. */
  31906. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31907. /**
  31908. * Set the value of an uniform to a vec2
  31909. * @param uniform defines the webGL uniform location where to store the value
  31910. * @param x defines the 1st component of the value
  31911. * @param y defines the 2nd component of the value
  31912. */
  31913. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31914. /**
  31915. * Set the value of an uniform to a vec3
  31916. * @param uniform defines the webGL uniform location where to store the value
  31917. * @param x defines the 1st component of the value
  31918. * @param y defines the 2nd component of the value
  31919. * @param z defines the 3rd component of the value
  31920. */
  31921. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31922. /**
  31923. * Set the value of an uniform to a boolean
  31924. * @param uniform defines the webGL uniform location where to store the value
  31925. * @param bool defines the boolean to store
  31926. */
  31927. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31928. /**
  31929. * Set the value of an uniform to a vec4
  31930. * @param uniform defines the webGL uniform location where to store the value
  31931. * @param x defines the 1st component of the value
  31932. * @param y defines the 2nd component of the value
  31933. * @param z defines the 3rd component of the value
  31934. * @param w defines the 4th component of the value
  31935. */
  31936. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31937. /**
  31938. * Sets a Color4 on a uniform variable
  31939. * @param uniform defines the uniform location
  31940. * @param color4 defines the value to be set
  31941. */
  31942. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31943. /**
  31944. * Set various states to the webGL context
  31945. * @param culling defines backface culling state
  31946. * @param zOffset defines the value to apply to zOffset (0 by default)
  31947. * @param force defines if states must be applied even if cache is up to date
  31948. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31949. */
  31950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31951. /**
  31952. * Set the z offset to apply to current rendering
  31953. * @param value defines the offset to apply
  31954. */
  31955. setZOffset(value: number): void;
  31956. /**
  31957. * Gets the current value of the zOffset
  31958. * @returns the current zOffset state
  31959. */
  31960. getZOffset(): number;
  31961. /**
  31962. * Enable or disable depth buffering
  31963. * @param enable defines the state to set
  31964. */
  31965. setDepthBuffer(enable: boolean): void;
  31966. /**
  31967. * Gets a boolean indicating if depth writing is enabled
  31968. * @returns the current depth writing state
  31969. */
  31970. getDepthWrite(): boolean;
  31971. /**
  31972. * Enable or disable depth writing
  31973. * @param enable defines the state to set
  31974. */
  31975. setDepthWrite(enable: boolean): void;
  31976. /**
  31977. * Enable or disable color writing
  31978. * @param enable defines the state to set
  31979. */
  31980. setColorWrite(enable: boolean): void;
  31981. /**
  31982. * Gets a boolean indicating if color writing is enabled
  31983. * @returns the current color writing state
  31984. */
  31985. getColorWrite(): boolean;
  31986. /**
  31987. * Sets alpha constants used by some alpha blending modes
  31988. * @param r defines the red component
  31989. * @param g defines the green component
  31990. * @param b defines the blue component
  31991. * @param a defines the alpha component
  31992. */
  31993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31994. /**
  31995. * Sets the current alpha mode
  31996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31999. */
  32000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32001. /**
  32002. * Gets the current alpha mode
  32003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32004. * @returns the current alpha mode
  32005. */
  32006. getAlphaMode(): number;
  32007. /**
  32008. * Clears the list of texture accessible through engine.
  32009. * This can help preventing texture load conflict due to name collision.
  32010. */
  32011. clearInternalTexturesCache(): void;
  32012. /**
  32013. * Force the entire cache to be cleared
  32014. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32015. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32016. */
  32017. wipeCaches(bruteForce?: boolean): void;
  32018. /**
  32019. * Set the compressed texture format to use, based on the formats you have, and the formats
  32020. * supported by the hardware / browser.
  32021. *
  32022. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32023. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32024. * to API arguments needed to compressed textures. This puts the burden on the container
  32025. * generator to house the arcane code for determining these for current & future formats.
  32026. *
  32027. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32028. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32029. *
  32030. * Note: The result of this call is not taken into account when a texture is base64.
  32031. *
  32032. * @param formatsAvailable defines the list of those format families you have created
  32033. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32034. *
  32035. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32036. * @returns The extension selected.
  32037. */
  32038. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32039. /** @hidden */
  32040. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32041. min: number;
  32042. mag: number;
  32043. };
  32044. /** @hidden */
  32045. _createTexture(): WebGLTexture;
  32046. /**
  32047. * Usually called from Texture.ts.
  32048. * Passed information to create a WebGLTexture
  32049. * @param urlArg defines a value which contains one of the following:
  32050. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32051. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32052. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32053. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32054. * @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)
  32055. * @param scene needed for loading to the correct scene
  32056. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32057. * @param onLoad optional callback to be called upon successful completion
  32058. * @param onError optional callback to be called upon failure
  32059. * @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
  32060. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32061. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32062. * @param forcedExtension defines the extension to use to pick the right loader
  32063. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32064. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32065. */
  32066. 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;
  32067. /**
  32068. * @hidden
  32069. * Rescales a texture
  32070. * @param source input texutre
  32071. * @param destination destination texture
  32072. * @param scene scene to use to render the resize
  32073. * @param internalFormat format to use when resizing
  32074. * @param onComplete callback to be called when resize has completed
  32075. */
  32076. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32077. private _unpackFlipYCached;
  32078. /**
  32079. * In case you are sharing the context with other applications, it might
  32080. * be interested to not cache the unpack flip y state to ensure a consistent
  32081. * value would be set.
  32082. */
  32083. enableUnpackFlipYCached: boolean;
  32084. /** @hidden */
  32085. _unpackFlipY(value: boolean): void;
  32086. /** @hidden */
  32087. _getUnpackAlignement(): number;
  32088. /**
  32089. * Creates a dynamic texture
  32090. * @param width defines the width of the texture
  32091. * @param height defines the height of the texture
  32092. * @param generateMipMaps defines if the engine should generate the mip levels
  32093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32094. * @returns the dynamic texture inside an InternalTexture
  32095. */
  32096. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32097. /**
  32098. * Update the sampling mode of a given texture
  32099. * @param samplingMode defines the required sampling mode
  32100. * @param texture defines the texture to update
  32101. */
  32102. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32103. /**
  32104. * Update the content of a dynamic texture
  32105. * @param texture defines the texture to update
  32106. * @param canvas defines the canvas containing the source
  32107. * @param invertY defines if data must be stored with Y axis inverted
  32108. * @param premulAlpha defines if alpha is stored as premultiplied
  32109. * @param format defines the format of the data
  32110. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32111. */
  32112. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32113. /**
  32114. * Update a video texture
  32115. * @param texture defines the texture to update
  32116. * @param video defines the video element to use
  32117. * @param invertY defines if data must be stored with Y axis inverted
  32118. */
  32119. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32120. /**
  32121. * Updates a depth texture Comparison Mode and Function.
  32122. * If the comparison Function is equal to 0, the mode will be set to none.
  32123. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32124. * @param texture The texture to set the comparison function for
  32125. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32126. */
  32127. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32128. /** @hidden */
  32129. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32130. width: number;
  32131. height: number;
  32132. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32133. /**
  32134. * Creates a depth stencil texture.
  32135. * This is only available in WebGL 2 or with the depth texture extension available.
  32136. * @param size The size of face edge in the texture.
  32137. * @param options The options defining the texture.
  32138. * @returns The texture
  32139. */
  32140. createDepthStencilTexture(size: number | {
  32141. width: number;
  32142. height: number;
  32143. }, options: DepthTextureCreationOptions): InternalTexture;
  32144. /**
  32145. * Creates a depth stencil texture.
  32146. * This is only available in WebGL 2 or with the depth texture extension available.
  32147. * @param size The size of face edge in the texture.
  32148. * @param options The options defining the texture.
  32149. * @returns The texture
  32150. */
  32151. private _createDepthStencilTexture;
  32152. /**
  32153. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32154. * @param renderTarget The render target to set the frame buffer for
  32155. */
  32156. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32157. /**
  32158. * Creates a new render target texture
  32159. * @param size defines the size of the texture
  32160. * @param options defines the options used to create the texture
  32161. * @returns a new render target texture stored in an InternalTexture
  32162. */
  32163. createRenderTargetTexture(size: number | {
  32164. width: number;
  32165. height: number;
  32166. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32167. /** @hidden */
  32168. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32169. /**
  32170. * Updates the sample count of a render target texture
  32171. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32172. * @param texture defines the texture to update
  32173. * @param samples defines the sample count to set
  32174. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32175. */
  32176. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32177. /** @hidden */
  32178. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32179. /** @hidden */
  32180. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32181. /** @hidden */
  32182. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32183. /** @hidden */
  32184. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32185. /**
  32186. * @hidden
  32187. */
  32188. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32189. private _prepareWebGLTextureContinuation;
  32190. private _prepareWebGLTexture;
  32191. /** @hidden */
  32192. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32193. /** @hidden */
  32194. _releaseFramebufferObjects(texture: InternalTexture): void;
  32195. /** @hidden */
  32196. _releaseTexture(texture: InternalTexture): void;
  32197. private setProgram;
  32198. private _boundUniforms;
  32199. /**
  32200. * Binds an effect to the webGL context
  32201. * @param effect defines the effect to bind
  32202. */
  32203. bindSamplers(effect: Effect): void;
  32204. private _activateCurrentTexture;
  32205. /** @hidden */
  32206. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32207. /** @hidden */
  32208. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32209. /**
  32210. * Sets a texture to the webGL context from a postprocess
  32211. * @param channel defines the channel to use
  32212. * @param postProcess defines the source postprocess
  32213. */
  32214. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32215. /**
  32216. * Binds the output of the passed in post process to the texture channel specified
  32217. * @param channel The channel the texture should be bound to
  32218. * @param postProcess The post process which's output should be bound
  32219. */
  32220. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32221. /**
  32222. * Unbind all textures from the webGL context
  32223. */
  32224. unbindAllTextures(): void;
  32225. /**
  32226. * Sets a texture to the according uniform.
  32227. * @param channel The texture channel
  32228. * @param uniform The uniform to set
  32229. * @param texture The texture to apply
  32230. */
  32231. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32232. /**
  32233. * Sets a depth stencil texture from a render target to the according uniform.
  32234. * @param channel The texture channel
  32235. * @param uniform The uniform to set
  32236. * @param texture The render target texture containing the depth stencil texture to apply
  32237. */
  32238. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32239. private _bindSamplerUniformToChannel;
  32240. private _getTextureWrapMode;
  32241. private _setTexture;
  32242. /**
  32243. * Sets an array of texture to the webGL context
  32244. * @param channel defines the channel where the texture array must be set
  32245. * @param uniform defines the associated uniform location
  32246. * @param textures defines the array of textures to bind
  32247. */
  32248. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32249. /** @hidden */
  32250. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32251. private _setTextureParameterFloat;
  32252. private _setTextureParameterInteger;
  32253. /**
  32254. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32255. * @param x defines the x coordinate of the rectangle where pixels must be read
  32256. * @param y defines the y coordinate of the rectangle where pixels must be read
  32257. * @param width defines the width of the rectangle where pixels must be read
  32258. * @param height defines the height of the rectangle where pixels must be read
  32259. * @returns a Uint8Array containing RGBA colors
  32260. */
  32261. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32262. /**
  32263. * Add an externaly attached data from its key.
  32264. * This method call will fail and return false, if such key already exists.
  32265. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32266. * @param key the unique key that identifies the data
  32267. * @param data the data object to associate to the key for this Engine instance
  32268. * @return true if no such key were already present and the data was added successfully, false otherwise
  32269. */
  32270. addExternalData<T>(key: string, data: T): boolean;
  32271. /**
  32272. * Get an externaly attached data from its key
  32273. * @param key the unique key that identifies the data
  32274. * @return the associated data, if present (can be null), or undefined if not present
  32275. */
  32276. getExternalData<T>(key: string): T;
  32277. /**
  32278. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32279. * @param key the unique key that identifies the data
  32280. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32281. * @return the associated data, can be null if the factory returned null.
  32282. */
  32283. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32284. /**
  32285. * Remove an externaly attached data from the Engine instance
  32286. * @param key the unique key that identifies the data
  32287. * @return true if the data was successfully removed, false if it doesn't exist
  32288. */
  32289. removeExternalData(key: string): boolean;
  32290. /**
  32291. * Unbind all vertex attributes from the webGL context
  32292. */
  32293. unbindAllAttributes(): void;
  32294. /**
  32295. * 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
  32296. */
  32297. releaseEffects(): void;
  32298. /**
  32299. * Dispose and release all associated resources
  32300. */
  32301. dispose(): void;
  32302. /**
  32303. * Display the loading screen
  32304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32305. */
  32306. displayLoadingUI(): void;
  32307. /**
  32308. * Hide the loading screen
  32309. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32310. */
  32311. hideLoadingUI(): void;
  32312. /**
  32313. * Gets the current loading screen object
  32314. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32315. */
  32316. /**
  32317. * Sets the current loading screen object
  32318. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32319. */
  32320. loadingScreen: ILoadingScreen;
  32321. /**
  32322. * Sets the current loading screen text
  32323. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32324. */
  32325. loadingUIText: string;
  32326. /**
  32327. * Sets the current loading screen background color
  32328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32329. */
  32330. loadingUIBackgroundColor: string;
  32331. /**
  32332. * Attach a new callback raised when context lost event is fired
  32333. * @param callback defines the callback to call
  32334. */
  32335. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32336. /**
  32337. * Attach a new callback raised when context restored event is fired
  32338. * @param callback defines the callback to call
  32339. */
  32340. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32341. /**
  32342. * Gets the source code of the vertex shader associated with a specific webGL program
  32343. * @param program defines the program to use
  32344. * @returns a string containing the source code of the vertex shader associated with the program
  32345. */
  32346. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32347. /**
  32348. * Gets the source code of the fragment shader associated with a specific webGL program
  32349. * @param program defines the program to use
  32350. * @returns a string containing the source code of the fragment shader associated with the program
  32351. */
  32352. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32353. /**
  32354. * Get the current error code of the webGL context
  32355. * @returns the error code
  32356. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32357. */
  32358. getError(): number;
  32359. /**
  32360. * Gets the current framerate
  32361. * @returns a number representing the framerate
  32362. */
  32363. getFps(): number;
  32364. /**
  32365. * Gets the time spent between current and previous frame
  32366. * @returns a number representing the delta time in ms
  32367. */
  32368. getDeltaTime(): number;
  32369. private _measureFps;
  32370. /** @hidden */
  32371. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32372. private _canRenderToFloatFramebuffer;
  32373. private _canRenderToHalfFloatFramebuffer;
  32374. private _canRenderToFramebuffer;
  32375. /** @hidden */
  32376. _getWebGLTextureType(type: number): number;
  32377. /** @hidden */
  32378. _getInternalFormat(format: number): number;
  32379. /** @hidden */
  32380. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32381. /** @hidden */
  32382. _getRGBAMultiSampleBufferFormat(type: number): number;
  32383. /** @hidden */
  32384. _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;
  32385. /** @hidden */
  32386. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32387. /**
  32388. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32389. * @returns true if the engine can be created
  32390. * @ignorenaming
  32391. */
  32392. static isSupported(): boolean;
  32393. /**
  32394. * Find the next highest power of two.
  32395. * @param x Number to start search from.
  32396. * @return Next highest power of two.
  32397. */
  32398. static CeilingPOT(x: number): number;
  32399. /**
  32400. * Find the next lowest power of two.
  32401. * @param x Number to start search from.
  32402. * @return Next lowest power of two.
  32403. */
  32404. static FloorPOT(x: number): number;
  32405. /**
  32406. * Find the nearest power of two.
  32407. * @param x Number to start search from.
  32408. * @return Next nearest power of two.
  32409. */
  32410. static NearestPOT(x: number): number;
  32411. /**
  32412. * Get the closest exponent of two
  32413. * @param value defines the value to approximate
  32414. * @param max defines the maximum value to return
  32415. * @param mode defines how to define the closest value
  32416. * @returns closest exponent of two of the given value
  32417. */
  32418. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32419. /**
  32420. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32421. * @param func - the function to be called
  32422. * @param requester - the object that will request the next frame. Falls back to window.
  32423. * @returns frame number
  32424. */
  32425. static QueueNewFrame(func: () => void, requester?: any): number;
  32426. /**
  32427. * Ask the browser to promote the current element to pointerlock mode
  32428. * @param element defines the DOM element to promote
  32429. */
  32430. static _RequestPointerlock(element: HTMLElement): void;
  32431. /**
  32432. * Asks the browser to exit pointerlock mode
  32433. */
  32434. static _ExitPointerlock(): void;
  32435. /**
  32436. * Ask the browser to promote the current element to fullscreen rendering mode
  32437. * @param element defines the DOM element to promote
  32438. */
  32439. static _RequestFullscreen(element: HTMLElement): void;
  32440. /**
  32441. * Asks the browser to exit fullscreen mode
  32442. */
  32443. static _ExitFullscreen(): void;
  32444. }
  32445. }
  32446. declare module "babylonjs/Engines/engineStore" {
  32447. import { Nullable } from "babylonjs/types";
  32448. import { Engine } from "babylonjs/Engines/engine";
  32449. import { Scene } from "babylonjs/scene";
  32450. /**
  32451. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32452. * during the life time of the application.
  32453. */
  32454. export class EngineStore {
  32455. /** Gets the list of created engines */
  32456. static Instances: import("babylonjs/Engines/engine").Engine[];
  32457. /** @hidden */
  32458. static _LastCreatedScene: Nullable<Scene>;
  32459. /**
  32460. * Gets the latest created engine
  32461. */
  32462. static readonly LastCreatedEngine: Nullable<Engine>;
  32463. /**
  32464. * Gets the latest created scene
  32465. */
  32466. static readonly LastCreatedScene: Nullable<Scene>;
  32467. /**
  32468. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32469. * @ignorenaming
  32470. */
  32471. static UseFallbackTexture: boolean;
  32472. /**
  32473. * Texture content used if a texture cannot loaded
  32474. * @ignorenaming
  32475. */
  32476. static FallbackTexture: string;
  32477. }
  32478. }
  32479. declare module "babylonjs/Misc/promise" {
  32480. /**
  32481. * Helper class that provides a small promise polyfill
  32482. */
  32483. export class PromisePolyfill {
  32484. /**
  32485. * Static function used to check if the polyfill is required
  32486. * If this is the case then the function will inject the polyfill to window.Promise
  32487. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32488. */
  32489. static Apply(force?: boolean): void;
  32490. }
  32491. }
  32492. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32493. /**
  32494. * Interface for screenshot methods with describe argument called `size` as object with options
  32495. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32496. */
  32497. export interface IScreenshotSize {
  32498. /**
  32499. * number in pixels for canvas height
  32500. */
  32501. height?: number;
  32502. /**
  32503. * multiplier allowing render at a higher or lower resolution
  32504. * If value is defined then height and width will be ignored and taken from camera
  32505. */
  32506. precision?: number;
  32507. /**
  32508. * number in pixels for canvas width
  32509. */
  32510. width?: number;
  32511. }
  32512. }
  32513. declare module "babylonjs/Misc/tools" {
  32514. import { Nullable, float } from "babylonjs/types";
  32515. import { DomManagement } from "babylonjs/Misc/domManagement";
  32516. import { WebRequest } from "babylonjs/Misc/webRequest";
  32517. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32518. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32519. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32520. import { Camera } from "babylonjs/Cameras/camera";
  32521. import { Engine } from "babylonjs/Engines/engine";
  32522. interface IColor4Like {
  32523. r: float;
  32524. g: float;
  32525. b: float;
  32526. a: float;
  32527. }
  32528. /**
  32529. * Class containing a set of static utilities functions
  32530. */
  32531. export class Tools {
  32532. /**
  32533. * Gets or sets the base URL to use to load assets
  32534. */
  32535. static BaseUrl: string;
  32536. /**
  32537. * Enable/Disable Custom HTTP Request Headers globally.
  32538. * default = false
  32539. * @see CustomRequestHeaders
  32540. */
  32541. static UseCustomRequestHeaders: boolean;
  32542. /**
  32543. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32544. * i.e. when loading files, where the server/service expects an Authorization header
  32545. */
  32546. static CustomRequestHeaders: {
  32547. [key: string]: string;
  32548. };
  32549. /**
  32550. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32551. */
  32552. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32553. /**
  32554. * Default behaviour for cors in the application.
  32555. * It can be a string if the expected behavior is identical in the entire app.
  32556. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32557. */
  32558. static CorsBehavior: string | ((url: string | string[]) => string);
  32559. /**
  32560. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32561. * @ignorenaming
  32562. */
  32563. static UseFallbackTexture: boolean;
  32564. /**
  32565. * Use this object to register external classes like custom textures or material
  32566. * to allow the laoders to instantiate them
  32567. */
  32568. static RegisteredExternalClasses: {
  32569. [key: string]: Object;
  32570. };
  32571. /**
  32572. * Texture content used if a texture cannot loaded
  32573. * @ignorenaming
  32574. */
  32575. static fallbackTexture: string;
  32576. /**
  32577. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32578. * @param u defines the coordinate on X axis
  32579. * @param v defines the coordinate on Y axis
  32580. * @param width defines the width of the source data
  32581. * @param height defines the height of the source data
  32582. * @param pixels defines the source byte array
  32583. * @param color defines the output color
  32584. */
  32585. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32586. /**
  32587. * Interpolates between a and b via alpha
  32588. * @param a The lower value (returned when alpha = 0)
  32589. * @param b The upper value (returned when alpha = 1)
  32590. * @param alpha The interpolation-factor
  32591. * @return The mixed value
  32592. */
  32593. static Mix(a: number, b: number, alpha: number): number;
  32594. /**
  32595. * Tries to instantiate a new object from a given class name
  32596. * @param className defines the class name to instantiate
  32597. * @returns the new object or null if the system was not able to do the instantiation
  32598. */
  32599. static Instantiate(className: string): any;
  32600. /**
  32601. * Provides a slice function that will work even on IE
  32602. * @param data defines the array to slice
  32603. * @param start defines the start of the data (optional)
  32604. * @param end defines the end of the data (optional)
  32605. * @returns the new sliced array
  32606. */
  32607. static Slice<T>(data: T, start?: number, end?: number): T;
  32608. /**
  32609. * Polyfill for setImmediate
  32610. * @param action defines the action to execute after the current execution block
  32611. */
  32612. static SetImmediate(action: () => void): void;
  32613. /**
  32614. * Function indicating if a number is an exponent of 2
  32615. * @param value defines the value to test
  32616. * @returns true if the value is an exponent of 2
  32617. */
  32618. static IsExponentOfTwo(value: number): boolean;
  32619. private static _tmpFloatArray;
  32620. /**
  32621. * Returns the nearest 32-bit single precision float representation of a Number
  32622. * @param value A Number. If the parameter is of a different type, it will get converted
  32623. * to a number or to NaN if it cannot be converted
  32624. * @returns number
  32625. */
  32626. static FloatRound(value: number): number;
  32627. /**
  32628. * Extracts the filename from a path
  32629. * @param path defines the path to use
  32630. * @returns the filename
  32631. */
  32632. static GetFilename(path: string): string;
  32633. /**
  32634. * Extracts the "folder" part of a path (everything before the filename).
  32635. * @param uri The URI to extract the info from
  32636. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32637. * @returns The "folder" part of the path
  32638. */
  32639. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32640. /**
  32641. * Extracts text content from a DOM element hierarchy
  32642. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32643. */
  32644. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32645. /**
  32646. * Convert an angle in radians to degrees
  32647. * @param angle defines the angle to convert
  32648. * @returns the angle in degrees
  32649. */
  32650. static ToDegrees(angle: number): number;
  32651. /**
  32652. * Convert an angle in degrees to radians
  32653. * @param angle defines the angle to convert
  32654. * @returns the angle in radians
  32655. */
  32656. static ToRadians(angle: number): number;
  32657. /**
  32658. * Encode a buffer to a base64 string
  32659. * @param buffer defines the buffer to encode
  32660. * @returns the encoded string
  32661. */
  32662. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32663. /**
  32664. * Returns an array if obj is not an array
  32665. * @param obj defines the object to evaluate as an array
  32666. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32667. * @returns either obj directly if obj is an array or a new array containing obj
  32668. */
  32669. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32670. /**
  32671. * Gets the pointer prefix to use
  32672. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32673. */
  32674. static GetPointerPrefix(): string;
  32675. /**
  32676. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32677. * @param url define the url we are trying
  32678. * @param element define the dom element where to configure the cors policy
  32679. */
  32680. static SetCorsBehavior(url: string | string[], element: {
  32681. crossOrigin: string | null;
  32682. }): void;
  32683. /**
  32684. * Removes unwanted characters from an url
  32685. * @param url defines the url to clean
  32686. * @returns the cleaned url
  32687. */
  32688. static CleanUrl(url: string): string;
  32689. /**
  32690. * Gets or sets a function used to pre-process url before using them to load assets
  32691. */
  32692. static PreprocessUrl: (url: string) => string;
  32693. /**
  32694. * Loads an image as an HTMLImageElement.
  32695. * @param input url string, ArrayBuffer, or Blob to load
  32696. * @param onLoad callback called when the image successfully loads
  32697. * @param onError callback called when the image fails to load
  32698. * @param offlineProvider offline provider for caching
  32699. * @returns the HTMLImageElement of the loaded image
  32700. */
  32701. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32702. /**
  32703. * Loads a file
  32704. * @param url url string, ArrayBuffer, or Blob to load
  32705. * @param onSuccess callback called when the file successfully loads
  32706. * @param onProgress callback called while file is loading (if the server supports this mode)
  32707. * @param offlineProvider defines the offline provider for caching
  32708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32709. * @param onError callback called when the file fails to load
  32710. * @returns a file request object
  32711. */
  32712. 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;
  32713. /**
  32714. * Loads a file from a url
  32715. * @param url the file url to load
  32716. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32717. */
  32718. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32719. /**
  32720. * Load a script (identified by an url). When the url returns, the
  32721. * content of this file is added into a new script element, attached to the DOM (body element)
  32722. * @param scriptUrl defines the url of the script to laod
  32723. * @param onSuccess defines the callback called when the script is loaded
  32724. * @param onError defines the callback to call if an error occurs
  32725. * @param scriptId defines the id of the script element
  32726. */
  32727. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32728. /**
  32729. * Load an asynchronous script (identified by an url). When the url returns, the
  32730. * content of this file is added into a new script element, attached to the DOM (body element)
  32731. * @param scriptUrl defines the url of the script to laod
  32732. * @param scriptId defines the id of the script element
  32733. * @returns a promise request object
  32734. */
  32735. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32736. /**
  32737. * Loads a file from a blob
  32738. * @param fileToLoad defines the blob to use
  32739. * @param callback defines the callback to call when data is loaded
  32740. * @param progressCallback defines the callback to call during loading process
  32741. * @returns a file request object
  32742. */
  32743. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32744. /**
  32745. * Loads a file
  32746. * @param fileToLoad defines the file to load
  32747. * @param callback defines the callback to call when data is loaded
  32748. * @param progressCallBack defines the callback to call during loading process
  32749. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32750. * @returns a file request object
  32751. */
  32752. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32753. /**
  32754. * Creates a data url from a given string content
  32755. * @param content defines the content to convert
  32756. * @returns the new data url link
  32757. */
  32758. static FileAsURL(content: string): string;
  32759. /**
  32760. * Format the given number to a specific decimal format
  32761. * @param value defines the number to format
  32762. * @param decimals defines the number of decimals to use
  32763. * @returns the formatted string
  32764. */
  32765. static Format(value: number, decimals?: number): string;
  32766. /**
  32767. * Tries to copy an object by duplicating every property
  32768. * @param source defines the source object
  32769. * @param destination defines the target object
  32770. * @param doNotCopyList defines a list of properties to avoid
  32771. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32772. */
  32773. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32774. /**
  32775. * Gets a boolean indicating if the given object has no own property
  32776. * @param obj defines the object to test
  32777. * @returns true if object has no own property
  32778. */
  32779. static IsEmpty(obj: any): boolean;
  32780. /**
  32781. * Function used to register events at window level
  32782. * @param windowElement defines the Window object to use
  32783. * @param events defines the events to register
  32784. */
  32785. static RegisterTopRootEvents(windowElement: Window, events: {
  32786. name: string;
  32787. handler: Nullable<(e: FocusEvent) => any>;
  32788. }[]): void;
  32789. /**
  32790. * Function used to unregister events from window level
  32791. * @param windowElement defines the Window object to use
  32792. * @param events defines the events to unregister
  32793. */
  32794. static UnregisterTopRootEvents(windowElement: Window, events: {
  32795. name: string;
  32796. handler: Nullable<(e: FocusEvent) => any>;
  32797. }[]): void;
  32798. /**
  32799. * @ignore
  32800. */
  32801. static _ScreenshotCanvas: HTMLCanvasElement;
  32802. /**
  32803. * Dumps the current bound framebuffer
  32804. * @param width defines the rendering width
  32805. * @param height defines the rendering height
  32806. * @param engine defines the hosting engine
  32807. * @param successCallback defines the callback triggered once the data are available
  32808. * @param mimeType defines the mime type of the result
  32809. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32810. */
  32811. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32812. /**
  32813. * Converts the canvas data to blob.
  32814. * This acts as a polyfill for browsers not supporting the to blob function.
  32815. * @param canvas Defines the canvas to extract the data from
  32816. * @param successCallback Defines the callback triggered once the data are available
  32817. * @param mimeType Defines the mime type of the result
  32818. */
  32819. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32820. /**
  32821. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32822. * @param successCallback defines the callback triggered once the data are available
  32823. * @param mimeType defines the mime type of the result
  32824. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32825. */
  32826. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32827. /**
  32828. * Downloads a blob in the browser
  32829. * @param blob defines the blob to download
  32830. * @param fileName defines the name of the downloaded file
  32831. */
  32832. static Download(blob: Blob, fileName: string): void;
  32833. /**
  32834. * Captures a screenshot of the current rendering
  32835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32836. * @param engine defines the rendering engine
  32837. * @param camera defines the source camera
  32838. * @param size This parameter can be set to a single number or to an object with the
  32839. * following (optional) properties: precision, width, height. If a single number is passed,
  32840. * it will be used for both width and height. If an object is passed, the screenshot size
  32841. * will be derived from the parameters. The precision property is a multiplier allowing
  32842. * rendering at a higher or lower resolution
  32843. * @param successCallback defines the callback receives a single parameter which contains the
  32844. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32845. * src parameter of an <img> to display it
  32846. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32847. * Check your browser for supported MIME types
  32848. */
  32849. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32850. /**
  32851. * Captures a screenshot of the current rendering
  32852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32853. * @param engine defines the rendering engine
  32854. * @param camera defines the source camera
  32855. * @param size This parameter can be set to a single number or to an object with the
  32856. * following (optional) properties: precision, width, height. If a single number is passed,
  32857. * it will be used for both width and height. If an object is passed, the screenshot size
  32858. * will be derived from the parameters. The precision property is a multiplier allowing
  32859. * rendering at a higher or lower resolution
  32860. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32861. * Check your browser for supported MIME types
  32862. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32863. * to the src parameter of an <img> to display it
  32864. */
  32865. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32866. /**
  32867. * Generates an image screenshot from the specified camera.
  32868. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32869. * @param engine The engine to use for rendering
  32870. * @param camera The camera to use for rendering
  32871. * @param size This parameter can be set to a single number or to an object with the
  32872. * following (optional) properties: precision, width, height. If a single number is passed,
  32873. * it will be used for both width and height. If an object is passed, the screenshot size
  32874. * will be derived from the parameters. The precision property is a multiplier allowing
  32875. * rendering at a higher or lower resolution
  32876. * @param successCallback The callback receives a single parameter which contains the
  32877. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32878. * src parameter of an <img> to display it
  32879. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32880. * Check your browser for supported MIME types
  32881. * @param samples Texture samples (default: 1)
  32882. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32883. * @param fileName A name for for the downloaded file.
  32884. */
  32885. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32886. /**
  32887. * Generates an image screenshot from the specified camera.
  32888. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32889. * @param engine The engine to use for rendering
  32890. * @param camera The camera to use for rendering
  32891. * @param size This parameter can be set to a single number or to an object with the
  32892. * following (optional) properties: precision, width, height. If a single number is passed,
  32893. * it will be used for both width and height. If an object is passed, the screenshot size
  32894. * will be derived from the parameters. The precision property is a multiplier allowing
  32895. * rendering at a higher or lower resolution
  32896. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32897. * Check your browser for supported MIME types
  32898. * @param samples Texture samples (default: 1)
  32899. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32900. * @param fileName A name for for the downloaded file.
  32901. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32902. * to the src parameter of an <img> to display it
  32903. */
  32904. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32905. /**
  32906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32907. * Be aware Math.random() could cause collisions, but:
  32908. * "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"
  32909. * @returns a pseudo random id
  32910. */
  32911. static RandomId(): string;
  32912. /**
  32913. * Test if the given uri is a base64 string
  32914. * @param uri The uri to test
  32915. * @return True if the uri is a base64 string or false otherwise
  32916. */
  32917. static IsBase64(uri: string): boolean;
  32918. /**
  32919. * Decode the given base64 uri.
  32920. * @param uri The uri to decode
  32921. * @return The decoded base64 data.
  32922. */
  32923. static DecodeBase64(uri: string): ArrayBuffer;
  32924. /**
  32925. * Gets the absolute url.
  32926. * @param url the input url
  32927. * @return the absolute url
  32928. */
  32929. static GetAbsoluteUrl(url: string): string;
  32930. /**
  32931. * No log
  32932. */
  32933. static readonly NoneLogLevel: number;
  32934. /**
  32935. * Only message logs
  32936. */
  32937. static readonly MessageLogLevel: number;
  32938. /**
  32939. * Only warning logs
  32940. */
  32941. static readonly WarningLogLevel: number;
  32942. /**
  32943. * Only error logs
  32944. */
  32945. static readonly ErrorLogLevel: number;
  32946. /**
  32947. * All logs
  32948. */
  32949. static readonly AllLogLevel: number;
  32950. /**
  32951. * Gets a value indicating the number of loading errors
  32952. * @ignorenaming
  32953. */
  32954. static readonly errorsCount: number;
  32955. /**
  32956. * Callback called when a new log is added
  32957. */
  32958. static OnNewCacheEntry: (entry: string) => void;
  32959. /**
  32960. * Log a message to the console
  32961. * @param message defines the message to log
  32962. */
  32963. static Log(message: string): void;
  32964. /**
  32965. * Write a warning message to the console
  32966. * @param message defines the message to log
  32967. */
  32968. static Warn(message: string): void;
  32969. /**
  32970. * Write an error message to the console
  32971. * @param message defines the message to log
  32972. */
  32973. static Error(message: string): void;
  32974. /**
  32975. * Gets current log cache (list of logs)
  32976. */
  32977. static readonly LogCache: string;
  32978. /**
  32979. * Clears the log cache
  32980. */
  32981. static ClearLogCache(): void;
  32982. /**
  32983. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32984. */
  32985. static LogLevels: number;
  32986. /**
  32987. * Checks if the window object exists
  32988. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32989. */
  32990. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32991. /**
  32992. * No performance log
  32993. */
  32994. static readonly PerformanceNoneLogLevel: number;
  32995. /**
  32996. * Use user marks to log performance
  32997. */
  32998. static readonly PerformanceUserMarkLogLevel: number;
  32999. /**
  33000. * Log performance to the console
  33001. */
  33002. static readonly PerformanceConsoleLogLevel: number;
  33003. private static _performance;
  33004. /**
  33005. * Sets the current performance log level
  33006. */
  33007. static PerformanceLogLevel: number;
  33008. private static _StartPerformanceCounterDisabled;
  33009. private static _EndPerformanceCounterDisabled;
  33010. private static _StartUserMark;
  33011. private static _EndUserMark;
  33012. private static _StartPerformanceConsole;
  33013. private static _EndPerformanceConsole;
  33014. /**
  33015. * Starts a performance counter
  33016. */
  33017. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33018. /**
  33019. * Ends a specific performance coutner
  33020. */
  33021. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33022. /**
  33023. * Gets either window.performance.now() if supported or Date.now() else
  33024. */
  33025. static readonly Now: number;
  33026. /**
  33027. * This method will return the name of the class used to create the instance of the given object.
  33028. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33029. * @param object the object to get the class name from
  33030. * @param isType defines if the object is actually a type
  33031. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33032. */
  33033. static GetClassName(object: any, isType?: boolean): string;
  33034. /**
  33035. * Gets the first element of an array satisfying a given predicate
  33036. * @param array defines the array to browse
  33037. * @param predicate defines the predicate to use
  33038. * @returns null if not found or the element
  33039. */
  33040. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33041. /**
  33042. * This method will return the name of the full name of the class, including its owning module (if any).
  33043. * 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).
  33044. * @param object the object to get the class name from
  33045. * @param isType defines if the object is actually a type
  33046. * @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.
  33047. * @ignorenaming
  33048. */
  33049. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33050. /**
  33051. * Returns a promise that resolves after the given amount of time.
  33052. * @param delay Number of milliseconds to delay
  33053. * @returns Promise that resolves after the given amount of time
  33054. */
  33055. static DelayAsync(delay: number): Promise<void>;
  33056. }
  33057. /**
  33058. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33059. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33060. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33061. * @param name The name of the class, case should be preserved
  33062. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33063. */
  33064. export function className(name: string, module?: string): (target: Object) => void;
  33065. /**
  33066. * An implementation of a loop for asynchronous functions.
  33067. */
  33068. export class AsyncLoop {
  33069. /**
  33070. * Defines the number of iterations for the loop
  33071. */
  33072. iterations: number;
  33073. /**
  33074. * Defines the current index of the loop.
  33075. */
  33076. index: number;
  33077. private _done;
  33078. private _fn;
  33079. private _successCallback;
  33080. /**
  33081. * Constructor.
  33082. * @param iterations the number of iterations.
  33083. * @param func the function to run each iteration
  33084. * @param successCallback the callback that will be called upon succesful execution
  33085. * @param offset starting offset.
  33086. */
  33087. constructor(
  33088. /**
  33089. * Defines the number of iterations for the loop
  33090. */
  33091. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33092. /**
  33093. * Execute the next iteration. Must be called after the last iteration was finished.
  33094. */
  33095. executeNext(): void;
  33096. /**
  33097. * Break the loop and run the success callback.
  33098. */
  33099. breakLoop(): void;
  33100. /**
  33101. * Create and run an async loop.
  33102. * @param iterations the number of iterations.
  33103. * @param fn the function to run each iteration
  33104. * @param successCallback the callback that will be called upon succesful execution
  33105. * @param offset starting offset.
  33106. * @returns the created async loop object
  33107. */
  33108. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33109. /**
  33110. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33111. * @param iterations total number of iterations
  33112. * @param syncedIterations number of synchronous iterations in each async iteration.
  33113. * @param fn the function to call each iteration.
  33114. * @param callback a success call back that will be called when iterating stops.
  33115. * @param breakFunction a break condition (optional)
  33116. * @param timeout timeout settings for the setTimeout function. default - 0.
  33117. * @returns the created async loop object
  33118. */
  33119. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33120. }
  33121. }
  33122. declare module "babylonjs/Collisions/collisionCoordinator" {
  33123. import { Nullable } from "babylonjs/types";
  33124. import { Scene } from "babylonjs/scene";
  33125. import { Vector3 } from "babylonjs/Maths/math.vector";
  33126. import { Collider } from "babylonjs/Collisions/collider";
  33127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33128. /** @hidden */
  33129. export interface ICollisionCoordinator {
  33130. createCollider(): Collider;
  33131. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33132. init(scene: Scene): void;
  33133. }
  33134. /** @hidden */
  33135. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33136. private _scene;
  33137. private _scaledPosition;
  33138. private _scaledVelocity;
  33139. private _finalPosition;
  33140. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33141. createCollider(): Collider;
  33142. init(scene: Scene): void;
  33143. private _collideWithWorld;
  33144. }
  33145. }
  33146. declare module "babylonjs/Inputs/scene.inputManager" {
  33147. import { Nullable } from "babylonjs/types";
  33148. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33149. import { Vector2 } from "babylonjs/Maths/math.vector";
  33150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33151. import { Scene } from "babylonjs/scene";
  33152. /**
  33153. * Class used to manage all inputs for the scene.
  33154. */
  33155. export class InputManager {
  33156. /** The distance in pixel that you have to move to prevent some events */
  33157. static DragMovementThreshold: number;
  33158. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33159. static LongPressDelay: number;
  33160. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33161. static DoubleClickDelay: number;
  33162. /** If you need to check double click without raising a single click at first click, enable this flag */
  33163. static ExclusiveDoubleClickMode: boolean;
  33164. private _wheelEventName;
  33165. private _onPointerMove;
  33166. private _onPointerDown;
  33167. private _onPointerUp;
  33168. private _initClickEvent;
  33169. private _initActionManager;
  33170. private _delayedSimpleClick;
  33171. private _delayedSimpleClickTimeout;
  33172. private _previousDelayedSimpleClickTimeout;
  33173. private _meshPickProceed;
  33174. private _previousButtonPressed;
  33175. private _currentPickResult;
  33176. private _previousPickResult;
  33177. private _totalPointersPressed;
  33178. private _doubleClickOccured;
  33179. private _pointerOverMesh;
  33180. private _pickedDownMesh;
  33181. private _pickedUpMesh;
  33182. private _pointerX;
  33183. private _pointerY;
  33184. private _unTranslatedPointerX;
  33185. private _unTranslatedPointerY;
  33186. private _startingPointerPosition;
  33187. private _previousStartingPointerPosition;
  33188. private _startingPointerTime;
  33189. private _previousStartingPointerTime;
  33190. private _pointerCaptures;
  33191. private _onKeyDown;
  33192. private _onKeyUp;
  33193. private _onCanvasFocusObserver;
  33194. private _onCanvasBlurObserver;
  33195. private _scene;
  33196. /**
  33197. * Creates a new InputManager
  33198. * @param scene defines the hosting scene
  33199. */
  33200. constructor(scene: Scene);
  33201. /**
  33202. * Gets the mesh that is currently under the pointer
  33203. */
  33204. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33205. /**
  33206. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33207. */
  33208. readonly unTranslatedPointer: Vector2;
  33209. /**
  33210. * Gets or sets the current on-screen X position of the pointer
  33211. */
  33212. pointerX: number;
  33213. /**
  33214. * Gets or sets the current on-screen Y position of the pointer
  33215. */
  33216. pointerY: number;
  33217. private _updatePointerPosition;
  33218. private _processPointerMove;
  33219. private _setRayOnPointerInfo;
  33220. private _checkPrePointerObservable;
  33221. /**
  33222. * Use this method to simulate a pointer move on a mesh
  33223. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33224. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33225. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33226. */
  33227. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33228. /**
  33229. * Use this method to simulate a pointer down on a mesh
  33230. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33231. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33232. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33233. */
  33234. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33235. private _processPointerDown;
  33236. /** @hidden */
  33237. _isPointerSwiping(): boolean;
  33238. /**
  33239. * Use this method to simulate a pointer up on a mesh
  33240. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33241. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33242. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33243. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33244. */
  33245. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33246. private _processPointerUp;
  33247. /**
  33248. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33249. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33250. * @returns true if the pointer was captured
  33251. */
  33252. isPointerCaptured(pointerId?: number): boolean;
  33253. /**
  33254. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33255. * @param attachUp defines if you want to attach events to pointerup
  33256. * @param attachDown defines if you want to attach events to pointerdown
  33257. * @param attachMove defines if you want to attach events to pointermove
  33258. */
  33259. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33260. /**
  33261. * Detaches all event handlers
  33262. */
  33263. detachControl(): void;
  33264. /**
  33265. * Force the value of meshUnderPointer
  33266. * @param mesh defines the mesh to use
  33267. */
  33268. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33269. /**
  33270. * Gets the mesh under the pointer
  33271. * @returns a Mesh or null if no mesh is under the pointer
  33272. */
  33273. getPointerOverMesh(): Nullable<AbstractMesh>;
  33274. }
  33275. }
  33276. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33277. /**
  33278. * Helper class used to generate session unique ID
  33279. */
  33280. export class UniqueIdGenerator {
  33281. private static _UniqueIdCounter;
  33282. /**
  33283. * Gets an unique (relatively to the current scene) Id
  33284. */
  33285. static readonly UniqueId: number;
  33286. }
  33287. }
  33288. declare module "babylonjs/Animations/animationGroup" {
  33289. import { Animatable } from "babylonjs/Animations/animatable";
  33290. import { Animation } from "babylonjs/Animations/animation";
  33291. import { Scene, IDisposable } from "babylonjs/scene";
  33292. import { Observable } from "babylonjs/Misc/observable";
  33293. import { Nullable } from "babylonjs/types";
  33294. import "babylonjs/Animations/animatable";
  33295. /**
  33296. * This class defines the direct association between an animation and a target
  33297. */
  33298. export class TargetedAnimation {
  33299. /**
  33300. * Animation to perform
  33301. */
  33302. animation: Animation;
  33303. /**
  33304. * Target to animate
  33305. */
  33306. target: any;
  33307. /**
  33308. * Serialize the object
  33309. * @returns the JSON object representing the current entity
  33310. */
  33311. serialize(): any;
  33312. }
  33313. /**
  33314. * Use this class to create coordinated animations on multiple targets
  33315. */
  33316. export class AnimationGroup implements IDisposable {
  33317. /** The name of the animation group */
  33318. name: string;
  33319. private _scene;
  33320. private _targetedAnimations;
  33321. private _animatables;
  33322. private _from;
  33323. private _to;
  33324. private _isStarted;
  33325. private _isPaused;
  33326. private _speedRatio;
  33327. private _loopAnimation;
  33328. /**
  33329. * Gets or sets the unique id of the node
  33330. */
  33331. uniqueId: number;
  33332. /**
  33333. * This observable will notify when one animation have ended
  33334. */
  33335. onAnimationEndObservable: Observable<TargetedAnimation>;
  33336. /**
  33337. * Observer raised when one animation loops
  33338. */
  33339. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33340. /**
  33341. * This observable will notify when all animations have ended.
  33342. */
  33343. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33344. /**
  33345. * This observable will notify when all animations have paused.
  33346. */
  33347. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33348. /**
  33349. * This observable will notify when all animations are playing.
  33350. */
  33351. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33352. /**
  33353. * Gets the first frame
  33354. */
  33355. readonly from: number;
  33356. /**
  33357. * Gets the last frame
  33358. */
  33359. readonly to: number;
  33360. /**
  33361. * Define if the animations are started
  33362. */
  33363. readonly isStarted: boolean;
  33364. /**
  33365. * Gets a value indicating that the current group is playing
  33366. */
  33367. readonly isPlaying: boolean;
  33368. /**
  33369. * Gets or sets the speed ratio to use for all animations
  33370. */
  33371. /**
  33372. * Gets or sets the speed ratio to use for all animations
  33373. */
  33374. speedRatio: number;
  33375. /**
  33376. * Gets or sets if all animations should loop or not
  33377. */
  33378. loopAnimation: boolean;
  33379. /**
  33380. * Gets the targeted animations for this animation group
  33381. */
  33382. readonly targetedAnimations: Array<TargetedAnimation>;
  33383. /**
  33384. * returning the list of animatables controlled by this animation group.
  33385. */
  33386. readonly animatables: Array<Animatable>;
  33387. /**
  33388. * Instantiates a new Animation Group.
  33389. * This helps managing several animations at once.
  33390. * @see http://doc.babylonjs.com/how_to/group
  33391. * @param name Defines the name of the group
  33392. * @param scene Defines the scene the group belongs to
  33393. */
  33394. constructor(
  33395. /** The name of the animation group */
  33396. name: string, scene?: Nullable<Scene>);
  33397. /**
  33398. * Add an animation (with its target) in the group
  33399. * @param animation defines the animation we want to add
  33400. * @param target defines the target of the animation
  33401. * @returns the TargetedAnimation object
  33402. */
  33403. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33404. /**
  33405. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33406. * It can add constant keys at begin or end
  33407. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33408. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33409. * @returns the animation group
  33410. */
  33411. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33412. /**
  33413. * Start all animations on given targets
  33414. * @param loop defines if animations must loop
  33415. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33416. * @param from defines the from key (optional)
  33417. * @param to defines the to key (optional)
  33418. * @returns the current animation group
  33419. */
  33420. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33421. /**
  33422. * Pause all animations
  33423. * @returns the animation group
  33424. */
  33425. pause(): AnimationGroup;
  33426. /**
  33427. * Play all animations to initial state
  33428. * This function will start() the animations if they were not started or will restart() them if they were paused
  33429. * @param loop defines if animations must loop
  33430. * @returns the animation group
  33431. */
  33432. play(loop?: boolean): AnimationGroup;
  33433. /**
  33434. * Reset all animations to initial state
  33435. * @returns the animation group
  33436. */
  33437. reset(): AnimationGroup;
  33438. /**
  33439. * Restart animations from key 0
  33440. * @returns the animation group
  33441. */
  33442. restart(): AnimationGroup;
  33443. /**
  33444. * Stop all animations
  33445. * @returns the animation group
  33446. */
  33447. stop(): AnimationGroup;
  33448. /**
  33449. * Set animation weight for all animatables
  33450. * @param weight defines the weight to use
  33451. * @return the animationGroup
  33452. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33453. */
  33454. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33455. /**
  33456. * Synchronize and normalize all animatables with a source animatable
  33457. * @param root defines the root animatable to synchronize with
  33458. * @return the animationGroup
  33459. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33460. */
  33461. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33462. /**
  33463. * Goes to a specific frame in this animation group
  33464. * @param frame the frame number to go to
  33465. * @return the animationGroup
  33466. */
  33467. goToFrame(frame: number): AnimationGroup;
  33468. /**
  33469. * Dispose all associated resources
  33470. */
  33471. dispose(): void;
  33472. private _checkAnimationGroupEnded;
  33473. /**
  33474. * Clone the current animation group and returns a copy
  33475. * @param newName defines the name of the new group
  33476. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33477. * @returns the new aniamtion group
  33478. */
  33479. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33480. /**
  33481. * Serializes the animationGroup to an object
  33482. * @returns Serialized object
  33483. */
  33484. serialize(): any;
  33485. /**
  33486. * Returns a new AnimationGroup object parsed from the source provided.
  33487. * @param parsedAnimationGroup defines the source
  33488. * @param scene defines the scene that will receive the animationGroup
  33489. * @returns a new AnimationGroup
  33490. */
  33491. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33492. /**
  33493. * Returns the string "AnimationGroup"
  33494. * @returns "AnimationGroup"
  33495. */
  33496. getClassName(): string;
  33497. /**
  33498. * Creates a detailled string about the object
  33499. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33500. * @returns a string representing the object
  33501. */
  33502. toString(fullDetails?: boolean): string;
  33503. }
  33504. }
  33505. declare module "babylonjs/scene" {
  33506. import { Nullable } from "babylonjs/types";
  33507. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33508. import { Observable } from "babylonjs/Misc/observable";
  33509. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33510. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33511. import { Geometry } from "babylonjs/Meshes/geometry";
  33512. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33515. import { Mesh } from "babylonjs/Meshes/mesh";
  33516. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33517. import { Bone } from "babylonjs/Bones/bone";
  33518. import { Skeleton } from "babylonjs/Bones/skeleton";
  33519. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33520. import { Camera } from "babylonjs/Cameras/camera";
  33521. import { AbstractScene } from "babylonjs/abstractScene";
  33522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33523. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33524. import { Material } from "babylonjs/Materials/material";
  33525. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33526. import { Effect } from "babylonjs/Materials/effect";
  33527. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33528. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33529. import { Light } from "babylonjs/Lights/light";
  33530. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33531. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33532. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33533. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33535. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33536. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33537. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33538. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33539. import { Engine } from "babylonjs/Engines/engine";
  33540. import { Node } from "babylonjs/node";
  33541. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33542. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33543. import { WebRequest } from "babylonjs/Misc/webRequest";
  33544. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33545. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33546. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33548. import { Plane } from "babylonjs/Maths/math.plane";
  33549. import { Ray } from "babylonjs/Culling/ray";
  33550. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33551. import { Animation } from "babylonjs/Animations/animation";
  33552. import { Animatable } from "babylonjs/Animations/animatable";
  33553. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33554. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33555. import { Collider } from "babylonjs/Collisions/collider";
  33556. /**
  33557. * Define an interface for all classes that will hold resources
  33558. */
  33559. export interface IDisposable {
  33560. /**
  33561. * Releases all held resources
  33562. */
  33563. dispose(): void;
  33564. }
  33565. /** Interface defining initialization parameters for Scene class */
  33566. export interface SceneOptions {
  33567. /**
  33568. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33569. * It will improve performance when the number of geometries becomes important.
  33570. */
  33571. useGeometryUniqueIdsMap?: boolean;
  33572. /**
  33573. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33574. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33575. */
  33576. useMaterialMeshMap?: boolean;
  33577. /**
  33578. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33579. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33580. */
  33581. useClonedMeshhMap?: boolean;
  33582. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33583. virtual?: boolean;
  33584. }
  33585. /**
  33586. * Represents a scene to be rendered by the engine.
  33587. * @see http://doc.babylonjs.com/features/scene
  33588. */
  33589. export class Scene extends AbstractScene implements IAnimatable {
  33590. /** The fog is deactivated */
  33591. static readonly FOGMODE_NONE: number;
  33592. /** The fog density is following an exponential function */
  33593. static readonly FOGMODE_EXP: number;
  33594. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33595. static readonly FOGMODE_EXP2: number;
  33596. /** The fog density is following a linear function. */
  33597. static readonly FOGMODE_LINEAR: number;
  33598. /**
  33599. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33600. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33601. */
  33602. static MinDeltaTime: number;
  33603. /**
  33604. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33606. */
  33607. static MaxDeltaTime: number;
  33608. /**
  33609. * Factory used to create the default material.
  33610. * @param name The name of the material to create
  33611. * @param scene The scene to create the material for
  33612. * @returns The default material
  33613. */
  33614. static DefaultMaterialFactory(scene: Scene): Material;
  33615. /**
  33616. * Factory used to create the a collision coordinator.
  33617. * @returns The collision coordinator
  33618. */
  33619. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33620. /** @hidden */
  33621. _inputManager: InputManager;
  33622. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33623. cameraToUseForPointers: Nullable<Camera>;
  33624. /** @hidden */
  33625. readonly _isScene: boolean;
  33626. /**
  33627. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33628. */
  33629. autoClear: boolean;
  33630. /**
  33631. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33632. */
  33633. autoClearDepthAndStencil: boolean;
  33634. /**
  33635. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33636. */
  33637. clearColor: Color4;
  33638. /**
  33639. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33640. */
  33641. ambientColor: Color3;
  33642. /**
  33643. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33644. * It should only be one of the following (if not the default embedded one):
  33645. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33646. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33647. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33648. * The material properties need to be setup according to the type of texture in use.
  33649. */
  33650. environmentBRDFTexture: BaseTexture;
  33651. /** @hidden */
  33652. protected _environmentTexture: Nullable<BaseTexture>;
  33653. /**
  33654. * Texture used in all pbr material as the reflection texture.
  33655. * As in the majority of the scene they are the same (exception for multi room and so on),
  33656. * this is easier to reference from here than from all the materials.
  33657. */
  33658. /**
  33659. * Texture used in all pbr material as the reflection texture.
  33660. * As in the majority of the scene they are the same (exception for multi room and so on),
  33661. * this is easier to set here than in all the materials.
  33662. */
  33663. environmentTexture: Nullable<BaseTexture>;
  33664. /** @hidden */
  33665. protected _environmentIntensity: number;
  33666. /**
  33667. * Intensity of the environment in all pbr material.
  33668. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33669. * As in the majority of the scene they are the same (exception for multi room and so on),
  33670. * this is easier to reference from here than from all the materials.
  33671. */
  33672. /**
  33673. * Intensity of the environment in all pbr material.
  33674. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33675. * As in the majority of the scene they are the same (exception for multi room and so on),
  33676. * this is easier to set here than in all the materials.
  33677. */
  33678. environmentIntensity: number;
  33679. /** @hidden */
  33680. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33681. /**
  33682. * Default image processing configuration used either in the rendering
  33683. * Forward main pass or through the imageProcessingPostProcess if present.
  33684. * As in the majority of the scene they are the same (exception for multi camera),
  33685. * this is easier to reference from here than from all the materials and post process.
  33686. *
  33687. * No setter as we it is a shared configuration, you can set the values instead.
  33688. */
  33689. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33690. private _forceWireframe;
  33691. /**
  33692. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33693. */
  33694. forceWireframe: boolean;
  33695. private _forcePointsCloud;
  33696. /**
  33697. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33698. */
  33699. forcePointsCloud: boolean;
  33700. /**
  33701. * Gets or sets the active clipplane 1
  33702. */
  33703. clipPlane: Nullable<Plane>;
  33704. /**
  33705. * Gets or sets the active clipplane 2
  33706. */
  33707. clipPlane2: Nullable<Plane>;
  33708. /**
  33709. * Gets or sets the active clipplane 3
  33710. */
  33711. clipPlane3: Nullable<Plane>;
  33712. /**
  33713. * Gets or sets the active clipplane 4
  33714. */
  33715. clipPlane4: Nullable<Plane>;
  33716. /**
  33717. * Gets or sets a boolean indicating if animations are enabled
  33718. */
  33719. animationsEnabled: boolean;
  33720. private _animationPropertiesOverride;
  33721. /**
  33722. * Gets or sets the animation properties override
  33723. */
  33724. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33725. /**
  33726. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33727. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33728. */
  33729. useConstantAnimationDeltaTime: boolean;
  33730. /**
  33731. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33732. * Please note that it requires to run a ray cast through the scene on every frame
  33733. */
  33734. constantlyUpdateMeshUnderPointer: boolean;
  33735. /**
  33736. * Defines the HTML cursor to use when hovering over interactive elements
  33737. */
  33738. hoverCursor: string;
  33739. /**
  33740. * Defines the HTML default cursor to use (empty by default)
  33741. */
  33742. defaultCursor: string;
  33743. /**
  33744. * This is used to call preventDefault() on pointer down
  33745. * in order to block unwanted artifacts like system double clicks
  33746. */
  33747. preventDefaultOnPointerDown: boolean;
  33748. /**
  33749. * This is used to call preventDefault() on pointer up
  33750. * in order to block unwanted artifacts like system double clicks
  33751. */
  33752. preventDefaultOnPointerUp: boolean;
  33753. /**
  33754. * Gets or sets user defined metadata
  33755. */
  33756. metadata: any;
  33757. /**
  33758. * For internal use only. Please do not use.
  33759. */
  33760. reservedDataStore: any;
  33761. /**
  33762. * Gets the name of the plugin used to load this scene (null by default)
  33763. */
  33764. loadingPluginName: string;
  33765. /**
  33766. * Use this array to add regular expressions used to disable offline support for specific urls
  33767. */
  33768. disableOfflineSupportExceptionRules: RegExp[];
  33769. /**
  33770. * An event triggered when the scene is disposed.
  33771. */
  33772. onDisposeObservable: Observable<Scene>;
  33773. private _onDisposeObserver;
  33774. /** Sets a function to be executed when this scene is disposed. */
  33775. onDispose: () => void;
  33776. /**
  33777. * An event triggered before rendering the scene (right after animations and physics)
  33778. */
  33779. onBeforeRenderObservable: Observable<Scene>;
  33780. private _onBeforeRenderObserver;
  33781. /** Sets a function to be executed before rendering this scene */
  33782. beforeRender: Nullable<() => void>;
  33783. /**
  33784. * An event triggered after rendering the scene
  33785. */
  33786. onAfterRenderObservable: Observable<Scene>;
  33787. /**
  33788. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33789. */
  33790. onAfterRenderCameraObservable: Observable<Camera>;
  33791. private _onAfterRenderObserver;
  33792. /** Sets a function to be executed after rendering this scene */
  33793. afterRender: Nullable<() => void>;
  33794. /**
  33795. * An event triggered before animating the scene
  33796. */
  33797. onBeforeAnimationsObservable: Observable<Scene>;
  33798. /**
  33799. * An event triggered after animations processing
  33800. */
  33801. onAfterAnimationsObservable: Observable<Scene>;
  33802. /**
  33803. * An event triggered before draw calls are ready to be sent
  33804. */
  33805. onBeforeDrawPhaseObservable: Observable<Scene>;
  33806. /**
  33807. * An event triggered after draw calls have been sent
  33808. */
  33809. onAfterDrawPhaseObservable: Observable<Scene>;
  33810. /**
  33811. * An event triggered when the scene is ready
  33812. */
  33813. onReadyObservable: Observable<Scene>;
  33814. /**
  33815. * An event triggered before rendering a camera
  33816. */
  33817. onBeforeCameraRenderObservable: Observable<Camera>;
  33818. private _onBeforeCameraRenderObserver;
  33819. /** Sets a function to be executed before rendering a camera*/
  33820. beforeCameraRender: () => void;
  33821. /**
  33822. * An event triggered after rendering a camera
  33823. */
  33824. onAfterCameraRenderObservable: Observable<Camera>;
  33825. private _onAfterCameraRenderObserver;
  33826. /** Sets a function to be executed after rendering a camera*/
  33827. afterCameraRender: () => void;
  33828. /**
  33829. * An event triggered when active meshes evaluation is about to start
  33830. */
  33831. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33832. /**
  33833. * An event triggered when active meshes evaluation is done
  33834. */
  33835. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33836. /**
  33837. * An event triggered when particles rendering is about to start
  33838. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33839. */
  33840. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33841. /**
  33842. * An event triggered when particles rendering is done
  33843. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33844. */
  33845. onAfterParticlesRenderingObservable: Observable<Scene>;
  33846. /**
  33847. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33848. */
  33849. onDataLoadedObservable: Observable<Scene>;
  33850. /**
  33851. * An event triggered when a camera is created
  33852. */
  33853. onNewCameraAddedObservable: Observable<Camera>;
  33854. /**
  33855. * An event triggered when a camera is removed
  33856. */
  33857. onCameraRemovedObservable: Observable<Camera>;
  33858. /**
  33859. * An event triggered when a light is created
  33860. */
  33861. onNewLightAddedObservable: Observable<Light>;
  33862. /**
  33863. * An event triggered when a light is removed
  33864. */
  33865. onLightRemovedObservable: Observable<Light>;
  33866. /**
  33867. * An event triggered when a geometry is created
  33868. */
  33869. onNewGeometryAddedObservable: Observable<Geometry>;
  33870. /**
  33871. * An event triggered when a geometry is removed
  33872. */
  33873. onGeometryRemovedObservable: Observable<Geometry>;
  33874. /**
  33875. * An event triggered when a transform node is created
  33876. */
  33877. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33878. /**
  33879. * An event triggered when a transform node is removed
  33880. */
  33881. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33882. /**
  33883. * An event triggered when a mesh is created
  33884. */
  33885. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33886. /**
  33887. * An event triggered when a mesh is removed
  33888. */
  33889. onMeshRemovedObservable: Observable<AbstractMesh>;
  33890. /**
  33891. * An event triggered when a skeleton is created
  33892. */
  33893. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33894. /**
  33895. * An event triggered when a skeleton is removed
  33896. */
  33897. onSkeletonRemovedObservable: Observable<Skeleton>;
  33898. /**
  33899. * An event triggered when a material is created
  33900. */
  33901. onNewMaterialAddedObservable: Observable<Material>;
  33902. /**
  33903. * An event triggered when a material is removed
  33904. */
  33905. onMaterialRemovedObservable: Observable<Material>;
  33906. /**
  33907. * An event triggered when a texture is created
  33908. */
  33909. onNewTextureAddedObservable: Observable<BaseTexture>;
  33910. /**
  33911. * An event triggered when a texture is removed
  33912. */
  33913. onTextureRemovedObservable: Observable<BaseTexture>;
  33914. /**
  33915. * An event triggered when render targets are about to be rendered
  33916. * Can happen multiple times per frame.
  33917. */
  33918. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33919. /**
  33920. * An event triggered when render targets were rendered.
  33921. * Can happen multiple times per frame.
  33922. */
  33923. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33924. /**
  33925. * An event triggered before calculating deterministic simulation step
  33926. */
  33927. onBeforeStepObservable: Observable<Scene>;
  33928. /**
  33929. * An event triggered after calculating deterministic simulation step
  33930. */
  33931. onAfterStepObservable: Observable<Scene>;
  33932. /**
  33933. * An event triggered when the activeCamera property is updated
  33934. */
  33935. onActiveCameraChanged: Observable<Scene>;
  33936. /**
  33937. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33938. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33939. * 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)
  33940. */
  33941. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33942. /**
  33943. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33944. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33945. * 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)
  33946. */
  33947. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33948. /**
  33949. * This Observable will when a mesh has been imported into the scene.
  33950. */
  33951. onMeshImportedObservable: Observable<AbstractMesh>;
  33952. /**
  33953. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33954. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33955. */
  33956. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33957. /** @hidden */
  33958. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33959. /**
  33960. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33961. */
  33962. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33963. /**
  33964. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33965. */
  33966. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33967. /**
  33968. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33969. */
  33970. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33971. /** Callback called when a pointer move is detected */
  33972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33973. /** Callback called when a pointer down is detected */
  33974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33975. /** Callback called when a pointer up is detected */
  33976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33977. /** Callback called when a pointer pick is detected */
  33978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33979. /**
  33980. * 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).
  33981. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33982. */
  33983. onPrePointerObservable: Observable<PointerInfoPre>;
  33984. /**
  33985. * Observable event triggered each time an input event is received from the rendering canvas
  33986. */
  33987. onPointerObservable: Observable<PointerInfo>;
  33988. /**
  33989. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33990. */
  33991. readonly unTranslatedPointer: Vector2;
  33992. /**
  33993. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33994. */
  33995. static DragMovementThreshold: number;
  33996. /**
  33997. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33998. */
  33999. static LongPressDelay: number;
  34000. /**
  34001. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34002. */
  34003. static DoubleClickDelay: number;
  34004. /** If you need to check double click without raising a single click at first click, enable this flag */
  34005. static ExclusiveDoubleClickMode: boolean;
  34006. /** @hidden */
  34007. _mirroredCameraPosition: Nullable<Vector3>;
  34008. /**
  34009. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34010. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34011. */
  34012. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34013. /**
  34014. * Observable event triggered each time an keyboard event is received from the hosting window
  34015. */
  34016. onKeyboardObservable: Observable<KeyboardInfo>;
  34017. private _useRightHandedSystem;
  34018. /**
  34019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34020. */
  34021. useRightHandedSystem: boolean;
  34022. private _timeAccumulator;
  34023. private _currentStepId;
  34024. private _currentInternalStep;
  34025. /**
  34026. * Sets the step Id used by deterministic lock step
  34027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34028. * @param newStepId defines the step Id
  34029. */
  34030. setStepId(newStepId: number): void;
  34031. /**
  34032. * Gets the step Id used by deterministic lock step
  34033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34034. * @returns the step Id
  34035. */
  34036. getStepId(): number;
  34037. /**
  34038. * Gets the internal step used by deterministic lock step
  34039. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34040. * @returns the internal step
  34041. */
  34042. getInternalStep(): number;
  34043. private _fogEnabled;
  34044. /**
  34045. * Gets or sets a boolean indicating if fog is enabled on this scene
  34046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34047. * (Default is true)
  34048. */
  34049. fogEnabled: boolean;
  34050. private _fogMode;
  34051. /**
  34052. * Gets or sets the fog mode to use
  34053. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34054. * | mode | value |
  34055. * | --- | --- |
  34056. * | FOGMODE_NONE | 0 |
  34057. * | FOGMODE_EXP | 1 |
  34058. * | FOGMODE_EXP2 | 2 |
  34059. * | FOGMODE_LINEAR | 3 |
  34060. */
  34061. fogMode: number;
  34062. /**
  34063. * Gets or sets the fog color to use
  34064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34065. * (Default is Color3(0.2, 0.2, 0.3))
  34066. */
  34067. fogColor: Color3;
  34068. /**
  34069. * Gets or sets the fog density to use
  34070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34071. * (Default is 0.1)
  34072. */
  34073. fogDensity: number;
  34074. /**
  34075. * Gets or sets the fog start distance to use
  34076. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34077. * (Default is 0)
  34078. */
  34079. fogStart: number;
  34080. /**
  34081. * Gets or sets the fog end distance to use
  34082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34083. * (Default is 1000)
  34084. */
  34085. fogEnd: number;
  34086. private _shadowsEnabled;
  34087. /**
  34088. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34089. */
  34090. shadowsEnabled: boolean;
  34091. private _lightsEnabled;
  34092. /**
  34093. * Gets or sets a boolean indicating if lights are enabled on this scene
  34094. */
  34095. lightsEnabled: boolean;
  34096. /** All of the active cameras added to this scene. */
  34097. activeCameras: Camera[];
  34098. /** @hidden */
  34099. _activeCamera: Nullable<Camera>;
  34100. /** Gets or sets the current active camera */
  34101. activeCamera: Nullable<Camera>;
  34102. private _defaultMaterial;
  34103. /** The default material used on meshes when no material is affected */
  34104. /** The default material used on meshes when no material is affected */
  34105. defaultMaterial: Material;
  34106. private _texturesEnabled;
  34107. /**
  34108. * Gets or sets a boolean indicating if textures are enabled on this scene
  34109. */
  34110. texturesEnabled: boolean;
  34111. /**
  34112. * Gets or sets a boolean indicating if particles are enabled on this scene
  34113. */
  34114. particlesEnabled: boolean;
  34115. /**
  34116. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34117. */
  34118. spritesEnabled: boolean;
  34119. private _skeletonsEnabled;
  34120. /**
  34121. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34122. */
  34123. skeletonsEnabled: boolean;
  34124. /**
  34125. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34126. */
  34127. lensFlaresEnabled: boolean;
  34128. /**
  34129. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34131. */
  34132. collisionsEnabled: boolean;
  34133. private _collisionCoordinator;
  34134. /** @hidden */
  34135. readonly collisionCoordinator: ICollisionCoordinator;
  34136. /**
  34137. * Defines the gravity applied to this scene (used only for collisions)
  34138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34139. */
  34140. gravity: Vector3;
  34141. /**
  34142. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34143. */
  34144. postProcessesEnabled: boolean;
  34145. /**
  34146. * The list of postprocesses added to the scene
  34147. */
  34148. postProcesses: PostProcess[];
  34149. /**
  34150. * Gets the current postprocess manager
  34151. */
  34152. postProcessManager: PostProcessManager;
  34153. /**
  34154. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34155. */
  34156. renderTargetsEnabled: boolean;
  34157. /**
  34158. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34159. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34160. */
  34161. dumpNextRenderTargets: boolean;
  34162. /**
  34163. * The list of user defined render targets added to the scene
  34164. */
  34165. customRenderTargets: RenderTargetTexture[];
  34166. /**
  34167. * Defines if texture loading must be delayed
  34168. * If true, textures will only be loaded when they need to be rendered
  34169. */
  34170. useDelayedTextureLoading: boolean;
  34171. /**
  34172. * Gets the list of meshes imported to the scene through SceneLoader
  34173. */
  34174. importedMeshesFiles: String[];
  34175. /**
  34176. * Gets or sets a boolean indicating if probes are enabled on this scene
  34177. */
  34178. probesEnabled: boolean;
  34179. /**
  34180. * Gets or sets the current offline provider to use to store scene data
  34181. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34182. */
  34183. offlineProvider: IOfflineProvider;
  34184. /**
  34185. * Gets or sets the action manager associated with the scene
  34186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34187. */
  34188. actionManager: AbstractActionManager;
  34189. private _meshesForIntersections;
  34190. /**
  34191. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34192. */
  34193. proceduralTexturesEnabled: boolean;
  34194. private _engine;
  34195. private _totalVertices;
  34196. /** @hidden */
  34197. _activeIndices: PerfCounter;
  34198. /** @hidden */
  34199. _activeParticles: PerfCounter;
  34200. /** @hidden */
  34201. _activeBones: PerfCounter;
  34202. private _animationRatio;
  34203. /** @hidden */
  34204. _animationTimeLast: number;
  34205. /** @hidden */
  34206. _animationTime: number;
  34207. /**
  34208. * Gets or sets a general scale for animation speed
  34209. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34210. */
  34211. animationTimeScale: number;
  34212. /** @hidden */
  34213. _cachedMaterial: Nullable<Material>;
  34214. /** @hidden */
  34215. _cachedEffect: Nullable<Effect>;
  34216. /** @hidden */
  34217. _cachedVisibility: Nullable<number>;
  34218. private _renderId;
  34219. private _frameId;
  34220. private _executeWhenReadyTimeoutId;
  34221. private _intermediateRendering;
  34222. private _viewUpdateFlag;
  34223. private _projectionUpdateFlag;
  34224. /** @hidden */
  34225. _toBeDisposed: Nullable<IDisposable>[];
  34226. private _activeRequests;
  34227. /** @hidden */
  34228. _pendingData: any[];
  34229. private _isDisposed;
  34230. /**
  34231. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34232. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34233. */
  34234. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34235. private _activeMeshes;
  34236. private _processedMaterials;
  34237. private _renderTargets;
  34238. /** @hidden */
  34239. _activeParticleSystems: SmartArray<IParticleSystem>;
  34240. private _activeSkeletons;
  34241. private _softwareSkinnedMeshes;
  34242. private _renderingManager;
  34243. /** @hidden */
  34244. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34245. private _transformMatrix;
  34246. private _sceneUbo;
  34247. /** @hidden */
  34248. _viewMatrix: Matrix;
  34249. private _projectionMatrix;
  34250. /** @hidden */
  34251. _forcedViewPosition: Nullable<Vector3>;
  34252. /** @hidden */
  34253. _frustumPlanes: Plane[];
  34254. /**
  34255. * Gets the list of frustum planes (built from the active camera)
  34256. */
  34257. readonly frustumPlanes: Plane[];
  34258. /**
  34259. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34260. * This is useful if there are more lights that the maximum simulteanous authorized
  34261. */
  34262. requireLightSorting: boolean;
  34263. /** @hidden */
  34264. readonly useMaterialMeshMap: boolean;
  34265. /** @hidden */
  34266. readonly useClonedMeshhMap: boolean;
  34267. private _externalData;
  34268. private _uid;
  34269. /**
  34270. * @hidden
  34271. * Backing store of defined scene components.
  34272. */
  34273. _components: ISceneComponent[];
  34274. /**
  34275. * @hidden
  34276. * Backing store of defined scene components.
  34277. */
  34278. _serializableComponents: ISceneSerializableComponent[];
  34279. /**
  34280. * List of components to register on the next registration step.
  34281. */
  34282. private _transientComponents;
  34283. /**
  34284. * Registers the transient components if needed.
  34285. */
  34286. private _registerTransientComponents;
  34287. /**
  34288. * @hidden
  34289. * Add a component to the scene.
  34290. * Note that the ccomponent could be registered on th next frame if this is called after
  34291. * the register component stage.
  34292. * @param component Defines the component to add to the scene
  34293. */
  34294. _addComponent(component: ISceneComponent): void;
  34295. /**
  34296. * @hidden
  34297. * Gets a component from the scene.
  34298. * @param name defines the name of the component to retrieve
  34299. * @returns the component or null if not present
  34300. */
  34301. _getComponent(name: string): Nullable<ISceneComponent>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening before camera updates.
  34305. */
  34306. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening before clear the canvas.
  34310. */
  34311. _beforeClearStage: Stage<SimpleStageAction>;
  34312. /**
  34313. * @hidden
  34314. * Defines the actions when collecting render targets for the frame.
  34315. */
  34316. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34317. /**
  34318. * @hidden
  34319. * Defines the actions happening for one camera in the frame.
  34320. */
  34321. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34322. /**
  34323. * @hidden
  34324. * Defines the actions happening during the per mesh ready checks.
  34325. */
  34326. _isReadyForMeshStage: Stage<MeshStageAction>;
  34327. /**
  34328. * @hidden
  34329. * Defines the actions happening before evaluate active mesh checks.
  34330. */
  34331. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34332. /**
  34333. * @hidden
  34334. * Defines the actions happening during the evaluate sub mesh checks.
  34335. */
  34336. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34337. /**
  34338. * @hidden
  34339. * Defines the actions happening during the active mesh stage.
  34340. */
  34341. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34342. /**
  34343. * @hidden
  34344. * Defines the actions happening during the per camera render target step.
  34345. */
  34346. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34347. /**
  34348. * @hidden
  34349. * Defines the actions happening just before the active camera is drawing.
  34350. */
  34351. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34352. /**
  34353. * @hidden
  34354. * Defines the actions happening just before a render target is drawing.
  34355. */
  34356. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34357. /**
  34358. * @hidden
  34359. * Defines the actions happening just before a rendering group is drawing.
  34360. */
  34361. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34362. /**
  34363. * @hidden
  34364. * Defines the actions happening just before a mesh is drawing.
  34365. */
  34366. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34367. /**
  34368. * @hidden
  34369. * Defines the actions happening just after a mesh has been drawn.
  34370. */
  34371. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34372. /**
  34373. * @hidden
  34374. * Defines the actions happening just after a rendering group has been drawn.
  34375. */
  34376. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34377. /**
  34378. * @hidden
  34379. * Defines the actions happening just after the active camera has been drawn.
  34380. */
  34381. _afterCameraDrawStage: Stage<CameraStageAction>;
  34382. /**
  34383. * @hidden
  34384. * Defines the actions happening just after a render target has been drawn.
  34385. */
  34386. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34387. /**
  34388. * @hidden
  34389. * Defines the actions happening just after rendering all cameras and computing intersections.
  34390. */
  34391. _afterRenderStage: Stage<SimpleStageAction>;
  34392. /**
  34393. * @hidden
  34394. * Defines the actions happening when a pointer move event happens.
  34395. */
  34396. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34397. /**
  34398. * @hidden
  34399. * Defines the actions happening when a pointer down event happens.
  34400. */
  34401. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34402. /**
  34403. * @hidden
  34404. * Defines the actions happening when a pointer up event happens.
  34405. */
  34406. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34407. /**
  34408. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34409. */
  34410. private geometriesByUniqueId;
  34411. /**
  34412. * Creates a new Scene
  34413. * @param engine defines the engine to use to render this scene
  34414. * @param options defines the scene options
  34415. */
  34416. constructor(engine: Engine, options?: SceneOptions);
  34417. /**
  34418. * Gets a string idenfifying the name of the class
  34419. * @returns "Scene" string
  34420. */
  34421. getClassName(): string;
  34422. private _defaultMeshCandidates;
  34423. /**
  34424. * @hidden
  34425. */
  34426. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34427. private _defaultSubMeshCandidates;
  34428. /**
  34429. * @hidden
  34430. */
  34431. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34432. /**
  34433. * Sets the default candidate providers for the scene.
  34434. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34435. * and getCollidingSubMeshCandidates to their default function
  34436. */
  34437. setDefaultCandidateProviders(): void;
  34438. /**
  34439. * Gets the mesh that is currently under the pointer
  34440. */
  34441. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34442. /**
  34443. * Gets or sets the current on-screen X position of the pointer
  34444. */
  34445. pointerX: number;
  34446. /**
  34447. * Gets or sets the current on-screen Y position of the pointer
  34448. */
  34449. pointerY: number;
  34450. /**
  34451. * Gets the cached material (ie. the latest rendered one)
  34452. * @returns the cached material
  34453. */
  34454. getCachedMaterial(): Nullable<Material>;
  34455. /**
  34456. * Gets the cached effect (ie. the latest rendered one)
  34457. * @returns the cached effect
  34458. */
  34459. getCachedEffect(): Nullable<Effect>;
  34460. /**
  34461. * Gets the cached visibility state (ie. the latest rendered one)
  34462. * @returns the cached visibility state
  34463. */
  34464. getCachedVisibility(): Nullable<number>;
  34465. /**
  34466. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34467. * @param material defines the current material
  34468. * @param effect defines the current effect
  34469. * @param visibility defines the current visibility state
  34470. * @returns true if one parameter is not cached
  34471. */
  34472. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34473. /**
  34474. * Gets the engine associated with the scene
  34475. * @returns an Engine
  34476. */
  34477. getEngine(): Engine;
  34478. /**
  34479. * Gets the total number of vertices rendered per frame
  34480. * @returns the total number of vertices rendered per frame
  34481. */
  34482. getTotalVertices(): number;
  34483. /**
  34484. * Gets the performance counter for total vertices
  34485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34486. */
  34487. readonly totalVerticesPerfCounter: PerfCounter;
  34488. /**
  34489. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34490. * @returns the total number of active indices rendered per frame
  34491. */
  34492. getActiveIndices(): number;
  34493. /**
  34494. * Gets the performance counter for active indices
  34495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34496. */
  34497. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34498. /**
  34499. * Gets the total number of active particles rendered per frame
  34500. * @returns the total number of active particles rendered per frame
  34501. */
  34502. getActiveParticles(): number;
  34503. /**
  34504. * Gets the performance counter for active particles
  34505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34506. */
  34507. readonly activeParticlesPerfCounter: PerfCounter;
  34508. /**
  34509. * Gets the total number of active bones rendered per frame
  34510. * @returns the total number of active bones rendered per frame
  34511. */
  34512. getActiveBones(): number;
  34513. /**
  34514. * Gets the performance counter for active bones
  34515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34516. */
  34517. readonly activeBonesPerfCounter: PerfCounter;
  34518. /**
  34519. * Gets the array of active meshes
  34520. * @returns an array of AbstractMesh
  34521. */
  34522. getActiveMeshes(): SmartArray<AbstractMesh>;
  34523. /**
  34524. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34525. * @returns a number
  34526. */
  34527. getAnimationRatio(): number;
  34528. /**
  34529. * Gets an unique Id for the current render phase
  34530. * @returns a number
  34531. */
  34532. getRenderId(): number;
  34533. /**
  34534. * Gets an unique Id for the current frame
  34535. * @returns a number
  34536. */
  34537. getFrameId(): number;
  34538. /** Call this function if you want to manually increment the render Id*/
  34539. incrementRenderId(): void;
  34540. private _createUbo;
  34541. /**
  34542. * Use this method to simulate a pointer move on a mesh
  34543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34546. * @returns the current scene
  34547. */
  34548. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34549. /**
  34550. * Use this method to simulate a pointer down on a mesh
  34551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34554. * @returns the current scene
  34555. */
  34556. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34557. /**
  34558. * Use this method to simulate a pointer up on a mesh
  34559. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34560. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34561. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34562. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34563. * @returns the current scene
  34564. */
  34565. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34566. /**
  34567. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34568. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34569. * @returns true if the pointer was captured
  34570. */
  34571. isPointerCaptured(pointerId?: number): boolean;
  34572. /**
  34573. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34574. * @param attachUp defines if you want to attach events to pointerup
  34575. * @param attachDown defines if you want to attach events to pointerdown
  34576. * @param attachMove defines if you want to attach events to pointermove
  34577. */
  34578. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34579. /** Detaches all event handlers*/
  34580. detachControl(): void;
  34581. /**
  34582. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34583. * Delay loaded resources are not taking in account
  34584. * @return true if all required resources are ready
  34585. */
  34586. isReady(): boolean;
  34587. /** Resets all cached information relative to material (including effect and visibility) */
  34588. resetCachedMaterial(): void;
  34589. /**
  34590. * Registers a function to be called before every frame render
  34591. * @param func defines the function to register
  34592. */
  34593. registerBeforeRender(func: () => void): void;
  34594. /**
  34595. * Unregisters a function called before every frame render
  34596. * @param func defines the function to unregister
  34597. */
  34598. unregisterBeforeRender(func: () => void): void;
  34599. /**
  34600. * Registers a function to be called after every frame render
  34601. * @param func defines the function to register
  34602. */
  34603. registerAfterRender(func: () => void): void;
  34604. /**
  34605. * Unregisters a function called after every frame render
  34606. * @param func defines the function to unregister
  34607. */
  34608. unregisterAfterRender(func: () => void): void;
  34609. private _executeOnceBeforeRender;
  34610. /**
  34611. * The provided function will run before render once and will be disposed afterwards.
  34612. * A timeout delay can be provided so that the function will be executed in N ms.
  34613. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34614. * @param func The function to be executed.
  34615. * @param timeout optional delay in ms
  34616. */
  34617. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34618. /** @hidden */
  34619. _addPendingData(data: any): void;
  34620. /** @hidden */
  34621. _removePendingData(data: any): void;
  34622. /**
  34623. * Returns the number of items waiting to be loaded
  34624. * @returns the number of items waiting to be loaded
  34625. */
  34626. getWaitingItemsCount(): number;
  34627. /**
  34628. * Returns a boolean indicating if the scene is still loading data
  34629. */
  34630. readonly isLoading: boolean;
  34631. /**
  34632. * Registers a function to be executed when the scene is ready
  34633. * @param {Function} func - the function to be executed
  34634. */
  34635. executeWhenReady(func: () => void): void;
  34636. /**
  34637. * Returns a promise that resolves when the scene is ready
  34638. * @returns A promise that resolves when the scene is ready
  34639. */
  34640. whenReadyAsync(): Promise<void>;
  34641. /** @hidden */
  34642. _checkIsReady(): void;
  34643. /**
  34644. * Gets all animatable attached to the scene
  34645. */
  34646. readonly animatables: Animatable[];
  34647. /**
  34648. * Resets the last animation time frame.
  34649. * Useful to override when animations start running when loading a scene for the first time.
  34650. */
  34651. resetLastAnimationTimeFrame(): void;
  34652. /**
  34653. * Gets the current view matrix
  34654. * @returns a Matrix
  34655. */
  34656. getViewMatrix(): Matrix;
  34657. /**
  34658. * Gets the current projection matrix
  34659. * @returns a Matrix
  34660. */
  34661. getProjectionMatrix(): Matrix;
  34662. /**
  34663. * Gets the current transform matrix
  34664. * @returns a Matrix made of View * Projection
  34665. */
  34666. getTransformMatrix(): Matrix;
  34667. /**
  34668. * Sets the current transform matrix
  34669. * @param viewL defines the View matrix to use
  34670. * @param projectionL defines the Projection matrix to use
  34671. * @param viewR defines the right View matrix to use (if provided)
  34672. * @param projectionR defines the right Projection matrix to use (if provided)
  34673. */
  34674. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34675. /**
  34676. * Gets the uniform buffer used to store scene data
  34677. * @returns a UniformBuffer
  34678. */
  34679. getSceneUniformBuffer(): UniformBuffer;
  34680. /**
  34681. * Gets an unique (relatively to the current scene) Id
  34682. * @returns an unique number for the scene
  34683. */
  34684. getUniqueId(): number;
  34685. /**
  34686. * Add a mesh to the list of scene's meshes
  34687. * @param newMesh defines the mesh to add
  34688. * @param recursive if all child meshes should also be added to the scene
  34689. */
  34690. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34691. /**
  34692. * Remove a mesh for the list of scene's meshes
  34693. * @param toRemove defines the mesh to remove
  34694. * @param recursive if all child meshes should also be removed from the scene
  34695. * @returns the index where the mesh was in the mesh list
  34696. */
  34697. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34698. /**
  34699. * Add a transform node to the list of scene's transform nodes
  34700. * @param newTransformNode defines the transform node to add
  34701. */
  34702. addTransformNode(newTransformNode: TransformNode): void;
  34703. /**
  34704. * Remove a transform node for the list of scene's transform nodes
  34705. * @param toRemove defines the transform node to remove
  34706. * @returns the index where the transform node was in the transform node list
  34707. */
  34708. removeTransformNode(toRemove: TransformNode): number;
  34709. /**
  34710. * Remove a skeleton for the list of scene's skeletons
  34711. * @param toRemove defines the skeleton to remove
  34712. * @returns the index where the skeleton was in the skeleton list
  34713. */
  34714. removeSkeleton(toRemove: Skeleton): number;
  34715. /**
  34716. * Remove a morph target for the list of scene's morph targets
  34717. * @param toRemove defines the morph target to remove
  34718. * @returns the index where the morph target was in the morph target list
  34719. */
  34720. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34721. /**
  34722. * Remove a light for the list of scene's lights
  34723. * @param toRemove defines the light to remove
  34724. * @returns the index where the light was in the light list
  34725. */
  34726. removeLight(toRemove: Light): number;
  34727. /**
  34728. * Remove a camera for the list of scene's cameras
  34729. * @param toRemove defines the camera to remove
  34730. * @returns the index where the camera was in the camera list
  34731. */
  34732. removeCamera(toRemove: Camera): number;
  34733. /**
  34734. * Remove a particle system for the list of scene's particle systems
  34735. * @param toRemove defines the particle system to remove
  34736. * @returns the index where the particle system was in the particle system list
  34737. */
  34738. removeParticleSystem(toRemove: IParticleSystem): number;
  34739. /**
  34740. * Remove a animation for the list of scene's animations
  34741. * @param toRemove defines the animation to remove
  34742. * @returns the index where the animation was in the animation list
  34743. */
  34744. removeAnimation(toRemove: Animation): number;
  34745. /**
  34746. * Will stop the animation of the given target
  34747. * @param target - the target
  34748. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34749. * @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)
  34750. */
  34751. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34752. /**
  34753. * Removes the given animation group from this scene.
  34754. * @param toRemove The animation group to remove
  34755. * @returns The index of the removed animation group
  34756. */
  34757. removeAnimationGroup(toRemove: AnimationGroup): number;
  34758. /**
  34759. * Removes the given multi-material from this scene.
  34760. * @param toRemove The multi-material to remove
  34761. * @returns The index of the removed multi-material
  34762. */
  34763. removeMultiMaterial(toRemove: MultiMaterial): number;
  34764. /**
  34765. * Removes the given material from this scene.
  34766. * @param toRemove The material to remove
  34767. * @returns The index of the removed material
  34768. */
  34769. removeMaterial(toRemove: Material): number;
  34770. /**
  34771. * Removes the given action manager from this scene.
  34772. * @param toRemove The action manager to remove
  34773. * @returns The index of the removed action manager
  34774. */
  34775. removeActionManager(toRemove: AbstractActionManager): number;
  34776. /**
  34777. * Removes the given texture from this scene.
  34778. * @param toRemove The texture to remove
  34779. * @returns The index of the removed texture
  34780. */
  34781. removeTexture(toRemove: BaseTexture): number;
  34782. /**
  34783. * Adds the given light to this scene
  34784. * @param newLight The light to add
  34785. */
  34786. addLight(newLight: Light): void;
  34787. /**
  34788. * Sorts the list list based on light priorities
  34789. */
  34790. sortLightsByPriority(): void;
  34791. /**
  34792. * Adds the given camera to this scene
  34793. * @param newCamera The camera to add
  34794. */
  34795. addCamera(newCamera: Camera): void;
  34796. /**
  34797. * Adds the given skeleton to this scene
  34798. * @param newSkeleton The skeleton to add
  34799. */
  34800. addSkeleton(newSkeleton: Skeleton): void;
  34801. /**
  34802. * Adds the given particle system to this scene
  34803. * @param newParticleSystem The particle system to add
  34804. */
  34805. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34806. /**
  34807. * Adds the given animation to this scene
  34808. * @param newAnimation The animation to add
  34809. */
  34810. addAnimation(newAnimation: Animation): void;
  34811. /**
  34812. * Adds the given animation group to this scene.
  34813. * @param newAnimationGroup The animation group to add
  34814. */
  34815. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34816. /**
  34817. * Adds the given multi-material to this scene
  34818. * @param newMultiMaterial The multi-material to add
  34819. */
  34820. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34821. /**
  34822. * Adds the given material to this scene
  34823. * @param newMaterial The material to add
  34824. */
  34825. addMaterial(newMaterial: Material): void;
  34826. /**
  34827. * Adds the given morph target to this scene
  34828. * @param newMorphTargetManager The morph target to add
  34829. */
  34830. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34831. /**
  34832. * Adds the given geometry to this scene
  34833. * @param newGeometry The geometry to add
  34834. */
  34835. addGeometry(newGeometry: Geometry): void;
  34836. /**
  34837. * Adds the given action manager to this scene
  34838. * @param newActionManager The action manager to add
  34839. */
  34840. addActionManager(newActionManager: AbstractActionManager): void;
  34841. /**
  34842. * Adds the given texture to this scene.
  34843. * @param newTexture The texture to add
  34844. */
  34845. addTexture(newTexture: BaseTexture): void;
  34846. /**
  34847. * Switch active camera
  34848. * @param newCamera defines the new active camera
  34849. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34850. */
  34851. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34852. /**
  34853. * sets the active camera of the scene using its ID
  34854. * @param id defines the camera's ID
  34855. * @return the new active camera or null if none found.
  34856. */
  34857. setActiveCameraByID(id: string): Nullable<Camera>;
  34858. /**
  34859. * sets the active camera of the scene using its name
  34860. * @param name defines the camera's name
  34861. * @returns the new active camera or null if none found.
  34862. */
  34863. setActiveCameraByName(name: string): Nullable<Camera>;
  34864. /**
  34865. * get an animation group using its name
  34866. * @param name defines the material's name
  34867. * @return the animation group or null if none found.
  34868. */
  34869. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34870. /**
  34871. * Get a material using its unique id
  34872. * @param uniqueId defines the material's unique id
  34873. * @return the material or null if none found.
  34874. */
  34875. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34876. /**
  34877. * get a material using its id
  34878. * @param id defines the material's ID
  34879. * @return the material or null if none found.
  34880. */
  34881. getMaterialByID(id: string): Nullable<Material>;
  34882. /**
  34883. * Gets a the last added material using a given id
  34884. * @param id defines the material's ID
  34885. * @return the last material with the given id or null if none found.
  34886. */
  34887. getLastMaterialByID(id: string): Nullable<Material>;
  34888. /**
  34889. * Gets a material using its name
  34890. * @param name defines the material's name
  34891. * @return the material or null if none found.
  34892. */
  34893. getMaterialByName(name: string): Nullable<Material>;
  34894. /**
  34895. * Get a texture using its unique id
  34896. * @param uniqueId defines the texture's unique id
  34897. * @return the texture or null if none found.
  34898. */
  34899. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34900. /**
  34901. * Gets a camera using its id
  34902. * @param id defines the id to look for
  34903. * @returns the camera or null if not found
  34904. */
  34905. getCameraByID(id: string): Nullable<Camera>;
  34906. /**
  34907. * Gets a camera using its unique id
  34908. * @param uniqueId defines the unique id to look for
  34909. * @returns the camera or null if not found
  34910. */
  34911. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34912. /**
  34913. * Gets a camera using its name
  34914. * @param name defines the camera's name
  34915. * @return the camera or null if none found.
  34916. */
  34917. getCameraByName(name: string): Nullable<Camera>;
  34918. /**
  34919. * Gets a bone using its id
  34920. * @param id defines the bone's id
  34921. * @return the bone or null if not found
  34922. */
  34923. getBoneByID(id: string): Nullable<Bone>;
  34924. /**
  34925. * Gets a bone using its id
  34926. * @param name defines the bone's name
  34927. * @return the bone or null if not found
  34928. */
  34929. getBoneByName(name: string): Nullable<Bone>;
  34930. /**
  34931. * Gets a light node using its name
  34932. * @param name defines the the light's name
  34933. * @return the light or null if none found.
  34934. */
  34935. getLightByName(name: string): Nullable<Light>;
  34936. /**
  34937. * Gets a light node using its id
  34938. * @param id defines the light's id
  34939. * @return the light or null if none found.
  34940. */
  34941. getLightByID(id: string): Nullable<Light>;
  34942. /**
  34943. * Gets a light node using its scene-generated unique ID
  34944. * @param uniqueId defines the light's unique id
  34945. * @return the light or null if none found.
  34946. */
  34947. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34948. /**
  34949. * Gets a particle system by id
  34950. * @param id defines the particle system id
  34951. * @return the corresponding system or null if none found
  34952. */
  34953. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34954. /**
  34955. * Gets a geometry using its ID
  34956. * @param id defines the geometry's id
  34957. * @return the geometry or null if none found.
  34958. */
  34959. getGeometryByID(id: string): Nullable<Geometry>;
  34960. private _getGeometryByUniqueID;
  34961. /**
  34962. * Add a new geometry to this scene
  34963. * @param geometry defines the geometry to be added to the scene.
  34964. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34965. * @return a boolean defining if the geometry was added or not
  34966. */
  34967. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34968. /**
  34969. * Removes an existing geometry
  34970. * @param geometry defines the geometry to be removed from the scene
  34971. * @return a boolean defining if the geometry was removed or not
  34972. */
  34973. removeGeometry(geometry: Geometry): boolean;
  34974. /**
  34975. * Gets the list of geometries attached to the scene
  34976. * @returns an array of Geometry
  34977. */
  34978. getGeometries(): Geometry[];
  34979. /**
  34980. * Gets the first added mesh found of a given ID
  34981. * @param id defines the id to search for
  34982. * @return the mesh found or null if not found at all
  34983. */
  34984. getMeshByID(id: string): Nullable<AbstractMesh>;
  34985. /**
  34986. * Gets a list of meshes using their id
  34987. * @param id defines the id to search for
  34988. * @returns a list of meshes
  34989. */
  34990. getMeshesByID(id: string): Array<AbstractMesh>;
  34991. /**
  34992. * Gets the first added transform node found of a given ID
  34993. * @param id defines the id to search for
  34994. * @return the found transform node or null if not found at all.
  34995. */
  34996. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34997. /**
  34998. * Gets a transform node with its auto-generated unique id
  34999. * @param uniqueId efines the unique id to search for
  35000. * @return the found transform node or null if not found at all.
  35001. */
  35002. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35003. /**
  35004. * Gets a list of transform nodes using their id
  35005. * @param id defines the id to search for
  35006. * @returns a list of transform nodes
  35007. */
  35008. getTransformNodesByID(id: string): Array<TransformNode>;
  35009. /**
  35010. * Gets a mesh with its auto-generated unique id
  35011. * @param uniqueId defines the unique id to search for
  35012. * @return the found mesh or null if not found at all.
  35013. */
  35014. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35015. /**
  35016. * Gets a the last added mesh using a given id
  35017. * @param id defines the id to search for
  35018. * @return the found mesh or null if not found at all.
  35019. */
  35020. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35021. /**
  35022. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35023. * @param id defines the id to search for
  35024. * @return the found node or null if not found at all
  35025. */
  35026. getLastEntryByID(id: string): Nullable<Node>;
  35027. /**
  35028. * Gets a node (Mesh, Camera, Light) using a given id
  35029. * @param id defines the id to search for
  35030. * @return the found node or null if not found at all
  35031. */
  35032. getNodeByID(id: string): Nullable<Node>;
  35033. /**
  35034. * Gets a node (Mesh, Camera, Light) using a given name
  35035. * @param name defines the name to search for
  35036. * @return the found node or null if not found at all.
  35037. */
  35038. getNodeByName(name: string): Nullable<Node>;
  35039. /**
  35040. * Gets a mesh using a given name
  35041. * @param name defines the name to search for
  35042. * @return the found mesh or null if not found at all.
  35043. */
  35044. getMeshByName(name: string): Nullable<AbstractMesh>;
  35045. /**
  35046. * Gets a transform node using a given name
  35047. * @param name defines the name to search for
  35048. * @return the found transform node or null if not found at all.
  35049. */
  35050. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35051. /**
  35052. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35053. * @param id defines the id to search for
  35054. * @return the found skeleton or null if not found at all.
  35055. */
  35056. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35057. /**
  35058. * Gets a skeleton using a given auto generated unique id
  35059. * @param uniqueId defines the unique id to search for
  35060. * @return the found skeleton or null if not found at all.
  35061. */
  35062. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35063. /**
  35064. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35065. * @param id defines the id to search for
  35066. * @return the found skeleton or null if not found at all.
  35067. */
  35068. getSkeletonById(id: string): Nullable<Skeleton>;
  35069. /**
  35070. * Gets a skeleton using a given name
  35071. * @param name defines the name to search for
  35072. * @return the found skeleton or null if not found at all.
  35073. */
  35074. getSkeletonByName(name: string): Nullable<Skeleton>;
  35075. /**
  35076. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35077. * @param id defines the id to search for
  35078. * @return the found morph target manager or null if not found at all.
  35079. */
  35080. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35081. /**
  35082. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35083. * @param id defines the id to search for
  35084. * @return the found morph target or null if not found at all.
  35085. */
  35086. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35087. /**
  35088. * Gets a boolean indicating if the given mesh is active
  35089. * @param mesh defines the mesh to look for
  35090. * @returns true if the mesh is in the active list
  35091. */
  35092. isActiveMesh(mesh: AbstractMesh): boolean;
  35093. /**
  35094. * Return a unique id as a string which can serve as an identifier for the scene
  35095. */
  35096. readonly uid: string;
  35097. /**
  35098. * Add an externaly attached data from its key.
  35099. * This method call will fail and return false, if such key already exists.
  35100. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35101. * @param key the unique key that identifies the data
  35102. * @param data the data object to associate to the key for this Engine instance
  35103. * @return true if no such key were already present and the data was added successfully, false otherwise
  35104. */
  35105. addExternalData<T>(key: string, data: T): boolean;
  35106. /**
  35107. * Get an externaly attached data from its key
  35108. * @param key the unique key that identifies the data
  35109. * @return the associated data, if present (can be null), or undefined if not present
  35110. */
  35111. getExternalData<T>(key: string): Nullable<T>;
  35112. /**
  35113. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35114. * @param key the unique key that identifies the data
  35115. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35116. * @return the associated data, can be null if the factory returned null.
  35117. */
  35118. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35119. /**
  35120. * Remove an externaly attached data from the Engine instance
  35121. * @param key the unique key that identifies the data
  35122. * @return true if the data was successfully removed, false if it doesn't exist
  35123. */
  35124. removeExternalData(key: string): boolean;
  35125. private _evaluateSubMesh;
  35126. /**
  35127. * Clear the processed materials smart array preventing retention point in material dispose.
  35128. */
  35129. freeProcessedMaterials(): void;
  35130. private _preventFreeActiveMeshesAndRenderingGroups;
  35131. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35132. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35133. * when disposing several meshes in a row or a hierarchy of meshes.
  35134. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35135. */
  35136. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35137. /**
  35138. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35139. */
  35140. freeActiveMeshes(): void;
  35141. /**
  35142. * Clear the info related to rendering groups preventing retention points during dispose.
  35143. */
  35144. freeRenderingGroups(): void;
  35145. /** @hidden */
  35146. _isInIntermediateRendering(): boolean;
  35147. /**
  35148. * Lambda returning the list of potentially active meshes.
  35149. */
  35150. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35151. /**
  35152. * Lambda returning the list of potentially active sub meshes.
  35153. */
  35154. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35155. /**
  35156. * Lambda returning the list of potentially intersecting sub meshes.
  35157. */
  35158. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35159. /**
  35160. * Lambda returning the list of potentially colliding sub meshes.
  35161. */
  35162. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35163. private _activeMeshesFrozen;
  35164. /**
  35165. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35166. * @returns the current scene
  35167. */
  35168. freezeActiveMeshes(): Scene;
  35169. /**
  35170. * Use this function to restart evaluating active meshes on every frame
  35171. * @returns the current scene
  35172. */
  35173. unfreezeActiveMeshes(): Scene;
  35174. private _evaluateActiveMeshes;
  35175. private _activeMesh;
  35176. /**
  35177. * Update the transform matrix to update from the current active camera
  35178. * @param force defines a boolean used to force the update even if cache is up to date
  35179. */
  35180. updateTransformMatrix(force?: boolean): void;
  35181. private _bindFrameBuffer;
  35182. /** @hidden */
  35183. _allowPostProcessClearColor: boolean;
  35184. /** @hidden */
  35185. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35186. private _processSubCameras;
  35187. private _checkIntersections;
  35188. /** @hidden */
  35189. _advancePhysicsEngineStep(step: number): void;
  35190. /**
  35191. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35192. */
  35193. getDeterministicFrameTime: () => number;
  35194. /** @hidden */
  35195. _animate(): void;
  35196. /** Execute all animations (for a frame) */
  35197. animate(): void;
  35198. /**
  35199. * Render the scene
  35200. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35201. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35202. */
  35203. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35204. /**
  35205. * Freeze all materials
  35206. * A frozen material will not be updatable but should be faster to render
  35207. */
  35208. freezeMaterials(): void;
  35209. /**
  35210. * Unfreeze all materials
  35211. * A frozen material will not be updatable but should be faster to render
  35212. */
  35213. unfreezeMaterials(): void;
  35214. /**
  35215. * Releases all held ressources
  35216. */
  35217. dispose(): void;
  35218. /**
  35219. * Gets if the scene is already disposed
  35220. */
  35221. readonly isDisposed: boolean;
  35222. /**
  35223. * Call this function to reduce memory footprint of the scene.
  35224. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35225. */
  35226. clearCachedVertexData(): void;
  35227. /**
  35228. * This function will remove the local cached buffer data from texture.
  35229. * It will save memory but will prevent the texture from being rebuilt
  35230. */
  35231. cleanCachedTextureBuffer(): void;
  35232. /**
  35233. * Get the world extend vectors with an optional filter
  35234. *
  35235. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35236. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35237. */
  35238. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35239. min: Vector3;
  35240. max: Vector3;
  35241. };
  35242. /**
  35243. * Creates a ray that can be used to pick in the scene
  35244. * @param x defines the x coordinate of the origin (on-screen)
  35245. * @param y defines the y coordinate of the origin (on-screen)
  35246. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35247. * @param camera defines the camera to use for the picking
  35248. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35249. * @returns a Ray
  35250. */
  35251. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35252. /**
  35253. * Creates a ray that can be used to pick in the scene
  35254. * @param x defines the x coordinate of the origin (on-screen)
  35255. * @param y defines the y coordinate of the origin (on-screen)
  35256. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35257. * @param result defines the ray where to store the picking ray
  35258. * @param camera defines the camera to use for the picking
  35259. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35260. * @returns the current scene
  35261. */
  35262. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35263. /**
  35264. * Creates a ray that can be used to pick in the scene
  35265. * @param x defines the x coordinate of the origin (on-screen)
  35266. * @param y defines the y coordinate of the origin (on-screen)
  35267. * @param camera defines the camera to use for the picking
  35268. * @returns a Ray
  35269. */
  35270. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35271. /**
  35272. * Creates a ray that can be used to pick in the scene
  35273. * @param x defines the x coordinate of the origin (on-screen)
  35274. * @param y defines the y coordinate of the origin (on-screen)
  35275. * @param result defines the ray where to store the picking ray
  35276. * @param camera defines the camera to use for the picking
  35277. * @returns the current scene
  35278. */
  35279. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35280. /** Launch a ray to try to pick a mesh in the scene
  35281. * @param x position on screen
  35282. * @param y position on screen
  35283. * @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
  35284. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35285. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35287. * @returns a PickingInfo
  35288. */
  35289. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35290. /** Use the given ray to pick a mesh in the scene
  35291. * @param ray The ray to use to pick meshes
  35292. * @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
  35293. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35295. * @returns a PickingInfo
  35296. */
  35297. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35298. /**
  35299. * Launch a ray to try to pick a mesh in the scene
  35300. * @param x X position on screen
  35301. * @param y Y position on screen
  35302. * @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
  35303. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35304. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35305. * @returns an array of PickingInfo
  35306. */
  35307. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35308. /**
  35309. * Launch a ray to try to pick a mesh in the scene
  35310. * @param ray Ray to use
  35311. * @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
  35312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35313. * @returns an array of PickingInfo
  35314. */
  35315. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35316. /**
  35317. * Force the value of meshUnderPointer
  35318. * @param mesh defines the mesh to use
  35319. */
  35320. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35321. /**
  35322. * Gets the mesh under the pointer
  35323. * @returns a Mesh or null if no mesh is under the pointer
  35324. */
  35325. getPointerOverMesh(): Nullable<AbstractMesh>;
  35326. /** @hidden */
  35327. _rebuildGeometries(): void;
  35328. /** @hidden */
  35329. _rebuildTextures(): void;
  35330. private _getByTags;
  35331. /**
  35332. * Get a list of meshes by tags
  35333. * @param tagsQuery defines the tags query to use
  35334. * @param forEach defines a predicate used to filter results
  35335. * @returns an array of Mesh
  35336. */
  35337. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35338. /**
  35339. * Get a list of cameras by tags
  35340. * @param tagsQuery defines the tags query to use
  35341. * @param forEach defines a predicate used to filter results
  35342. * @returns an array of Camera
  35343. */
  35344. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35345. /**
  35346. * Get a list of lights by tags
  35347. * @param tagsQuery defines the tags query to use
  35348. * @param forEach defines a predicate used to filter results
  35349. * @returns an array of Light
  35350. */
  35351. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35352. /**
  35353. * Get a list of materials by tags
  35354. * @param tagsQuery defines the tags query to use
  35355. * @param forEach defines a predicate used to filter results
  35356. * @returns an array of Material
  35357. */
  35358. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35359. /**
  35360. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35361. * This allowed control for front to back rendering or reversly depending of the special needs.
  35362. *
  35363. * @param renderingGroupId The rendering group id corresponding to its index
  35364. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35365. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35366. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35367. */
  35368. 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;
  35369. /**
  35370. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35371. *
  35372. * @param renderingGroupId The rendering group id corresponding to its index
  35373. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35374. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35375. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35376. */
  35377. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35378. /**
  35379. * Gets the current auto clear configuration for one rendering group of the rendering
  35380. * manager.
  35381. * @param index the rendering group index to get the information for
  35382. * @returns The auto clear setup for the requested rendering group
  35383. */
  35384. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35385. private _blockMaterialDirtyMechanism;
  35386. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35387. blockMaterialDirtyMechanism: boolean;
  35388. /**
  35389. * Will flag all materials as dirty to trigger new shader compilation
  35390. * @param flag defines the flag used to specify which material part must be marked as dirty
  35391. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35392. */
  35393. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35394. /** @hidden */
  35395. _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;
  35396. /** @hidden */
  35397. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35398. }
  35399. }
  35400. declare module "babylonjs/assetContainer" {
  35401. import { AbstractScene } from "babylonjs/abstractScene";
  35402. import { Scene } from "babylonjs/scene";
  35403. import { Mesh } from "babylonjs/Meshes/mesh";
  35404. /**
  35405. * Set of assets to keep when moving a scene into an asset container.
  35406. */
  35407. export class KeepAssets extends AbstractScene {
  35408. }
  35409. /**
  35410. * Container with a set of assets that can be added or removed from a scene.
  35411. */
  35412. export class AssetContainer extends AbstractScene {
  35413. /**
  35414. * The scene the AssetContainer belongs to.
  35415. */
  35416. scene: Scene;
  35417. /**
  35418. * Instantiates an AssetContainer.
  35419. * @param scene The scene the AssetContainer belongs to.
  35420. */
  35421. constructor(scene: Scene);
  35422. /**
  35423. * Adds all the assets from the container to the scene.
  35424. */
  35425. addAllToScene(): void;
  35426. /**
  35427. * Removes all the assets in the container from the scene
  35428. */
  35429. removeAllFromScene(): void;
  35430. /**
  35431. * Disposes all the assets in the container
  35432. */
  35433. dispose(): void;
  35434. private _moveAssets;
  35435. /**
  35436. * Removes all the assets contained in the scene and adds them to the container.
  35437. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35438. */
  35439. moveAllFromScene(keepAssets?: KeepAssets): void;
  35440. /**
  35441. * 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.
  35442. * @returns the root mesh
  35443. */
  35444. createRootMesh(): Mesh;
  35445. }
  35446. }
  35447. declare module "babylonjs/abstractScene" {
  35448. import { Scene } from "babylonjs/scene";
  35449. import { Nullable } from "babylonjs/types";
  35450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35451. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35452. import { Geometry } from "babylonjs/Meshes/geometry";
  35453. import { Skeleton } from "babylonjs/Bones/skeleton";
  35454. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35455. import { AssetContainer } from "babylonjs/assetContainer";
  35456. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35457. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35459. import { Material } from "babylonjs/Materials/material";
  35460. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35462. import { Camera } from "babylonjs/Cameras/camera";
  35463. import { Light } from "babylonjs/Lights/light";
  35464. import { Node } from "babylonjs/node";
  35465. import { Animation } from "babylonjs/Animations/animation";
  35466. /**
  35467. * Defines how the parser contract is defined.
  35468. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35469. */
  35470. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35471. /**
  35472. * Defines how the individual parser contract is defined.
  35473. * These parser can parse an individual asset
  35474. */
  35475. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35476. /**
  35477. * Base class of the scene acting as a container for the different elements composing a scene.
  35478. * This class is dynamically extended by the different components of the scene increasing
  35479. * flexibility and reducing coupling
  35480. */
  35481. export abstract class AbstractScene {
  35482. /**
  35483. * Stores the list of available parsers in the application.
  35484. */
  35485. private static _BabylonFileParsers;
  35486. /**
  35487. * Stores the list of available individual parsers in the application.
  35488. */
  35489. private static _IndividualBabylonFileParsers;
  35490. /**
  35491. * Adds a parser in the list of available ones
  35492. * @param name Defines the name of the parser
  35493. * @param parser Defines the parser to add
  35494. */
  35495. static AddParser(name: string, parser: BabylonFileParser): void;
  35496. /**
  35497. * Gets a general parser from the list of avaialble ones
  35498. * @param name Defines the name of the parser
  35499. * @returns the requested parser or null
  35500. */
  35501. static GetParser(name: string): Nullable<BabylonFileParser>;
  35502. /**
  35503. * Adds n individual parser in the list of available ones
  35504. * @param name Defines the name of the parser
  35505. * @param parser Defines the parser to add
  35506. */
  35507. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35508. /**
  35509. * Gets an individual parser from the list of avaialble ones
  35510. * @param name Defines the name of the parser
  35511. * @returns the requested parser or null
  35512. */
  35513. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35514. /**
  35515. * Parser json data and populate both a scene and its associated container object
  35516. * @param jsonData Defines the data to parse
  35517. * @param scene Defines the scene to parse the data for
  35518. * @param container Defines the container attached to the parsing sequence
  35519. * @param rootUrl Defines the root url of the data
  35520. */
  35521. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35522. /**
  35523. * Gets the list of root nodes (ie. nodes with no parent)
  35524. */
  35525. rootNodes: Node[];
  35526. /** All of the cameras added to this scene
  35527. * @see http://doc.babylonjs.com/babylon101/cameras
  35528. */
  35529. cameras: Camera[];
  35530. /**
  35531. * All of the lights added to this scene
  35532. * @see http://doc.babylonjs.com/babylon101/lights
  35533. */
  35534. lights: Light[];
  35535. /**
  35536. * All of the (abstract) meshes added to this scene
  35537. */
  35538. meshes: AbstractMesh[];
  35539. /**
  35540. * The list of skeletons added to the scene
  35541. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35542. */
  35543. skeletons: Skeleton[];
  35544. /**
  35545. * All of the particle systems added to this scene
  35546. * @see http://doc.babylonjs.com/babylon101/particles
  35547. */
  35548. particleSystems: IParticleSystem[];
  35549. /**
  35550. * Gets a list of Animations associated with the scene
  35551. */
  35552. animations: Animation[];
  35553. /**
  35554. * All of the animation groups added to this scene
  35555. * @see http://doc.babylonjs.com/how_to/group
  35556. */
  35557. animationGroups: AnimationGroup[];
  35558. /**
  35559. * All of the multi-materials added to this scene
  35560. * @see http://doc.babylonjs.com/how_to/multi_materials
  35561. */
  35562. multiMaterials: MultiMaterial[];
  35563. /**
  35564. * All of the materials added to this scene
  35565. * In the context of a Scene, it is not supposed to be modified manually.
  35566. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35567. * Note also that the order of the Material wihin the array is not significant and might change.
  35568. * @see http://doc.babylonjs.com/babylon101/materials
  35569. */
  35570. materials: Material[];
  35571. /**
  35572. * The list of morph target managers added to the scene
  35573. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35574. */
  35575. morphTargetManagers: MorphTargetManager[];
  35576. /**
  35577. * The list of geometries used in the scene.
  35578. */
  35579. geometries: Geometry[];
  35580. /**
  35581. * All of the tranform nodes added to this scene
  35582. * In the context of a Scene, it is not supposed to be modified manually.
  35583. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35584. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35585. * @see http://doc.babylonjs.com/how_to/transformnode
  35586. */
  35587. transformNodes: TransformNode[];
  35588. /**
  35589. * ActionManagers available on the scene.
  35590. */
  35591. actionManagers: AbstractActionManager[];
  35592. /**
  35593. * Textures to keep.
  35594. */
  35595. textures: BaseTexture[];
  35596. /**
  35597. * Environment texture for the scene
  35598. */
  35599. environmentTexture: Nullable<BaseTexture>;
  35600. }
  35601. }
  35602. declare module "babylonjs/Audio/sound" {
  35603. import { Observable } from "babylonjs/Misc/observable";
  35604. import { Vector3 } from "babylonjs/Maths/math.vector";
  35605. import { Nullable } from "babylonjs/types";
  35606. import { Scene } from "babylonjs/scene";
  35607. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35608. /**
  35609. * Interface used to define options for Sound class
  35610. */
  35611. export interface ISoundOptions {
  35612. /**
  35613. * Does the sound autoplay once loaded.
  35614. */
  35615. autoplay?: boolean;
  35616. /**
  35617. * Does the sound loop after it finishes playing once.
  35618. */
  35619. loop?: boolean;
  35620. /**
  35621. * Sound's volume
  35622. */
  35623. volume?: number;
  35624. /**
  35625. * Is it a spatial sound?
  35626. */
  35627. spatialSound?: boolean;
  35628. /**
  35629. * Maximum distance to hear that sound
  35630. */
  35631. maxDistance?: number;
  35632. /**
  35633. * Uses user defined attenuation function
  35634. */
  35635. useCustomAttenuation?: boolean;
  35636. /**
  35637. * Define the roll off factor of spatial sounds.
  35638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35639. */
  35640. rolloffFactor?: number;
  35641. /**
  35642. * Define the reference distance the sound should be heard perfectly.
  35643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35644. */
  35645. refDistance?: number;
  35646. /**
  35647. * Define the distance attenuation model the sound will follow.
  35648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35649. */
  35650. distanceModel?: string;
  35651. /**
  35652. * Defines the playback speed (1 by default)
  35653. */
  35654. playbackRate?: number;
  35655. /**
  35656. * Defines if the sound is from a streaming source
  35657. */
  35658. streaming?: boolean;
  35659. /**
  35660. * Defines an optional length (in seconds) inside the sound file
  35661. */
  35662. length?: number;
  35663. /**
  35664. * Defines an optional offset (in seconds) inside the sound file
  35665. */
  35666. offset?: number;
  35667. /**
  35668. * If true, URLs will not be required to state the audio file codec to use.
  35669. */
  35670. skipCodecCheck?: boolean;
  35671. }
  35672. /**
  35673. * Defines a sound that can be played in the application.
  35674. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35676. */
  35677. export class Sound {
  35678. /**
  35679. * The name of the sound in the scene.
  35680. */
  35681. name: string;
  35682. /**
  35683. * Does the sound autoplay once loaded.
  35684. */
  35685. autoplay: boolean;
  35686. /**
  35687. * Does the sound loop after it finishes playing once.
  35688. */
  35689. loop: boolean;
  35690. /**
  35691. * Does the sound use a custom attenuation curve to simulate the falloff
  35692. * happening when the source gets further away from the camera.
  35693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35694. */
  35695. useCustomAttenuation: boolean;
  35696. /**
  35697. * The sound track id this sound belongs to.
  35698. */
  35699. soundTrackId: number;
  35700. /**
  35701. * Is this sound currently played.
  35702. */
  35703. isPlaying: boolean;
  35704. /**
  35705. * Is this sound currently paused.
  35706. */
  35707. isPaused: boolean;
  35708. /**
  35709. * Does this sound enables spatial sound.
  35710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35711. */
  35712. spatialSound: boolean;
  35713. /**
  35714. * Define the reference distance the sound should be heard perfectly.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35716. */
  35717. refDistance: number;
  35718. /**
  35719. * Define the roll off factor of spatial sounds.
  35720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35721. */
  35722. rolloffFactor: number;
  35723. /**
  35724. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35726. */
  35727. maxDistance: number;
  35728. /**
  35729. * Define the distance attenuation model the sound will follow.
  35730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35731. */
  35732. distanceModel: string;
  35733. /**
  35734. * @hidden
  35735. * Back Compat
  35736. **/
  35737. onended: () => any;
  35738. /**
  35739. * Observable event when the current playing sound finishes.
  35740. */
  35741. onEndedObservable: Observable<Sound>;
  35742. private _panningModel;
  35743. private _playbackRate;
  35744. private _streaming;
  35745. private _startTime;
  35746. private _startOffset;
  35747. private _position;
  35748. /** @hidden */
  35749. _positionInEmitterSpace: boolean;
  35750. private _localDirection;
  35751. private _volume;
  35752. private _isReadyToPlay;
  35753. private _isDirectional;
  35754. private _readyToPlayCallback;
  35755. private _audioBuffer;
  35756. private _soundSource;
  35757. private _streamingSource;
  35758. private _soundPanner;
  35759. private _soundGain;
  35760. private _inputAudioNode;
  35761. private _outputAudioNode;
  35762. private _coneInnerAngle;
  35763. private _coneOuterAngle;
  35764. private _coneOuterGain;
  35765. private _scene;
  35766. private _connectedTransformNode;
  35767. private _customAttenuationFunction;
  35768. private _registerFunc;
  35769. private _isOutputConnected;
  35770. private _htmlAudioElement;
  35771. private _urlType;
  35772. private _length?;
  35773. private _offset?;
  35774. /** @hidden */
  35775. static _SceneComponentInitialization: (scene: Scene) => void;
  35776. /**
  35777. * Create a sound and attach it to a scene
  35778. * @param name Name of your sound
  35779. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35780. * @param scene defines the scene the sound belongs to
  35781. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35782. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35783. */
  35784. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35785. /**
  35786. * Release the sound and its associated resources
  35787. */
  35788. dispose(): void;
  35789. /**
  35790. * Gets if the sounds is ready to be played or not.
  35791. * @returns true if ready, otherwise false
  35792. */
  35793. isReady(): boolean;
  35794. private _soundLoaded;
  35795. /**
  35796. * Sets the data of the sound from an audiobuffer
  35797. * @param audioBuffer The audioBuffer containing the data
  35798. */
  35799. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35800. /**
  35801. * Updates the current sounds options such as maxdistance, loop...
  35802. * @param options A JSON object containing values named as the object properties
  35803. */
  35804. updateOptions(options: ISoundOptions): void;
  35805. private _createSpatialParameters;
  35806. private _updateSpatialParameters;
  35807. /**
  35808. * Switch the panning model to HRTF:
  35809. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35811. */
  35812. switchPanningModelToHRTF(): void;
  35813. /**
  35814. * Switch the panning model to Equal Power:
  35815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35817. */
  35818. switchPanningModelToEqualPower(): void;
  35819. private _switchPanningModel;
  35820. /**
  35821. * Connect this sound to a sound track audio node like gain...
  35822. * @param soundTrackAudioNode the sound track audio node to connect to
  35823. */
  35824. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35825. /**
  35826. * Transform this sound into a directional source
  35827. * @param coneInnerAngle Size of the inner cone in degree
  35828. * @param coneOuterAngle Size of the outer cone in degree
  35829. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35830. */
  35831. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35832. /**
  35833. * Gets or sets the inner angle for the directional cone.
  35834. */
  35835. /**
  35836. * Gets or sets the inner angle for the directional cone.
  35837. */
  35838. directionalConeInnerAngle: number;
  35839. /**
  35840. * Gets or sets the outer angle for the directional cone.
  35841. */
  35842. /**
  35843. * Gets or sets the outer angle for the directional cone.
  35844. */
  35845. directionalConeOuterAngle: number;
  35846. /**
  35847. * Sets the position of the emitter if spatial sound is enabled
  35848. * @param newPosition Defines the new posisiton
  35849. */
  35850. setPosition(newPosition: Vector3): void;
  35851. /**
  35852. * Sets the local direction of the emitter if spatial sound is enabled
  35853. * @param newLocalDirection Defines the new local direction
  35854. */
  35855. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35856. private _updateDirection;
  35857. /** @hidden */
  35858. updateDistanceFromListener(): void;
  35859. /**
  35860. * Sets a new custom attenuation function for the sound.
  35861. * @param callback Defines the function used for the attenuation
  35862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35863. */
  35864. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35865. /**
  35866. * Play the sound
  35867. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35868. * @param offset (optional) Start the sound at a specific time in seconds
  35869. * @param length (optional) Sound duration (in seconds)
  35870. */
  35871. play(time?: number, offset?: number, length?: number): void;
  35872. private _onended;
  35873. /**
  35874. * Stop the sound
  35875. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35876. */
  35877. stop(time?: number): void;
  35878. /**
  35879. * Put the sound in pause
  35880. */
  35881. pause(): void;
  35882. /**
  35883. * Sets a dedicated volume for this sounds
  35884. * @param newVolume Define the new volume of the sound
  35885. * @param time Define time for gradual change to new volume
  35886. */
  35887. setVolume(newVolume: number, time?: number): void;
  35888. /**
  35889. * Set the sound play back rate
  35890. * @param newPlaybackRate Define the playback rate the sound should be played at
  35891. */
  35892. setPlaybackRate(newPlaybackRate: number): void;
  35893. /**
  35894. * Gets the volume of the sound.
  35895. * @returns the volume of the sound
  35896. */
  35897. getVolume(): number;
  35898. /**
  35899. * Attach the sound to a dedicated mesh
  35900. * @param transformNode The transform node to connect the sound with
  35901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35902. */
  35903. attachToMesh(transformNode: TransformNode): void;
  35904. /**
  35905. * Detach the sound from the previously attached mesh
  35906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35907. */
  35908. detachFromMesh(): void;
  35909. private _onRegisterAfterWorldMatrixUpdate;
  35910. /**
  35911. * Clone the current sound in the scene.
  35912. * @returns the new sound clone
  35913. */
  35914. clone(): Nullable<Sound>;
  35915. /**
  35916. * Gets the current underlying audio buffer containing the data
  35917. * @returns the audio buffer
  35918. */
  35919. getAudioBuffer(): Nullable<AudioBuffer>;
  35920. /**
  35921. * Serializes the Sound in a JSON representation
  35922. * @returns the JSON representation of the sound
  35923. */
  35924. serialize(): any;
  35925. /**
  35926. * Parse a JSON representation of a sound to innstantiate in a given scene
  35927. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35928. * @param scene Define the scene the new parsed sound should be created in
  35929. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35930. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35931. * @returns the newly parsed sound
  35932. */
  35933. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35934. }
  35935. }
  35936. declare module "babylonjs/Actions/directAudioActions" {
  35937. import { Action } from "babylonjs/Actions/action";
  35938. import { Condition } from "babylonjs/Actions/condition";
  35939. import { Sound } from "babylonjs/Audio/sound";
  35940. /**
  35941. * This defines an action helpful to play a defined sound on a triggered action.
  35942. */
  35943. export class PlaySoundAction extends Action {
  35944. private _sound;
  35945. /**
  35946. * Instantiate the action
  35947. * @param triggerOptions defines the trigger options
  35948. * @param sound defines the sound to play
  35949. * @param condition defines the trigger related conditions
  35950. */
  35951. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35952. /** @hidden */
  35953. _prepare(): void;
  35954. /**
  35955. * Execute the action and play the sound.
  35956. */
  35957. execute(): void;
  35958. /**
  35959. * Serializes the actions and its related information.
  35960. * @param parent defines the object to serialize in
  35961. * @returns the serialized object
  35962. */
  35963. serialize(parent: any): any;
  35964. }
  35965. /**
  35966. * This defines an action helpful to stop a defined sound on a triggered action.
  35967. */
  35968. export class StopSoundAction extends Action {
  35969. private _sound;
  35970. /**
  35971. * Instantiate the action
  35972. * @param triggerOptions defines the trigger options
  35973. * @param sound defines the sound to stop
  35974. * @param condition defines the trigger related conditions
  35975. */
  35976. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35977. /** @hidden */
  35978. _prepare(): void;
  35979. /**
  35980. * Execute the action and stop the sound.
  35981. */
  35982. execute(): void;
  35983. /**
  35984. * Serializes the actions and its related information.
  35985. * @param parent defines the object to serialize in
  35986. * @returns the serialized object
  35987. */
  35988. serialize(parent: any): any;
  35989. }
  35990. }
  35991. declare module "babylonjs/Actions/interpolateValueAction" {
  35992. import { Action } from "babylonjs/Actions/action";
  35993. import { Condition } from "babylonjs/Actions/condition";
  35994. import { Observable } from "babylonjs/Misc/observable";
  35995. /**
  35996. * This defines an action responsible to change the value of a property
  35997. * by interpolating between its current value and the newly set one once triggered.
  35998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35999. */
  36000. export class InterpolateValueAction extends Action {
  36001. /**
  36002. * Defines the path of the property where the value should be interpolated
  36003. */
  36004. propertyPath: string;
  36005. /**
  36006. * Defines the target value at the end of the interpolation.
  36007. */
  36008. value: any;
  36009. /**
  36010. * Defines the time it will take for the property to interpolate to the value.
  36011. */
  36012. duration: number;
  36013. /**
  36014. * Defines if the other scene animations should be stopped when the action has been triggered
  36015. */
  36016. stopOtherAnimations?: boolean;
  36017. /**
  36018. * Defines a callback raised once the interpolation animation has been done.
  36019. */
  36020. onInterpolationDone?: () => void;
  36021. /**
  36022. * Observable triggered once the interpolation animation has been done.
  36023. */
  36024. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36025. private _target;
  36026. private _effectiveTarget;
  36027. private _property;
  36028. /**
  36029. * Instantiate the action
  36030. * @param triggerOptions defines the trigger options
  36031. * @param target defines the object containing the value to interpolate
  36032. * @param propertyPath defines the path to the property in the target object
  36033. * @param value defines the target value at the end of the interpolation
  36034. * @param duration deines the time it will take for the property to interpolate to the value.
  36035. * @param condition defines the trigger related conditions
  36036. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36037. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36038. */
  36039. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36040. /** @hidden */
  36041. _prepare(): void;
  36042. /**
  36043. * Execute the action starts the value interpolation.
  36044. */
  36045. execute(): void;
  36046. /**
  36047. * Serializes the actions and its related information.
  36048. * @param parent defines the object to serialize in
  36049. * @returns the serialized object
  36050. */
  36051. serialize(parent: any): any;
  36052. }
  36053. }
  36054. declare module "babylonjs/Actions/index" {
  36055. export * from "babylonjs/Actions/action";
  36056. export * from "babylonjs/Actions/actionEvent";
  36057. export * from "babylonjs/Actions/actionManager";
  36058. export * from "babylonjs/Actions/condition";
  36059. export * from "babylonjs/Actions/directActions";
  36060. export * from "babylonjs/Actions/directAudioActions";
  36061. export * from "babylonjs/Actions/interpolateValueAction";
  36062. }
  36063. declare module "babylonjs/Animations/index" {
  36064. export * from "babylonjs/Animations/animatable";
  36065. export * from "babylonjs/Animations/animation";
  36066. export * from "babylonjs/Animations/animationGroup";
  36067. export * from "babylonjs/Animations/animationPropertiesOverride";
  36068. export * from "babylonjs/Animations/easing";
  36069. export * from "babylonjs/Animations/runtimeAnimation";
  36070. export * from "babylonjs/Animations/animationEvent";
  36071. export * from "babylonjs/Animations/animationGroup";
  36072. export * from "babylonjs/Animations/animationKey";
  36073. export * from "babylonjs/Animations/animationRange";
  36074. export * from "babylonjs/Animations/animatable.interface";
  36075. }
  36076. declare module "babylonjs/Audio/soundTrack" {
  36077. import { Sound } from "babylonjs/Audio/sound";
  36078. import { Analyser } from "babylonjs/Audio/analyser";
  36079. import { Scene } from "babylonjs/scene";
  36080. /**
  36081. * Options allowed during the creation of a sound track.
  36082. */
  36083. export interface ISoundTrackOptions {
  36084. /**
  36085. * The volume the sound track should take during creation
  36086. */
  36087. volume?: number;
  36088. /**
  36089. * Define if the sound track is the main sound track of the scene
  36090. */
  36091. mainTrack?: boolean;
  36092. }
  36093. /**
  36094. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36095. * It will be also used in a future release to apply effects on a specific track.
  36096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36097. */
  36098. export class SoundTrack {
  36099. /**
  36100. * The unique identifier of the sound track in the scene.
  36101. */
  36102. id: number;
  36103. /**
  36104. * The list of sounds included in the sound track.
  36105. */
  36106. soundCollection: Array<Sound>;
  36107. private _outputAudioNode;
  36108. private _scene;
  36109. private _isMainTrack;
  36110. private _connectedAnalyser;
  36111. private _options;
  36112. private _isInitialized;
  36113. /**
  36114. * Creates a new sound track.
  36115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36116. * @param scene Define the scene the sound track belongs to
  36117. * @param options
  36118. */
  36119. constructor(scene: Scene, options?: ISoundTrackOptions);
  36120. private _initializeSoundTrackAudioGraph;
  36121. /**
  36122. * Release the sound track and its associated resources
  36123. */
  36124. dispose(): void;
  36125. /**
  36126. * Adds a sound to this sound track
  36127. * @param sound define the cound to add
  36128. * @ignoreNaming
  36129. */
  36130. AddSound(sound: Sound): void;
  36131. /**
  36132. * Removes a sound to this sound track
  36133. * @param sound define the cound to remove
  36134. * @ignoreNaming
  36135. */
  36136. RemoveSound(sound: Sound): void;
  36137. /**
  36138. * Set a global volume for the full sound track.
  36139. * @param newVolume Define the new volume of the sound track
  36140. */
  36141. setVolume(newVolume: number): void;
  36142. /**
  36143. * Switch the panning model to HRTF:
  36144. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36146. */
  36147. switchPanningModelToHRTF(): void;
  36148. /**
  36149. * Switch the panning model to Equal Power:
  36150. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36152. */
  36153. switchPanningModelToEqualPower(): void;
  36154. /**
  36155. * Connect the sound track to an audio analyser allowing some amazing
  36156. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36158. * @param analyser The analyser to connect to the engine
  36159. */
  36160. connectToAnalyser(analyser: Analyser): void;
  36161. }
  36162. }
  36163. declare module "babylonjs/Audio/audioSceneComponent" {
  36164. import { Sound } from "babylonjs/Audio/sound";
  36165. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36166. import { Nullable } from "babylonjs/types";
  36167. import { Vector3 } from "babylonjs/Maths/math.vector";
  36168. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36169. import { Scene } from "babylonjs/scene";
  36170. import { AbstractScene } from "babylonjs/abstractScene";
  36171. import "babylonjs/Audio/audioEngine";
  36172. module "babylonjs/abstractScene" {
  36173. interface AbstractScene {
  36174. /**
  36175. * The list of sounds used in the scene.
  36176. */
  36177. sounds: Nullable<Array<Sound>>;
  36178. }
  36179. }
  36180. module "babylonjs/scene" {
  36181. interface Scene {
  36182. /**
  36183. * @hidden
  36184. * Backing field
  36185. */
  36186. _mainSoundTrack: SoundTrack;
  36187. /**
  36188. * The main sound track played by the scene.
  36189. * It cotains your primary collection of sounds.
  36190. */
  36191. mainSoundTrack: SoundTrack;
  36192. /**
  36193. * The list of sound tracks added to the scene
  36194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36195. */
  36196. soundTracks: Nullable<Array<SoundTrack>>;
  36197. /**
  36198. * Gets a sound using a given name
  36199. * @param name defines the name to search for
  36200. * @return the found sound or null if not found at all.
  36201. */
  36202. getSoundByName(name: string): Nullable<Sound>;
  36203. /**
  36204. * Gets or sets if audio support is enabled
  36205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36206. */
  36207. audioEnabled: boolean;
  36208. /**
  36209. * Gets or sets if audio will be output to headphones
  36210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36211. */
  36212. headphone: boolean;
  36213. /**
  36214. * Gets or sets custom audio listener position provider
  36215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36216. */
  36217. audioListenerPositionProvider: Nullable<() => Vector3>;
  36218. }
  36219. }
  36220. /**
  36221. * Defines the sound scene component responsible to manage any sounds
  36222. * in a given scene.
  36223. */
  36224. export class AudioSceneComponent implements ISceneSerializableComponent {
  36225. /**
  36226. * The component name helpfull to identify the component in the list of scene components.
  36227. */
  36228. readonly name: string;
  36229. /**
  36230. * The scene the component belongs to.
  36231. */
  36232. scene: Scene;
  36233. private _audioEnabled;
  36234. /**
  36235. * Gets whether audio is enabled or not.
  36236. * Please use related enable/disable method to switch state.
  36237. */
  36238. readonly audioEnabled: boolean;
  36239. private _headphone;
  36240. /**
  36241. * Gets whether audio is outputing to headphone or not.
  36242. * Please use the according Switch methods to change output.
  36243. */
  36244. readonly headphone: boolean;
  36245. private _audioListenerPositionProvider;
  36246. /**
  36247. * Gets the current audio listener position provider
  36248. */
  36249. /**
  36250. * Sets a custom listener position for all sounds in the scene
  36251. * By default, this is the position of the first active camera
  36252. */
  36253. audioListenerPositionProvider: Nullable<() => Vector3>;
  36254. /**
  36255. * Creates a new instance of the component for the given scene
  36256. * @param scene Defines the scene to register the component in
  36257. */
  36258. constructor(scene: Scene);
  36259. /**
  36260. * Registers the component in a given scene
  36261. */
  36262. register(): void;
  36263. /**
  36264. * Rebuilds the elements related to this component in case of
  36265. * context lost for instance.
  36266. */
  36267. rebuild(): void;
  36268. /**
  36269. * Serializes the component data to the specified json object
  36270. * @param serializationObject The object to serialize to
  36271. */
  36272. serialize(serializationObject: any): void;
  36273. /**
  36274. * Adds all the elements from the container to the scene
  36275. * @param container the container holding the elements
  36276. */
  36277. addFromContainer(container: AbstractScene): void;
  36278. /**
  36279. * Removes all the elements in the container from the scene
  36280. * @param container contains the elements to remove
  36281. * @param dispose if the removed element should be disposed (default: false)
  36282. */
  36283. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36284. /**
  36285. * Disposes the component and the associated ressources.
  36286. */
  36287. dispose(): void;
  36288. /**
  36289. * Disables audio in the associated scene.
  36290. */
  36291. disableAudio(): void;
  36292. /**
  36293. * Enables audio in the associated scene.
  36294. */
  36295. enableAudio(): void;
  36296. /**
  36297. * Switch audio to headphone output.
  36298. */
  36299. switchAudioModeForHeadphones(): void;
  36300. /**
  36301. * Switch audio to normal speakers.
  36302. */
  36303. switchAudioModeForNormalSpeakers(): void;
  36304. private _afterRender;
  36305. }
  36306. }
  36307. declare module "babylonjs/Audio/weightedsound" {
  36308. import { Sound } from "babylonjs/Audio/sound";
  36309. /**
  36310. * Wraps one or more Sound objects and selects one with random weight for playback.
  36311. */
  36312. export class WeightedSound {
  36313. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36314. loop: boolean;
  36315. private _coneInnerAngle;
  36316. private _coneOuterAngle;
  36317. private _volume;
  36318. /** A Sound is currently playing. */
  36319. isPlaying: boolean;
  36320. /** A Sound is currently paused. */
  36321. isPaused: boolean;
  36322. private _sounds;
  36323. private _weights;
  36324. private _currentIndex?;
  36325. /**
  36326. * Creates a new WeightedSound from the list of sounds given.
  36327. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36328. * @param sounds Array of Sounds that will be selected from.
  36329. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36330. */
  36331. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36332. /**
  36333. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36334. */
  36335. /**
  36336. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36337. */
  36338. directionalConeInnerAngle: number;
  36339. /**
  36340. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36341. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36342. */
  36343. /**
  36344. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36345. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36346. */
  36347. directionalConeOuterAngle: number;
  36348. /**
  36349. * Playback volume.
  36350. */
  36351. /**
  36352. * Playback volume.
  36353. */
  36354. volume: number;
  36355. private _onended;
  36356. /**
  36357. * Suspend playback
  36358. */
  36359. pause(): void;
  36360. /**
  36361. * Stop playback
  36362. */
  36363. stop(): void;
  36364. /**
  36365. * Start playback.
  36366. * @param startOffset Position the clip head at a specific time in seconds.
  36367. */
  36368. play(startOffset?: number): void;
  36369. }
  36370. }
  36371. declare module "babylonjs/Audio/index" {
  36372. export * from "babylonjs/Audio/analyser";
  36373. export * from "babylonjs/Audio/audioEngine";
  36374. export * from "babylonjs/Audio/audioSceneComponent";
  36375. export * from "babylonjs/Audio/sound";
  36376. export * from "babylonjs/Audio/soundTrack";
  36377. export * from "babylonjs/Audio/weightedsound";
  36378. }
  36379. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36380. import { Behavior } from "babylonjs/Behaviors/behavior";
  36381. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36382. import { BackEase } from "babylonjs/Animations/easing";
  36383. /**
  36384. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36385. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36386. */
  36387. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36388. /**
  36389. * Gets the name of the behavior.
  36390. */
  36391. readonly name: string;
  36392. /**
  36393. * The easing function used by animations
  36394. */
  36395. static EasingFunction: BackEase;
  36396. /**
  36397. * The easing mode used by animations
  36398. */
  36399. static EasingMode: number;
  36400. /**
  36401. * The duration of the animation, in milliseconds
  36402. */
  36403. transitionDuration: number;
  36404. /**
  36405. * Length of the distance animated by the transition when lower radius is reached
  36406. */
  36407. lowerRadiusTransitionRange: number;
  36408. /**
  36409. * Length of the distance animated by the transition when upper radius is reached
  36410. */
  36411. upperRadiusTransitionRange: number;
  36412. private _autoTransitionRange;
  36413. /**
  36414. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36415. */
  36416. /**
  36417. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36418. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36419. */
  36420. autoTransitionRange: boolean;
  36421. private _attachedCamera;
  36422. private _onAfterCheckInputsObserver;
  36423. private _onMeshTargetChangedObserver;
  36424. /**
  36425. * Initializes the behavior.
  36426. */
  36427. init(): void;
  36428. /**
  36429. * Attaches the behavior to its arc rotate camera.
  36430. * @param camera Defines the camera to attach the behavior to
  36431. */
  36432. attach(camera: ArcRotateCamera): void;
  36433. /**
  36434. * Detaches the behavior from its current arc rotate camera.
  36435. */
  36436. detach(): void;
  36437. private _radiusIsAnimating;
  36438. private _radiusBounceTransition;
  36439. private _animatables;
  36440. private _cachedWheelPrecision;
  36441. /**
  36442. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36443. * @param radiusLimit The limit to check against.
  36444. * @return Bool to indicate if at limit.
  36445. */
  36446. private _isRadiusAtLimit;
  36447. /**
  36448. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36449. * @param radiusDelta The delta by which to animate to. Can be negative.
  36450. */
  36451. private _applyBoundRadiusAnimation;
  36452. /**
  36453. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36454. */
  36455. protected _clearAnimationLocks(): void;
  36456. /**
  36457. * Stops and removes all animations that have been applied to the camera
  36458. */
  36459. stopAllAnimations(): void;
  36460. }
  36461. }
  36462. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36463. import { Behavior } from "babylonjs/Behaviors/behavior";
  36464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36465. import { ExponentialEase } from "babylonjs/Animations/easing";
  36466. import { Nullable } from "babylonjs/types";
  36467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36468. import { Vector3 } from "babylonjs/Maths/math.vector";
  36469. /**
  36470. * 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.
  36471. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36472. */
  36473. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36474. /**
  36475. * Gets the name of the behavior.
  36476. */
  36477. readonly name: string;
  36478. private _mode;
  36479. private _radiusScale;
  36480. private _positionScale;
  36481. private _defaultElevation;
  36482. private _elevationReturnTime;
  36483. private _elevationReturnWaitTime;
  36484. private _zoomStopsAnimation;
  36485. private _framingTime;
  36486. /**
  36487. * The easing function used by animations
  36488. */
  36489. static EasingFunction: ExponentialEase;
  36490. /**
  36491. * The easing mode used by animations
  36492. */
  36493. static EasingMode: number;
  36494. /**
  36495. * Sets the current mode used by the behavior
  36496. */
  36497. /**
  36498. * Gets current mode used by the behavior.
  36499. */
  36500. mode: number;
  36501. /**
  36502. * Sets the scale applied to the radius (1 by default)
  36503. */
  36504. /**
  36505. * Gets the scale applied to the radius
  36506. */
  36507. radiusScale: number;
  36508. /**
  36509. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36510. */
  36511. /**
  36512. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36513. */
  36514. positionScale: number;
  36515. /**
  36516. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36517. * behaviour is triggered, in radians.
  36518. */
  36519. /**
  36520. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36521. * behaviour is triggered, in radians.
  36522. */
  36523. defaultElevation: number;
  36524. /**
  36525. * Sets the time (in milliseconds) taken to return to the default beta position.
  36526. * Negative value indicates camera should not return to default.
  36527. */
  36528. /**
  36529. * Gets the time (in milliseconds) taken to return to the default beta position.
  36530. * Negative value indicates camera should not return to default.
  36531. */
  36532. elevationReturnTime: number;
  36533. /**
  36534. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36535. */
  36536. /**
  36537. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36538. */
  36539. elevationReturnWaitTime: number;
  36540. /**
  36541. * Sets the flag that indicates if user zooming should stop animation.
  36542. */
  36543. /**
  36544. * Gets the flag that indicates if user zooming should stop animation.
  36545. */
  36546. zoomStopsAnimation: boolean;
  36547. /**
  36548. * Sets the transition time when framing the mesh, in milliseconds
  36549. */
  36550. /**
  36551. * Gets the transition time when framing the mesh, in milliseconds
  36552. */
  36553. framingTime: number;
  36554. /**
  36555. * Define if the behavior should automatically change the configured
  36556. * camera limits and sensibilities.
  36557. */
  36558. autoCorrectCameraLimitsAndSensibility: boolean;
  36559. private _onPrePointerObservableObserver;
  36560. private _onAfterCheckInputsObserver;
  36561. private _onMeshTargetChangedObserver;
  36562. private _attachedCamera;
  36563. private _isPointerDown;
  36564. private _lastInteractionTime;
  36565. /**
  36566. * Initializes the behavior.
  36567. */
  36568. init(): void;
  36569. /**
  36570. * Attaches the behavior to its arc rotate camera.
  36571. * @param camera Defines the camera to attach the behavior to
  36572. */
  36573. attach(camera: ArcRotateCamera): void;
  36574. /**
  36575. * Detaches the behavior from its current arc rotate camera.
  36576. */
  36577. detach(): void;
  36578. private _animatables;
  36579. private _betaIsAnimating;
  36580. private _betaTransition;
  36581. private _radiusTransition;
  36582. private _vectorTransition;
  36583. /**
  36584. * Targets the given mesh and updates zoom level accordingly.
  36585. * @param mesh The mesh to target.
  36586. * @param radius Optional. If a cached radius position already exists, overrides default.
  36587. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36588. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36589. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36590. */
  36591. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36592. /**
  36593. * Targets the given mesh with its children and updates zoom level accordingly.
  36594. * @param mesh The mesh to target.
  36595. * @param radius Optional. If a cached radius position already exists, overrides default.
  36596. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36597. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36598. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36599. */
  36600. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36601. /**
  36602. * Targets the given meshes with their children and updates zoom level accordingly.
  36603. * @param meshes The mesh to target.
  36604. * @param radius Optional. If a cached radius position already exists, overrides default.
  36605. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36606. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36607. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36608. */
  36609. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36610. /**
  36611. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36612. * @param minimumWorld Determines the smaller position of the bounding box extend
  36613. * @param maximumWorld Determines the bigger position of the bounding box extend
  36614. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36615. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36616. */
  36617. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36618. /**
  36619. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36620. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36621. * frustum width.
  36622. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36623. * to fully enclose the mesh in the viewing frustum.
  36624. */
  36625. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36626. /**
  36627. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36628. * is automatically returned to its default position (expected to be above ground plane).
  36629. */
  36630. private _maintainCameraAboveGround;
  36631. /**
  36632. * Returns the frustum slope based on the canvas ratio and camera FOV
  36633. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36634. */
  36635. private _getFrustumSlope;
  36636. /**
  36637. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36638. */
  36639. private _clearAnimationLocks;
  36640. /**
  36641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36642. */
  36643. private _applyUserInteraction;
  36644. /**
  36645. * Stops and removes all animations that have been applied to the camera
  36646. */
  36647. stopAllAnimations(): void;
  36648. /**
  36649. * Gets a value indicating if the user is moving the camera
  36650. */
  36651. readonly isUserIsMoving: boolean;
  36652. /**
  36653. * The camera can move all the way towards the mesh.
  36654. */
  36655. static IgnoreBoundsSizeMode: number;
  36656. /**
  36657. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36658. */
  36659. static FitFrustumSidesMode: number;
  36660. }
  36661. }
  36662. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36663. import { Nullable } from "babylonjs/types";
  36664. import { Camera } from "babylonjs/Cameras/camera";
  36665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36666. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36667. /**
  36668. * Base class for Camera Pointer Inputs.
  36669. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36670. * for example usage.
  36671. */
  36672. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36673. /**
  36674. * Defines the camera the input is attached to.
  36675. */
  36676. abstract camera: Camera;
  36677. /**
  36678. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36679. */
  36680. protected _altKey: boolean;
  36681. protected _ctrlKey: boolean;
  36682. protected _metaKey: boolean;
  36683. protected _shiftKey: boolean;
  36684. /**
  36685. * Which mouse buttons were pressed at time of last mouse event.
  36686. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36687. */
  36688. protected _buttonsPressed: number;
  36689. /**
  36690. * Defines the buttons associated with the input to handle camera move.
  36691. */
  36692. buttons: number[];
  36693. /**
  36694. * Attach the input controls to a specific dom element to get the input from.
  36695. * @param element Defines the element the controls should be listened from
  36696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36697. */
  36698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36699. /**
  36700. * Detach the current controls from the specified dom element.
  36701. * @param element Defines the element to stop listening the inputs from
  36702. */
  36703. detachControl(element: Nullable<HTMLElement>): void;
  36704. /**
  36705. * Gets the class name of the current input.
  36706. * @returns the class name
  36707. */
  36708. getClassName(): string;
  36709. /**
  36710. * Get the friendly name associated with the input class.
  36711. * @returns the input friendly name
  36712. */
  36713. getSimpleName(): string;
  36714. /**
  36715. * Called on pointer POINTERDOUBLETAP event.
  36716. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36717. */
  36718. protected onDoubleTap(type: string): void;
  36719. /**
  36720. * Called on pointer POINTERMOVE event if only a single touch is active.
  36721. * Override this method to provide functionality.
  36722. */
  36723. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36724. /**
  36725. * Called on pointer POINTERMOVE event if multiple touches are active.
  36726. * Override this method to provide functionality.
  36727. */
  36728. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36729. /**
  36730. * Called on JS contextmenu event.
  36731. * Override this method to provide functionality.
  36732. */
  36733. protected onContextMenu(evt: PointerEvent): void;
  36734. /**
  36735. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36736. * press.
  36737. * Override this method to provide functionality.
  36738. */
  36739. protected onButtonDown(evt: PointerEvent): void;
  36740. /**
  36741. * Called each time a new POINTERUP event occurs. Ie, for each button
  36742. * release.
  36743. * Override this method to provide functionality.
  36744. */
  36745. protected onButtonUp(evt: PointerEvent): void;
  36746. /**
  36747. * Called when window becomes inactive.
  36748. * Override this method to provide functionality.
  36749. */
  36750. protected onLostFocus(): void;
  36751. private _pointerInput;
  36752. private _observer;
  36753. private _onLostFocus;
  36754. private pointA;
  36755. private pointB;
  36756. }
  36757. }
  36758. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36759. import { Nullable } from "babylonjs/types";
  36760. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36761. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36762. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36763. /**
  36764. * Manage the pointers inputs to control an arc rotate camera.
  36765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36766. */
  36767. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36768. /**
  36769. * Defines the camera the input is attached to.
  36770. */
  36771. camera: ArcRotateCamera;
  36772. /**
  36773. * Gets the class name of the current input.
  36774. * @returns the class name
  36775. */
  36776. getClassName(): string;
  36777. /**
  36778. * Defines the buttons associated with the input to handle camera move.
  36779. */
  36780. buttons: number[];
  36781. /**
  36782. * Defines the pointer angular sensibility along the X axis or how fast is
  36783. * the camera rotating.
  36784. */
  36785. angularSensibilityX: number;
  36786. /**
  36787. * Defines the pointer angular sensibility along the Y axis or how fast is
  36788. * the camera rotating.
  36789. */
  36790. angularSensibilityY: number;
  36791. /**
  36792. * Defines the pointer pinch precision or how fast is the camera zooming.
  36793. */
  36794. pinchPrecision: number;
  36795. /**
  36796. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36797. * from 0.
  36798. * It defines the percentage of current camera.radius to use as delta when
  36799. * pinch zoom is used.
  36800. */
  36801. pinchDeltaPercentage: number;
  36802. /**
  36803. * Defines the pointer panning sensibility or how fast is the camera moving.
  36804. */
  36805. panningSensibility: number;
  36806. /**
  36807. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36808. */
  36809. multiTouchPanning: boolean;
  36810. /**
  36811. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36812. * zoom (pinch) through multitouch.
  36813. */
  36814. multiTouchPanAndZoom: boolean;
  36815. /**
  36816. * Revers pinch action direction.
  36817. */
  36818. pinchInwards: boolean;
  36819. private _isPanClick;
  36820. private _twoFingerActivityCount;
  36821. private _isPinching;
  36822. /**
  36823. * Called on pointer POINTERMOVE event if only a single touch is active.
  36824. */
  36825. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36826. /**
  36827. * Called on pointer POINTERDOUBLETAP event.
  36828. */
  36829. protected onDoubleTap(type: string): void;
  36830. /**
  36831. * Called on pointer POINTERMOVE event if multiple touches are active.
  36832. */
  36833. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36834. /**
  36835. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36836. * press.
  36837. */
  36838. protected onButtonDown(evt: PointerEvent): void;
  36839. /**
  36840. * Called each time a new POINTERUP event occurs. Ie, for each button
  36841. * release.
  36842. */
  36843. protected onButtonUp(evt: PointerEvent): void;
  36844. /**
  36845. * Called when window becomes inactive.
  36846. */
  36847. protected onLostFocus(): void;
  36848. }
  36849. }
  36850. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36851. import { Nullable } from "babylonjs/types";
  36852. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36853. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36854. /**
  36855. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36857. */
  36858. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36859. /**
  36860. * Defines the camera the input is attached to.
  36861. */
  36862. camera: ArcRotateCamera;
  36863. /**
  36864. * Defines the list of key codes associated with the up action (increase alpha)
  36865. */
  36866. keysUp: number[];
  36867. /**
  36868. * Defines the list of key codes associated with the down action (decrease alpha)
  36869. */
  36870. keysDown: number[];
  36871. /**
  36872. * Defines the list of key codes associated with the left action (increase beta)
  36873. */
  36874. keysLeft: number[];
  36875. /**
  36876. * Defines the list of key codes associated with the right action (decrease beta)
  36877. */
  36878. keysRight: number[];
  36879. /**
  36880. * Defines the list of key codes associated with the reset action.
  36881. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36882. */
  36883. keysReset: number[];
  36884. /**
  36885. * Defines the panning sensibility of the inputs.
  36886. * (How fast is the camera paning)
  36887. */
  36888. panningSensibility: number;
  36889. /**
  36890. * Defines the zooming sensibility of the inputs.
  36891. * (How fast is the camera zooming)
  36892. */
  36893. zoomingSensibility: number;
  36894. /**
  36895. * Defines wether maintaining the alt key down switch the movement mode from
  36896. * orientation to zoom.
  36897. */
  36898. useAltToZoom: boolean;
  36899. /**
  36900. * Rotation speed of the camera
  36901. */
  36902. angularSpeed: number;
  36903. private _keys;
  36904. private _ctrlPressed;
  36905. private _altPressed;
  36906. private _onCanvasBlurObserver;
  36907. private _onKeyboardObserver;
  36908. private _engine;
  36909. private _scene;
  36910. /**
  36911. * Attach the input controls to a specific dom element to get the input from.
  36912. * @param element Defines the element the controls should be listened from
  36913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36914. */
  36915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36916. /**
  36917. * Detach the current controls from the specified dom element.
  36918. * @param element Defines the element to stop listening the inputs from
  36919. */
  36920. detachControl(element: Nullable<HTMLElement>): void;
  36921. /**
  36922. * Update the current camera state depending on the inputs that have been used this frame.
  36923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36924. */
  36925. checkInputs(): void;
  36926. /**
  36927. * Gets the class name of the current intput.
  36928. * @returns the class name
  36929. */
  36930. getClassName(): string;
  36931. /**
  36932. * Get the friendly name associated with the input class.
  36933. * @returns the input friendly name
  36934. */
  36935. getSimpleName(): string;
  36936. }
  36937. }
  36938. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36939. import { Nullable } from "babylonjs/types";
  36940. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36941. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36942. /**
  36943. * Manage the mouse wheel inputs to control an arc rotate camera.
  36944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36945. */
  36946. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36947. /**
  36948. * Defines the camera the input is attached to.
  36949. */
  36950. camera: ArcRotateCamera;
  36951. /**
  36952. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36953. */
  36954. wheelPrecision: number;
  36955. /**
  36956. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36957. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36958. */
  36959. wheelDeltaPercentage: number;
  36960. private _wheel;
  36961. private _observer;
  36962. private computeDeltaFromMouseWheelLegacyEvent;
  36963. /**
  36964. * Attach the input controls to a specific dom element to get the input from.
  36965. * @param element Defines the element the controls should be listened from
  36966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36967. */
  36968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36969. /**
  36970. * Detach the current controls from the specified dom element.
  36971. * @param element Defines the element to stop listening the inputs from
  36972. */
  36973. detachControl(element: Nullable<HTMLElement>): void;
  36974. /**
  36975. * Gets the class name of the current intput.
  36976. * @returns the class name
  36977. */
  36978. getClassName(): string;
  36979. /**
  36980. * Get the friendly name associated with the input class.
  36981. * @returns the input friendly name
  36982. */
  36983. getSimpleName(): string;
  36984. }
  36985. }
  36986. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36987. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36988. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36989. /**
  36990. * Default Inputs manager for the ArcRotateCamera.
  36991. * It groups all the default supported inputs for ease of use.
  36992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36993. */
  36994. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36995. /**
  36996. * Instantiates a new ArcRotateCameraInputsManager.
  36997. * @param camera Defines the camera the inputs belong to
  36998. */
  36999. constructor(camera: ArcRotateCamera);
  37000. /**
  37001. * Add mouse wheel input support to the input manager.
  37002. * @returns the current input manager
  37003. */
  37004. addMouseWheel(): ArcRotateCameraInputsManager;
  37005. /**
  37006. * Add pointers input support to the input manager.
  37007. * @returns the current input manager
  37008. */
  37009. addPointers(): ArcRotateCameraInputsManager;
  37010. /**
  37011. * Add keyboard input support to the input manager.
  37012. * @returns the current input manager
  37013. */
  37014. addKeyboard(): ArcRotateCameraInputsManager;
  37015. }
  37016. }
  37017. declare module "babylonjs/Cameras/arcRotateCamera" {
  37018. import { Observable } from "babylonjs/Misc/observable";
  37019. import { Nullable } from "babylonjs/types";
  37020. import { Scene } from "babylonjs/scene";
  37021. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37023. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37024. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37025. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37026. import { Camera } from "babylonjs/Cameras/camera";
  37027. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37028. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37029. import { Collider } from "babylonjs/Collisions/collider";
  37030. /**
  37031. * This represents an orbital type of camera.
  37032. *
  37033. * 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.
  37034. * 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.
  37035. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37036. */
  37037. export class ArcRotateCamera extends TargetCamera {
  37038. /**
  37039. * Defines the rotation angle of the camera along the longitudinal axis.
  37040. */
  37041. alpha: number;
  37042. /**
  37043. * Defines the rotation angle of the camera along the latitudinal axis.
  37044. */
  37045. beta: number;
  37046. /**
  37047. * Defines the radius of the camera from it s target point.
  37048. */
  37049. radius: number;
  37050. protected _target: Vector3;
  37051. protected _targetHost: Nullable<AbstractMesh>;
  37052. /**
  37053. * Defines the target point of the camera.
  37054. * The camera looks towards it form the radius distance.
  37055. */
  37056. target: Vector3;
  37057. /**
  37058. * Define the current local position of the camera in the scene
  37059. */
  37060. position: Vector3;
  37061. protected _upVector: Vector3;
  37062. protected _upToYMatrix: Matrix;
  37063. protected _YToUpMatrix: Matrix;
  37064. /**
  37065. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37066. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37067. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37068. */
  37069. upVector: Vector3;
  37070. /**
  37071. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37072. */
  37073. setMatUp(): void;
  37074. /**
  37075. * Current inertia value on the longitudinal axis.
  37076. * The bigger this number the longer it will take for the camera to stop.
  37077. */
  37078. inertialAlphaOffset: number;
  37079. /**
  37080. * Current inertia value on the latitudinal axis.
  37081. * The bigger this number the longer it will take for the camera to stop.
  37082. */
  37083. inertialBetaOffset: number;
  37084. /**
  37085. * Current inertia value on the radius axis.
  37086. * The bigger this number the longer it will take for the camera to stop.
  37087. */
  37088. inertialRadiusOffset: number;
  37089. /**
  37090. * Minimum allowed angle on the longitudinal axis.
  37091. * This can help limiting how the Camera is able to move in the scene.
  37092. */
  37093. lowerAlphaLimit: Nullable<number>;
  37094. /**
  37095. * Maximum allowed angle on the longitudinal axis.
  37096. * This can help limiting how the Camera is able to move in the scene.
  37097. */
  37098. upperAlphaLimit: Nullable<number>;
  37099. /**
  37100. * Minimum allowed angle on the latitudinal axis.
  37101. * This can help limiting how the Camera is able to move in the scene.
  37102. */
  37103. lowerBetaLimit: number;
  37104. /**
  37105. * Maximum allowed angle on the latitudinal axis.
  37106. * This can help limiting how the Camera is able to move in the scene.
  37107. */
  37108. upperBetaLimit: number;
  37109. /**
  37110. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37111. * This can help limiting how the Camera is able to move in the scene.
  37112. */
  37113. lowerRadiusLimit: Nullable<number>;
  37114. /**
  37115. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37116. * This can help limiting how the Camera is able to move in the scene.
  37117. */
  37118. upperRadiusLimit: Nullable<number>;
  37119. /**
  37120. * Defines the current inertia value used during panning of the camera along the X axis.
  37121. */
  37122. inertialPanningX: number;
  37123. /**
  37124. * Defines the current inertia value used during panning of the camera along the Y axis.
  37125. */
  37126. inertialPanningY: number;
  37127. /**
  37128. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37129. * Basically if your fingers moves away from more than this distance you will be considered
  37130. * in pinch mode.
  37131. */
  37132. pinchToPanMaxDistance: number;
  37133. /**
  37134. * Defines the maximum distance the camera can pan.
  37135. * This could help keeping the cammera always in your scene.
  37136. */
  37137. panningDistanceLimit: Nullable<number>;
  37138. /**
  37139. * Defines the target of the camera before paning.
  37140. */
  37141. panningOriginTarget: Vector3;
  37142. /**
  37143. * Defines the value of the inertia used during panning.
  37144. * 0 would mean stop inertia and one would mean no decelleration at all.
  37145. */
  37146. panningInertia: number;
  37147. /**
  37148. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37149. */
  37150. angularSensibilityX: number;
  37151. /**
  37152. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37153. */
  37154. angularSensibilityY: number;
  37155. /**
  37156. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37157. */
  37158. pinchPrecision: number;
  37159. /**
  37160. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37161. * It will be used instead of pinchDeltaPrecision if different from 0.
  37162. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37163. */
  37164. pinchDeltaPercentage: number;
  37165. /**
  37166. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37167. */
  37168. panningSensibility: number;
  37169. /**
  37170. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37171. */
  37172. keysUp: number[];
  37173. /**
  37174. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37175. */
  37176. keysDown: number[];
  37177. /**
  37178. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37179. */
  37180. keysLeft: number[];
  37181. /**
  37182. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37183. */
  37184. keysRight: number[];
  37185. /**
  37186. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37187. */
  37188. wheelPrecision: number;
  37189. /**
  37190. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37191. * It will be used instead of pinchDeltaPrecision if different from 0.
  37192. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37193. */
  37194. wheelDeltaPercentage: number;
  37195. /**
  37196. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37197. */
  37198. zoomOnFactor: number;
  37199. /**
  37200. * Defines a screen offset for the camera position.
  37201. */
  37202. targetScreenOffset: Vector2;
  37203. /**
  37204. * Allows the camera to be completely reversed.
  37205. * If false the camera can not arrive upside down.
  37206. */
  37207. allowUpsideDown: boolean;
  37208. /**
  37209. * Define if double tap/click is used to restore the previously saved state of the camera.
  37210. */
  37211. useInputToRestoreState: boolean;
  37212. /** @hidden */
  37213. _viewMatrix: Matrix;
  37214. /** @hidden */
  37215. _useCtrlForPanning: boolean;
  37216. /** @hidden */
  37217. _panningMouseButton: number;
  37218. /**
  37219. * Defines the input associated to the camera.
  37220. */
  37221. inputs: ArcRotateCameraInputsManager;
  37222. /** @hidden */
  37223. _reset: () => void;
  37224. /**
  37225. * Defines the allowed panning axis.
  37226. */
  37227. panningAxis: Vector3;
  37228. protected _localDirection: Vector3;
  37229. protected _transformedDirection: Vector3;
  37230. private _bouncingBehavior;
  37231. /**
  37232. * Gets the bouncing behavior of the camera if it has been enabled.
  37233. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37234. */
  37235. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37236. /**
  37237. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37239. */
  37240. useBouncingBehavior: boolean;
  37241. private _framingBehavior;
  37242. /**
  37243. * Gets the framing behavior of the camera if it has been enabled.
  37244. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37245. */
  37246. readonly framingBehavior: Nullable<FramingBehavior>;
  37247. /**
  37248. * Defines if the framing behavior of the camera is enabled on the camera.
  37249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37250. */
  37251. useFramingBehavior: boolean;
  37252. private _autoRotationBehavior;
  37253. /**
  37254. * Gets the auto rotation behavior of the camera if it has been enabled.
  37255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37256. */
  37257. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37258. /**
  37259. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37261. */
  37262. useAutoRotationBehavior: boolean;
  37263. /**
  37264. * Observable triggered when the mesh target has been changed on the camera.
  37265. */
  37266. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37267. /**
  37268. * Event raised when the camera is colliding with a mesh.
  37269. */
  37270. onCollide: (collidedMesh: AbstractMesh) => void;
  37271. /**
  37272. * Defines whether the camera should check collision with the objects oh the scene.
  37273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37274. */
  37275. checkCollisions: boolean;
  37276. /**
  37277. * Defines the collision radius of the camera.
  37278. * This simulates a sphere around the camera.
  37279. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37280. */
  37281. collisionRadius: Vector3;
  37282. protected _collider: Collider;
  37283. protected _previousPosition: Vector3;
  37284. protected _collisionVelocity: Vector3;
  37285. protected _newPosition: Vector3;
  37286. protected _previousAlpha: number;
  37287. protected _previousBeta: number;
  37288. protected _previousRadius: number;
  37289. protected _collisionTriggered: boolean;
  37290. protected _targetBoundingCenter: Nullable<Vector3>;
  37291. private _computationVector;
  37292. /**
  37293. * Instantiates a new ArcRotateCamera in a given scene
  37294. * @param name Defines the name of the camera
  37295. * @param alpha Defines the camera rotation along the logitudinal axis
  37296. * @param beta Defines the camera rotation along the latitudinal axis
  37297. * @param radius Defines the camera distance from its target
  37298. * @param target Defines the camera target
  37299. * @param scene Defines the scene the camera belongs to
  37300. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37301. */
  37302. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37303. /** @hidden */
  37304. _initCache(): void;
  37305. /** @hidden */
  37306. _updateCache(ignoreParentClass?: boolean): void;
  37307. protected _getTargetPosition(): Vector3;
  37308. private _storedAlpha;
  37309. private _storedBeta;
  37310. private _storedRadius;
  37311. private _storedTarget;
  37312. /**
  37313. * Stores the current state of the camera (alpha, beta, radius and target)
  37314. * @returns the camera itself
  37315. */
  37316. storeState(): Camera;
  37317. /**
  37318. * @hidden
  37319. * Restored camera state. You must call storeState() first
  37320. */
  37321. _restoreStateValues(): boolean;
  37322. /** @hidden */
  37323. _isSynchronizedViewMatrix(): boolean;
  37324. /**
  37325. * Attached controls to the current camera.
  37326. * @param element Defines the element the controls should be listened from
  37327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37328. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37329. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37330. */
  37331. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37332. /**
  37333. * Detach the current controls from the camera.
  37334. * The camera will stop reacting to inputs.
  37335. * @param element Defines the element to stop listening the inputs from
  37336. */
  37337. detachControl(element: HTMLElement): void;
  37338. /** @hidden */
  37339. _checkInputs(): void;
  37340. protected _checkLimits(): void;
  37341. /**
  37342. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37343. */
  37344. rebuildAnglesAndRadius(): void;
  37345. /**
  37346. * Use a position to define the current camera related information like aplha, beta and radius
  37347. * @param position Defines the position to set the camera at
  37348. */
  37349. setPosition(position: Vector3): void;
  37350. /**
  37351. * Defines the target the camera should look at.
  37352. * This will automatically adapt alpha beta and radius to fit within the new target.
  37353. * @param target Defines the new target as a Vector or a mesh
  37354. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37355. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37356. */
  37357. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37358. /** @hidden */
  37359. _getViewMatrix(): Matrix;
  37360. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37361. /**
  37362. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37363. * @param meshes Defines the mesh to zoom on
  37364. * @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)
  37365. */
  37366. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37367. /**
  37368. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37369. * The target will be changed but the radius
  37370. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37371. * @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)
  37372. */
  37373. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37374. min: Vector3;
  37375. max: Vector3;
  37376. distance: number;
  37377. }, doNotUpdateMaxZ?: boolean): void;
  37378. /**
  37379. * @override
  37380. * Override Camera.createRigCamera
  37381. */
  37382. createRigCamera(name: string, cameraIndex: number): Camera;
  37383. /**
  37384. * @hidden
  37385. * @override
  37386. * Override Camera._updateRigCameras
  37387. */
  37388. _updateRigCameras(): void;
  37389. /**
  37390. * Destroy the camera and release the current resources hold by it.
  37391. */
  37392. dispose(): void;
  37393. /**
  37394. * Gets the current object class name.
  37395. * @return the class name
  37396. */
  37397. getClassName(): string;
  37398. }
  37399. }
  37400. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37401. import { Behavior } from "babylonjs/Behaviors/behavior";
  37402. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37403. /**
  37404. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37406. */
  37407. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37408. /**
  37409. * Gets the name of the behavior.
  37410. */
  37411. readonly name: string;
  37412. private _zoomStopsAnimation;
  37413. private _idleRotationSpeed;
  37414. private _idleRotationWaitTime;
  37415. private _idleRotationSpinupTime;
  37416. /**
  37417. * Sets the flag that indicates if user zooming should stop animation.
  37418. */
  37419. /**
  37420. * Gets the flag that indicates if user zooming should stop animation.
  37421. */
  37422. zoomStopsAnimation: boolean;
  37423. /**
  37424. * Sets the default speed at which the camera rotates around the model.
  37425. */
  37426. /**
  37427. * Gets the default speed at which the camera rotates around the model.
  37428. */
  37429. idleRotationSpeed: number;
  37430. /**
  37431. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37432. */
  37433. /**
  37434. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37435. */
  37436. idleRotationWaitTime: number;
  37437. /**
  37438. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37439. */
  37440. /**
  37441. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37442. */
  37443. idleRotationSpinupTime: number;
  37444. /**
  37445. * Gets a value indicating if the camera is currently rotating because of this behavior
  37446. */
  37447. readonly rotationInProgress: boolean;
  37448. private _onPrePointerObservableObserver;
  37449. private _onAfterCheckInputsObserver;
  37450. private _attachedCamera;
  37451. private _isPointerDown;
  37452. private _lastFrameTime;
  37453. private _lastInteractionTime;
  37454. private _cameraRotationSpeed;
  37455. /**
  37456. * Initializes the behavior.
  37457. */
  37458. init(): void;
  37459. /**
  37460. * Attaches the behavior to its arc rotate camera.
  37461. * @param camera Defines the camera to attach the behavior to
  37462. */
  37463. attach(camera: ArcRotateCamera): void;
  37464. /**
  37465. * Detaches the behavior from its current arc rotate camera.
  37466. */
  37467. detach(): void;
  37468. /**
  37469. * Returns true if user is scrolling.
  37470. * @return true if user is scrolling.
  37471. */
  37472. private _userIsZooming;
  37473. private _lastFrameRadius;
  37474. private _shouldAnimationStopForInteraction;
  37475. /**
  37476. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37477. */
  37478. private _applyUserInteraction;
  37479. private _userIsMoving;
  37480. }
  37481. }
  37482. declare module "babylonjs/Behaviors/Cameras/index" {
  37483. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37484. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37485. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37486. }
  37487. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37488. import { Mesh } from "babylonjs/Meshes/mesh";
  37489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37490. import { Behavior } from "babylonjs/Behaviors/behavior";
  37491. /**
  37492. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37493. */
  37494. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37495. private ui;
  37496. /**
  37497. * The name of the behavior
  37498. */
  37499. name: string;
  37500. /**
  37501. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37502. */
  37503. distanceAwayFromFace: number;
  37504. /**
  37505. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37506. */
  37507. distanceAwayFromBottomOfFace: number;
  37508. private _faceVectors;
  37509. private _target;
  37510. private _scene;
  37511. private _onRenderObserver;
  37512. private _tmpMatrix;
  37513. private _tmpVector;
  37514. /**
  37515. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37516. * @param ui The transform node that should be attched to the mesh
  37517. */
  37518. constructor(ui: TransformNode);
  37519. /**
  37520. * Initializes the behavior
  37521. */
  37522. init(): void;
  37523. private _closestFace;
  37524. private _zeroVector;
  37525. private _lookAtTmpMatrix;
  37526. private _lookAtToRef;
  37527. /**
  37528. * Attaches the AttachToBoxBehavior to the passed in mesh
  37529. * @param target The mesh that the specified node will be attached to
  37530. */
  37531. attach(target: Mesh): void;
  37532. /**
  37533. * Detaches the behavior from the mesh
  37534. */
  37535. detach(): void;
  37536. }
  37537. }
  37538. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37539. import { Behavior } from "babylonjs/Behaviors/behavior";
  37540. import { Mesh } from "babylonjs/Meshes/mesh";
  37541. /**
  37542. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37543. */
  37544. export class FadeInOutBehavior implements Behavior<Mesh> {
  37545. /**
  37546. * Time in milliseconds to delay before fading in (Default: 0)
  37547. */
  37548. delay: number;
  37549. /**
  37550. * Time in milliseconds for the mesh to fade in (Default: 300)
  37551. */
  37552. fadeInTime: number;
  37553. private _millisecondsPerFrame;
  37554. private _hovered;
  37555. private _hoverValue;
  37556. private _ownerNode;
  37557. /**
  37558. * Instatiates the FadeInOutBehavior
  37559. */
  37560. constructor();
  37561. /**
  37562. * The name of the behavior
  37563. */
  37564. readonly name: string;
  37565. /**
  37566. * Initializes the behavior
  37567. */
  37568. init(): void;
  37569. /**
  37570. * Attaches the fade behavior on the passed in mesh
  37571. * @param ownerNode The mesh that will be faded in/out once attached
  37572. */
  37573. attach(ownerNode: Mesh): void;
  37574. /**
  37575. * Detaches the behavior from the mesh
  37576. */
  37577. detach(): void;
  37578. /**
  37579. * Triggers the mesh to begin fading in or out
  37580. * @param value if the object should fade in or out (true to fade in)
  37581. */
  37582. fadeIn(value: boolean): void;
  37583. private _update;
  37584. private _setAllVisibility;
  37585. }
  37586. }
  37587. declare module "babylonjs/Misc/pivotTools" {
  37588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37589. /**
  37590. * Class containing a set of static utilities functions for managing Pivots
  37591. * @hidden
  37592. */
  37593. export class PivotTools {
  37594. private static _PivotCached;
  37595. private static _OldPivotPoint;
  37596. private static _PivotTranslation;
  37597. private static _PivotTmpVector;
  37598. /** @hidden */
  37599. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37600. /** @hidden */
  37601. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37602. }
  37603. }
  37604. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37605. import { Scene } from "babylonjs/scene";
  37606. import { Vector4 } from "babylonjs/Maths/math.vector";
  37607. import { Mesh } from "babylonjs/Meshes/mesh";
  37608. import { Nullable } from "babylonjs/types";
  37609. import { Plane } from "babylonjs/Maths/math.plane";
  37610. /**
  37611. * Class containing static functions to help procedurally build meshes
  37612. */
  37613. export class PlaneBuilder {
  37614. /**
  37615. * Creates a plane mesh
  37616. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37617. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37618. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37622. * @param name defines the name of the mesh
  37623. * @param options defines the options used to create the mesh
  37624. * @param scene defines the hosting scene
  37625. * @returns the plane mesh
  37626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37627. */
  37628. static CreatePlane(name: string, options: {
  37629. size?: number;
  37630. width?: number;
  37631. height?: number;
  37632. sideOrientation?: number;
  37633. frontUVs?: Vector4;
  37634. backUVs?: Vector4;
  37635. updatable?: boolean;
  37636. sourcePlane?: Plane;
  37637. }, scene?: Nullable<Scene>): Mesh;
  37638. }
  37639. }
  37640. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37641. import { Behavior } from "babylonjs/Behaviors/behavior";
  37642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37643. import { Observable } from "babylonjs/Misc/observable";
  37644. import { Vector3 } from "babylonjs/Maths/math.vector";
  37645. import { Ray } from "babylonjs/Culling/ray";
  37646. import "babylonjs/Meshes/Builders/planeBuilder";
  37647. /**
  37648. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37649. */
  37650. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37651. private static _AnyMouseID;
  37652. /**
  37653. * Abstract mesh the behavior is set on
  37654. */
  37655. attachedNode: AbstractMesh;
  37656. private _dragPlane;
  37657. private _scene;
  37658. private _pointerObserver;
  37659. private _beforeRenderObserver;
  37660. private static _planeScene;
  37661. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37662. /**
  37663. * 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)
  37664. */
  37665. maxDragAngle: number;
  37666. /**
  37667. * @hidden
  37668. */
  37669. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37670. /**
  37671. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37672. */
  37673. currentDraggingPointerID: number;
  37674. /**
  37675. * The last position where the pointer hit the drag plane in world space
  37676. */
  37677. lastDragPosition: Vector3;
  37678. /**
  37679. * If the behavior is currently in a dragging state
  37680. */
  37681. dragging: boolean;
  37682. /**
  37683. * 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)
  37684. */
  37685. dragDeltaRatio: number;
  37686. /**
  37687. * If the drag plane orientation should be updated during the dragging (Default: true)
  37688. */
  37689. updateDragPlane: boolean;
  37690. private _debugMode;
  37691. private _moving;
  37692. /**
  37693. * Fires each time the attached mesh is dragged with the pointer
  37694. * * delta between last drag position and current drag position in world space
  37695. * * dragDistance along the drag axis
  37696. * * dragPlaneNormal normal of the current drag plane used during the drag
  37697. * * dragPlanePoint in world space where the drag intersects the drag plane
  37698. */
  37699. onDragObservable: Observable<{
  37700. delta: Vector3;
  37701. dragPlanePoint: Vector3;
  37702. dragPlaneNormal: Vector3;
  37703. dragDistance: number;
  37704. pointerId: number;
  37705. }>;
  37706. /**
  37707. * Fires each time a drag begins (eg. mouse down on mesh)
  37708. */
  37709. onDragStartObservable: Observable<{
  37710. dragPlanePoint: Vector3;
  37711. pointerId: number;
  37712. }>;
  37713. /**
  37714. * Fires each time a drag ends (eg. mouse release after drag)
  37715. */
  37716. onDragEndObservable: Observable<{
  37717. dragPlanePoint: Vector3;
  37718. pointerId: number;
  37719. }>;
  37720. /**
  37721. * If the attached mesh should be moved when dragged
  37722. */
  37723. moveAttached: boolean;
  37724. /**
  37725. * If the drag behavior will react to drag events (Default: true)
  37726. */
  37727. enabled: boolean;
  37728. /**
  37729. * If pointer events should start and release the drag (Default: true)
  37730. */
  37731. startAndReleaseDragOnPointerEvents: boolean;
  37732. /**
  37733. * If camera controls should be detached during the drag
  37734. */
  37735. detachCameraControls: boolean;
  37736. /**
  37737. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37738. */
  37739. useObjectOrienationForDragging: boolean;
  37740. private _options;
  37741. /**
  37742. * Creates a pointer drag behavior that can be attached to a mesh
  37743. * @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)
  37744. */
  37745. constructor(options?: {
  37746. dragAxis?: Vector3;
  37747. dragPlaneNormal?: Vector3;
  37748. });
  37749. /**
  37750. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37751. */
  37752. validateDrag: (targetPosition: Vector3) => boolean;
  37753. /**
  37754. * The name of the behavior
  37755. */
  37756. readonly name: string;
  37757. /**
  37758. * Initializes the behavior
  37759. */
  37760. init(): void;
  37761. private _tmpVector;
  37762. private _alternatePickedPoint;
  37763. private _worldDragAxis;
  37764. private _targetPosition;
  37765. private _attachedElement;
  37766. /**
  37767. * Attaches the drag behavior the passed in mesh
  37768. * @param ownerNode The mesh that will be dragged around once attached
  37769. */
  37770. attach(ownerNode: AbstractMesh): void;
  37771. /**
  37772. * Force relase the drag action by code.
  37773. */
  37774. releaseDrag(): void;
  37775. private _startDragRay;
  37776. private _lastPointerRay;
  37777. /**
  37778. * Simulates the start of a pointer drag event on the behavior
  37779. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37780. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37781. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37782. */
  37783. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37784. private _startDrag;
  37785. private _dragDelta;
  37786. private _moveDrag;
  37787. private _pickWithRayOnDragPlane;
  37788. private _pointA;
  37789. private _pointB;
  37790. private _pointC;
  37791. private _lineA;
  37792. private _lineB;
  37793. private _localAxis;
  37794. private _lookAt;
  37795. private _updateDragPlanePosition;
  37796. /**
  37797. * Detaches the behavior from the mesh
  37798. */
  37799. detach(): void;
  37800. }
  37801. }
  37802. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37803. import { Mesh } from "babylonjs/Meshes/mesh";
  37804. import { Behavior } from "babylonjs/Behaviors/behavior";
  37805. /**
  37806. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37807. */
  37808. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37809. private _dragBehaviorA;
  37810. private _dragBehaviorB;
  37811. private _startDistance;
  37812. private _initialScale;
  37813. private _targetScale;
  37814. private _ownerNode;
  37815. private _sceneRenderObserver;
  37816. /**
  37817. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37818. */
  37819. constructor();
  37820. /**
  37821. * The name of the behavior
  37822. */
  37823. readonly name: string;
  37824. /**
  37825. * Initializes the behavior
  37826. */
  37827. init(): void;
  37828. private _getCurrentDistance;
  37829. /**
  37830. * Attaches the scale behavior the passed in mesh
  37831. * @param ownerNode The mesh that will be scaled around once attached
  37832. */
  37833. attach(ownerNode: Mesh): void;
  37834. /**
  37835. * Detaches the behavior from the mesh
  37836. */
  37837. detach(): void;
  37838. }
  37839. }
  37840. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37841. import { Behavior } from "babylonjs/Behaviors/behavior";
  37842. import { Mesh } from "babylonjs/Meshes/mesh";
  37843. import { Observable } from "babylonjs/Misc/observable";
  37844. /**
  37845. * 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
  37846. */
  37847. export class SixDofDragBehavior implements Behavior<Mesh> {
  37848. private static _virtualScene;
  37849. private _ownerNode;
  37850. private _sceneRenderObserver;
  37851. private _scene;
  37852. private _targetPosition;
  37853. private _virtualOriginMesh;
  37854. private _virtualDragMesh;
  37855. private _pointerObserver;
  37856. private _moving;
  37857. private _startingOrientation;
  37858. /**
  37859. * 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)
  37860. */
  37861. private zDragFactor;
  37862. /**
  37863. * If the object should rotate to face the drag origin
  37864. */
  37865. rotateDraggedObject: boolean;
  37866. /**
  37867. * If the behavior is currently in a dragging state
  37868. */
  37869. dragging: boolean;
  37870. /**
  37871. * 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)
  37872. */
  37873. dragDeltaRatio: number;
  37874. /**
  37875. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37876. */
  37877. currentDraggingPointerID: number;
  37878. /**
  37879. * If camera controls should be detached during the drag
  37880. */
  37881. detachCameraControls: boolean;
  37882. /**
  37883. * Fires each time a drag starts
  37884. */
  37885. onDragStartObservable: Observable<{}>;
  37886. /**
  37887. * Fires each time a drag ends (eg. mouse release after drag)
  37888. */
  37889. onDragEndObservable: Observable<{}>;
  37890. /**
  37891. * 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
  37892. */
  37893. constructor();
  37894. /**
  37895. * The name of the behavior
  37896. */
  37897. readonly name: string;
  37898. /**
  37899. * Initializes the behavior
  37900. */
  37901. init(): void;
  37902. /**
  37903. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37904. */
  37905. private readonly _pointerCamera;
  37906. /**
  37907. * Attaches the scale behavior the passed in mesh
  37908. * @param ownerNode The mesh that will be scaled around once attached
  37909. */
  37910. attach(ownerNode: Mesh): void;
  37911. /**
  37912. * Detaches the behavior from the mesh
  37913. */
  37914. detach(): void;
  37915. }
  37916. }
  37917. declare module "babylonjs/Behaviors/Meshes/index" {
  37918. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37919. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37920. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37921. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37922. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37923. }
  37924. declare module "babylonjs/Behaviors/index" {
  37925. export * from "babylonjs/Behaviors/behavior";
  37926. export * from "babylonjs/Behaviors/Cameras/index";
  37927. export * from "babylonjs/Behaviors/Meshes/index";
  37928. }
  37929. declare module "babylonjs/Bones/boneIKController" {
  37930. import { Bone } from "babylonjs/Bones/bone";
  37931. import { Vector3 } from "babylonjs/Maths/math.vector";
  37932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37933. import { Nullable } from "babylonjs/types";
  37934. /**
  37935. * Class used to apply inverse kinematics to bones
  37936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37937. */
  37938. export class BoneIKController {
  37939. private static _tmpVecs;
  37940. private static _tmpQuat;
  37941. private static _tmpMats;
  37942. /**
  37943. * Gets or sets the target mesh
  37944. */
  37945. targetMesh: AbstractMesh;
  37946. /** Gets or sets the mesh used as pole */
  37947. poleTargetMesh: AbstractMesh;
  37948. /**
  37949. * Gets or sets the bone used as pole
  37950. */
  37951. poleTargetBone: Nullable<Bone>;
  37952. /**
  37953. * Gets or sets the target position
  37954. */
  37955. targetPosition: Vector3;
  37956. /**
  37957. * Gets or sets the pole target position
  37958. */
  37959. poleTargetPosition: Vector3;
  37960. /**
  37961. * Gets or sets the pole target local offset
  37962. */
  37963. poleTargetLocalOffset: Vector3;
  37964. /**
  37965. * Gets or sets the pole angle
  37966. */
  37967. poleAngle: number;
  37968. /**
  37969. * Gets or sets the mesh associated with the controller
  37970. */
  37971. mesh: AbstractMesh;
  37972. /**
  37973. * 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)
  37974. */
  37975. slerpAmount: number;
  37976. private _bone1Quat;
  37977. private _bone1Mat;
  37978. private _bone2Ang;
  37979. private _bone1;
  37980. private _bone2;
  37981. private _bone1Length;
  37982. private _bone2Length;
  37983. private _maxAngle;
  37984. private _maxReach;
  37985. private _rightHandedSystem;
  37986. private _bendAxis;
  37987. private _slerping;
  37988. private _adjustRoll;
  37989. /**
  37990. * Gets or sets maximum allowed angle
  37991. */
  37992. maxAngle: number;
  37993. /**
  37994. * Creates a new BoneIKController
  37995. * @param mesh defines the mesh to control
  37996. * @param bone defines the bone to control
  37997. * @param options defines options to set up the controller
  37998. */
  37999. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38000. targetMesh?: AbstractMesh;
  38001. poleTargetMesh?: AbstractMesh;
  38002. poleTargetBone?: Bone;
  38003. poleTargetLocalOffset?: Vector3;
  38004. poleAngle?: number;
  38005. bendAxis?: Vector3;
  38006. maxAngle?: number;
  38007. slerpAmount?: number;
  38008. });
  38009. private _setMaxAngle;
  38010. /**
  38011. * Force the controller to update the bones
  38012. */
  38013. update(): void;
  38014. }
  38015. }
  38016. declare module "babylonjs/Bones/boneLookController" {
  38017. import { Vector3 } from "babylonjs/Maths/math.vector";
  38018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38019. import { Bone } from "babylonjs/Bones/bone";
  38020. import { Space } from "babylonjs/Maths/math.axis";
  38021. /**
  38022. * Class used to make a bone look toward a point in space
  38023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38024. */
  38025. export class BoneLookController {
  38026. private static _tmpVecs;
  38027. private static _tmpQuat;
  38028. private static _tmpMats;
  38029. /**
  38030. * The target Vector3 that the bone will look at
  38031. */
  38032. target: Vector3;
  38033. /**
  38034. * The mesh that the bone is attached to
  38035. */
  38036. mesh: AbstractMesh;
  38037. /**
  38038. * The bone that will be looking to the target
  38039. */
  38040. bone: Bone;
  38041. /**
  38042. * The up axis of the coordinate system that is used when the bone is rotated
  38043. */
  38044. upAxis: Vector3;
  38045. /**
  38046. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38047. */
  38048. upAxisSpace: Space;
  38049. /**
  38050. * Used to make an adjustment to the yaw of the bone
  38051. */
  38052. adjustYaw: number;
  38053. /**
  38054. * Used to make an adjustment to the pitch of the bone
  38055. */
  38056. adjustPitch: number;
  38057. /**
  38058. * Used to make an adjustment to the roll of the bone
  38059. */
  38060. adjustRoll: number;
  38061. /**
  38062. * 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)
  38063. */
  38064. slerpAmount: number;
  38065. private _minYaw;
  38066. private _maxYaw;
  38067. private _minPitch;
  38068. private _maxPitch;
  38069. private _minYawSin;
  38070. private _minYawCos;
  38071. private _maxYawSin;
  38072. private _maxYawCos;
  38073. private _midYawConstraint;
  38074. private _minPitchTan;
  38075. private _maxPitchTan;
  38076. private _boneQuat;
  38077. private _slerping;
  38078. private _transformYawPitch;
  38079. private _transformYawPitchInv;
  38080. private _firstFrameSkipped;
  38081. private _yawRange;
  38082. private _fowardAxis;
  38083. /**
  38084. * Gets or sets the minimum yaw angle that the bone can look to
  38085. */
  38086. minYaw: number;
  38087. /**
  38088. * Gets or sets the maximum yaw angle that the bone can look to
  38089. */
  38090. maxYaw: number;
  38091. /**
  38092. * Gets or sets the minimum pitch angle that the bone can look to
  38093. */
  38094. minPitch: number;
  38095. /**
  38096. * Gets or sets the maximum pitch angle that the bone can look to
  38097. */
  38098. maxPitch: number;
  38099. /**
  38100. * Create a BoneLookController
  38101. * @param mesh the mesh that the bone belongs to
  38102. * @param bone the bone that will be looking to the target
  38103. * @param target the target Vector3 to look at
  38104. * @param options optional settings:
  38105. * * maxYaw: the maximum angle the bone will yaw to
  38106. * * minYaw: the minimum angle the bone will yaw to
  38107. * * maxPitch: the maximum angle the bone will pitch to
  38108. * * minPitch: the minimum angle the bone will yaw to
  38109. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38110. * * upAxis: the up axis of the coordinate system
  38111. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38112. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38113. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38114. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38115. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38116. * * adjustRoll: used to make an adjustment to the roll of the bone
  38117. **/
  38118. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38119. maxYaw?: number;
  38120. minYaw?: number;
  38121. maxPitch?: number;
  38122. minPitch?: number;
  38123. slerpAmount?: number;
  38124. upAxis?: Vector3;
  38125. upAxisSpace?: Space;
  38126. yawAxis?: Vector3;
  38127. pitchAxis?: Vector3;
  38128. adjustYaw?: number;
  38129. adjustPitch?: number;
  38130. adjustRoll?: number;
  38131. });
  38132. /**
  38133. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38134. */
  38135. update(): void;
  38136. private _getAngleDiff;
  38137. private _getAngleBetween;
  38138. private _isAngleBetween;
  38139. }
  38140. }
  38141. declare module "babylonjs/Bones/index" {
  38142. export * from "babylonjs/Bones/bone";
  38143. export * from "babylonjs/Bones/boneIKController";
  38144. export * from "babylonjs/Bones/boneLookController";
  38145. export * from "babylonjs/Bones/skeleton";
  38146. }
  38147. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38148. import { Nullable } from "babylonjs/types";
  38149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38150. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38151. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38152. /**
  38153. * Manage the gamepad inputs to control an arc rotate camera.
  38154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38155. */
  38156. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38157. /**
  38158. * Defines the camera the input is attached to.
  38159. */
  38160. camera: ArcRotateCamera;
  38161. /**
  38162. * Defines the gamepad the input is gathering event from.
  38163. */
  38164. gamepad: Nullable<Gamepad>;
  38165. /**
  38166. * Defines the gamepad rotation sensiblity.
  38167. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38168. */
  38169. gamepadRotationSensibility: number;
  38170. /**
  38171. * Defines the gamepad move sensiblity.
  38172. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38173. */
  38174. gamepadMoveSensibility: number;
  38175. private _onGamepadConnectedObserver;
  38176. private _onGamepadDisconnectedObserver;
  38177. /**
  38178. * Attach the input controls to a specific dom element to get the input from.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. */
  38182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38183. /**
  38184. * Detach the current controls from the specified dom element.
  38185. * @param element Defines the element to stop listening the inputs from
  38186. */
  38187. detachControl(element: Nullable<HTMLElement>): void;
  38188. /**
  38189. * Update the current camera state depending on the inputs that have been used this frame.
  38190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38191. */
  38192. checkInputs(): void;
  38193. /**
  38194. * Gets the class name of the current intput.
  38195. * @returns the class name
  38196. */
  38197. getClassName(): string;
  38198. /**
  38199. * Get the friendly name associated with the input class.
  38200. * @returns the input friendly name
  38201. */
  38202. getSimpleName(): string;
  38203. }
  38204. }
  38205. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38206. import { Nullable } from "babylonjs/types";
  38207. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38209. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38210. interface ArcRotateCameraInputsManager {
  38211. /**
  38212. * Add orientation input support to the input manager.
  38213. * @returns the current input manager
  38214. */
  38215. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38216. }
  38217. }
  38218. /**
  38219. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38221. */
  38222. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38223. /**
  38224. * Defines the camera the input is attached to.
  38225. */
  38226. camera: ArcRotateCamera;
  38227. /**
  38228. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38229. */
  38230. alphaCorrection: number;
  38231. /**
  38232. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38233. */
  38234. gammaCorrection: number;
  38235. private _alpha;
  38236. private _gamma;
  38237. private _dirty;
  38238. private _deviceOrientationHandler;
  38239. /**
  38240. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38241. */
  38242. constructor();
  38243. /**
  38244. * Attach the input controls to a specific dom element to get the input from.
  38245. * @param element Defines the element the controls should be listened from
  38246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38247. */
  38248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38249. /** @hidden */
  38250. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38251. /**
  38252. * Update the current camera state depending on the inputs that have been used this frame.
  38253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38254. */
  38255. checkInputs(): void;
  38256. /**
  38257. * Detach the current controls from the specified dom element.
  38258. * @param element Defines the element to stop listening the inputs from
  38259. */
  38260. detachControl(element: Nullable<HTMLElement>): void;
  38261. /**
  38262. * Gets the class name of the current intput.
  38263. * @returns the class name
  38264. */
  38265. getClassName(): string;
  38266. /**
  38267. * Get the friendly name associated with the input class.
  38268. * @returns the input friendly name
  38269. */
  38270. getSimpleName(): string;
  38271. }
  38272. }
  38273. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38274. import { Nullable } from "babylonjs/types";
  38275. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38276. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38277. /**
  38278. * Listen to mouse events to control the camera.
  38279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38280. */
  38281. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38282. /**
  38283. * Defines the camera the input is attached to.
  38284. */
  38285. camera: FlyCamera;
  38286. /**
  38287. * Defines if touch is enabled. (Default is true.)
  38288. */
  38289. touchEnabled: boolean;
  38290. /**
  38291. * Defines the buttons associated with the input to handle camera rotation.
  38292. */
  38293. buttons: number[];
  38294. /**
  38295. * Assign buttons for Yaw control.
  38296. */
  38297. buttonsYaw: number[];
  38298. /**
  38299. * Assign buttons for Pitch control.
  38300. */
  38301. buttonsPitch: number[];
  38302. /**
  38303. * Assign buttons for Roll control.
  38304. */
  38305. buttonsRoll: number[];
  38306. /**
  38307. * Detect if any button is being pressed while mouse is moved.
  38308. * -1 = Mouse locked.
  38309. * 0 = Left button.
  38310. * 1 = Middle Button.
  38311. * 2 = Right Button.
  38312. */
  38313. activeButton: number;
  38314. /**
  38315. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38316. * Higher values reduce its sensitivity.
  38317. */
  38318. angularSensibility: number;
  38319. private _mousemoveCallback;
  38320. private _observer;
  38321. private _rollObserver;
  38322. private previousPosition;
  38323. private noPreventDefault;
  38324. private element;
  38325. /**
  38326. * Listen to mouse events to control the camera.
  38327. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38329. */
  38330. constructor(touchEnabled?: boolean);
  38331. /**
  38332. * Attach the mouse control to the HTML DOM element.
  38333. * @param element Defines the element that listens to the input events.
  38334. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38335. */
  38336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38337. /**
  38338. * Detach the current controls from the specified dom element.
  38339. * @param element Defines the element to stop listening the inputs from
  38340. */
  38341. detachControl(element: Nullable<HTMLElement>): void;
  38342. /**
  38343. * Gets the class name of the current input.
  38344. * @returns the class name.
  38345. */
  38346. getClassName(): string;
  38347. /**
  38348. * Get the friendly name associated with the input class.
  38349. * @returns the input's friendly name.
  38350. */
  38351. getSimpleName(): string;
  38352. private _pointerInput;
  38353. private _onMouseMove;
  38354. /**
  38355. * Rotate camera by mouse offset.
  38356. */
  38357. private rotateCamera;
  38358. }
  38359. }
  38360. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38361. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38362. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38363. /**
  38364. * Default Inputs manager for the FlyCamera.
  38365. * It groups all the default supported inputs for ease of use.
  38366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38367. */
  38368. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38369. /**
  38370. * Instantiates a new FlyCameraInputsManager.
  38371. * @param camera Defines the camera the inputs belong to.
  38372. */
  38373. constructor(camera: FlyCamera);
  38374. /**
  38375. * Add keyboard input support to the input manager.
  38376. * @returns the new FlyCameraKeyboardMoveInput().
  38377. */
  38378. addKeyboard(): FlyCameraInputsManager;
  38379. /**
  38380. * Add mouse input support to the input manager.
  38381. * @param touchEnabled Enable touch screen support.
  38382. * @returns the new FlyCameraMouseInput().
  38383. */
  38384. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38385. }
  38386. }
  38387. declare module "babylonjs/Cameras/flyCamera" {
  38388. import { Scene } from "babylonjs/scene";
  38389. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38391. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38392. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38393. /**
  38394. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38395. * such as in a 3D Space Shooter or a Flight Simulator.
  38396. */
  38397. export class FlyCamera extends TargetCamera {
  38398. /**
  38399. * Define the collision ellipsoid of the camera.
  38400. * This is helpful for simulating a camera body, like a player's body.
  38401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38402. */
  38403. ellipsoid: Vector3;
  38404. /**
  38405. * Define an offset for the position of the ellipsoid around the camera.
  38406. * This can be helpful if the camera is attached away from the player's body center,
  38407. * such as at its head.
  38408. */
  38409. ellipsoidOffset: Vector3;
  38410. /**
  38411. * Enable or disable collisions of the camera with the rest of the scene objects.
  38412. */
  38413. checkCollisions: boolean;
  38414. /**
  38415. * Enable or disable gravity on the camera.
  38416. */
  38417. applyGravity: boolean;
  38418. /**
  38419. * Define the current direction the camera is moving to.
  38420. */
  38421. cameraDirection: Vector3;
  38422. /**
  38423. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38424. * This overrides and empties cameraRotation.
  38425. */
  38426. rotationQuaternion: Quaternion;
  38427. /**
  38428. * Track Roll to maintain the wanted Rolling when looking around.
  38429. */
  38430. _trackRoll: number;
  38431. /**
  38432. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38433. */
  38434. rollCorrect: number;
  38435. /**
  38436. * Mimic a banked turn, Rolling the camera when Yawing.
  38437. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38438. */
  38439. bankedTurn: boolean;
  38440. /**
  38441. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38442. */
  38443. bankedTurnLimit: number;
  38444. /**
  38445. * Value of 0 disables the banked Roll.
  38446. * Value of 1 is equal to the Yaw angle in radians.
  38447. */
  38448. bankedTurnMultiplier: number;
  38449. /**
  38450. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38451. */
  38452. inputs: FlyCameraInputsManager;
  38453. /**
  38454. * Gets the input sensibility for mouse input.
  38455. * Higher values reduce sensitivity.
  38456. */
  38457. /**
  38458. * Sets the input sensibility for a mouse input.
  38459. * Higher values reduce sensitivity.
  38460. */
  38461. angularSensibility: number;
  38462. /**
  38463. * Get the keys for camera movement forward.
  38464. */
  38465. /**
  38466. * Set the keys for camera movement forward.
  38467. */
  38468. keysForward: number[];
  38469. /**
  38470. * Get the keys for camera movement backward.
  38471. */
  38472. keysBackward: number[];
  38473. /**
  38474. * Get the keys for camera movement up.
  38475. */
  38476. /**
  38477. * Set the keys for camera movement up.
  38478. */
  38479. keysUp: number[];
  38480. /**
  38481. * Get the keys for camera movement down.
  38482. */
  38483. /**
  38484. * Set the keys for camera movement down.
  38485. */
  38486. keysDown: number[];
  38487. /**
  38488. * Get the keys for camera movement left.
  38489. */
  38490. /**
  38491. * Set the keys for camera movement left.
  38492. */
  38493. keysLeft: number[];
  38494. /**
  38495. * Set the keys for camera movement right.
  38496. */
  38497. /**
  38498. * Set the keys for camera movement right.
  38499. */
  38500. keysRight: number[];
  38501. /**
  38502. * Event raised when the camera collides with a mesh in the scene.
  38503. */
  38504. onCollide: (collidedMesh: AbstractMesh) => void;
  38505. private _collider;
  38506. private _needMoveForGravity;
  38507. private _oldPosition;
  38508. private _diffPosition;
  38509. private _newPosition;
  38510. /** @hidden */
  38511. _localDirection: Vector3;
  38512. /** @hidden */
  38513. _transformedDirection: Vector3;
  38514. /**
  38515. * Instantiates a FlyCamera.
  38516. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38517. * such as in a 3D Space Shooter or a Flight Simulator.
  38518. * @param name Define the name of the camera in the scene.
  38519. * @param position Define the starting position of the camera in the scene.
  38520. * @param scene Define the scene the camera belongs to.
  38521. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38522. */
  38523. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38524. /**
  38525. * Attach a control to the HTML DOM element.
  38526. * @param element Defines the element that listens to the input events.
  38527. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38528. */
  38529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38530. /**
  38531. * Detach a control from the HTML DOM element.
  38532. * The camera will stop reacting to that input.
  38533. * @param element Defines the element that listens to the input events.
  38534. */
  38535. detachControl(element: HTMLElement): void;
  38536. private _collisionMask;
  38537. /**
  38538. * Get the mask that the camera ignores in collision events.
  38539. */
  38540. /**
  38541. * Set the mask that the camera ignores in collision events.
  38542. */
  38543. collisionMask: number;
  38544. /** @hidden */
  38545. _collideWithWorld(displacement: Vector3): void;
  38546. /** @hidden */
  38547. private _onCollisionPositionChange;
  38548. /** @hidden */
  38549. _checkInputs(): void;
  38550. /** @hidden */
  38551. _decideIfNeedsToMove(): boolean;
  38552. /** @hidden */
  38553. _updatePosition(): void;
  38554. /**
  38555. * Restore the Roll to its target value at the rate specified.
  38556. * @param rate - Higher means slower restoring.
  38557. * @hidden
  38558. */
  38559. restoreRoll(rate: number): void;
  38560. /**
  38561. * Destroy the camera and release the current resources held by it.
  38562. */
  38563. dispose(): void;
  38564. /**
  38565. * Get the current object class name.
  38566. * @returns the class name.
  38567. */
  38568. getClassName(): string;
  38569. }
  38570. }
  38571. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38572. import { Nullable } from "babylonjs/types";
  38573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38574. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38575. /**
  38576. * Listen to keyboard events to control the camera.
  38577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38578. */
  38579. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38580. /**
  38581. * Defines the camera the input is attached to.
  38582. */
  38583. camera: FlyCamera;
  38584. /**
  38585. * The list of keyboard keys used to control the forward move of the camera.
  38586. */
  38587. keysForward: number[];
  38588. /**
  38589. * The list of keyboard keys used to control the backward move of the camera.
  38590. */
  38591. keysBackward: number[];
  38592. /**
  38593. * The list of keyboard keys used to control the forward move of the camera.
  38594. */
  38595. keysUp: number[];
  38596. /**
  38597. * The list of keyboard keys used to control the backward move of the camera.
  38598. */
  38599. keysDown: number[];
  38600. /**
  38601. * The list of keyboard keys used to control the right strafe move of the camera.
  38602. */
  38603. keysRight: number[];
  38604. /**
  38605. * The list of keyboard keys used to control the left strafe move of the camera.
  38606. */
  38607. keysLeft: number[];
  38608. private _keys;
  38609. private _onCanvasBlurObserver;
  38610. private _onKeyboardObserver;
  38611. private _engine;
  38612. private _scene;
  38613. /**
  38614. * Attach the input controls to a specific dom element to get the input from.
  38615. * @param element Defines the element the controls should be listened from
  38616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38617. */
  38618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38619. /**
  38620. * Detach the current controls from the specified dom element.
  38621. * @param element Defines the element to stop listening the inputs from
  38622. */
  38623. detachControl(element: Nullable<HTMLElement>): void;
  38624. /**
  38625. * Gets the class name of the current intput.
  38626. * @returns the class name
  38627. */
  38628. getClassName(): string;
  38629. /** @hidden */
  38630. _onLostFocus(e: FocusEvent): void;
  38631. /**
  38632. * Get the friendly name associated with the input class.
  38633. * @returns the input friendly name
  38634. */
  38635. getSimpleName(): string;
  38636. /**
  38637. * Update the current camera state depending on the inputs that have been used this frame.
  38638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38639. */
  38640. checkInputs(): void;
  38641. }
  38642. }
  38643. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38644. import { Nullable } from "babylonjs/types";
  38645. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38646. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38647. /**
  38648. * Manage the mouse wheel inputs to control a follow camera.
  38649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38650. */
  38651. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38652. /**
  38653. * Defines the camera the input is attached to.
  38654. */
  38655. camera: FollowCamera;
  38656. /**
  38657. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38658. */
  38659. axisControlRadius: boolean;
  38660. /**
  38661. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38662. */
  38663. axisControlHeight: boolean;
  38664. /**
  38665. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38666. */
  38667. axisControlRotation: boolean;
  38668. /**
  38669. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38670. * relation to mouseWheel events.
  38671. */
  38672. wheelPrecision: number;
  38673. /**
  38674. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38675. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38676. */
  38677. wheelDeltaPercentage: number;
  38678. private _wheel;
  38679. private _observer;
  38680. /**
  38681. * Attach the input controls to a specific dom element to get the input from.
  38682. * @param element Defines the element the controls should be listened from
  38683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38684. */
  38685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38686. /**
  38687. * Detach the current controls from the specified dom element.
  38688. * @param element Defines the element to stop listening the inputs from
  38689. */
  38690. detachControl(element: Nullable<HTMLElement>): void;
  38691. /**
  38692. * Gets the class name of the current intput.
  38693. * @returns the class name
  38694. */
  38695. getClassName(): string;
  38696. /**
  38697. * Get the friendly name associated with the input class.
  38698. * @returns the input friendly name
  38699. */
  38700. getSimpleName(): string;
  38701. }
  38702. }
  38703. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38704. import { Nullable } from "babylonjs/types";
  38705. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38706. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38707. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38708. /**
  38709. * Manage the pointers inputs to control an follow camera.
  38710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38711. */
  38712. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38713. /**
  38714. * Defines the camera the input is attached to.
  38715. */
  38716. camera: FollowCamera;
  38717. /**
  38718. * Gets the class name of the current input.
  38719. * @returns the class name
  38720. */
  38721. getClassName(): string;
  38722. /**
  38723. * Defines the pointer angular sensibility along the X axis or how fast is
  38724. * the camera rotating.
  38725. * A negative number will reverse the axis direction.
  38726. */
  38727. angularSensibilityX: number;
  38728. /**
  38729. * Defines the pointer angular sensibility along the Y axis or how fast is
  38730. * the camera rotating.
  38731. * A negative number will reverse the axis direction.
  38732. */
  38733. angularSensibilityY: number;
  38734. /**
  38735. * Defines the pointer pinch precision or how fast is the camera zooming.
  38736. * A negative number will reverse the axis direction.
  38737. */
  38738. pinchPrecision: number;
  38739. /**
  38740. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38741. * from 0.
  38742. * It defines the percentage of current camera.radius to use as delta when
  38743. * pinch zoom is used.
  38744. */
  38745. pinchDeltaPercentage: number;
  38746. /**
  38747. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38748. */
  38749. axisXControlRadius: boolean;
  38750. /**
  38751. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38752. */
  38753. axisXControlHeight: boolean;
  38754. /**
  38755. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38756. */
  38757. axisXControlRotation: boolean;
  38758. /**
  38759. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38760. */
  38761. axisYControlRadius: boolean;
  38762. /**
  38763. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38764. */
  38765. axisYControlHeight: boolean;
  38766. /**
  38767. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38768. */
  38769. axisYControlRotation: boolean;
  38770. /**
  38771. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38772. */
  38773. axisPinchControlRadius: boolean;
  38774. /**
  38775. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38776. */
  38777. axisPinchControlHeight: boolean;
  38778. /**
  38779. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38780. */
  38781. axisPinchControlRotation: boolean;
  38782. /**
  38783. * Log error messages if basic misconfiguration has occurred.
  38784. */
  38785. warningEnable: boolean;
  38786. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38787. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38788. private _warningCounter;
  38789. private _warning;
  38790. }
  38791. }
  38792. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38793. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38794. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38795. /**
  38796. * Default Inputs manager for the FollowCamera.
  38797. * It groups all the default supported inputs for ease of use.
  38798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38799. */
  38800. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38801. /**
  38802. * Instantiates a new FollowCameraInputsManager.
  38803. * @param camera Defines the camera the inputs belong to
  38804. */
  38805. constructor(camera: FollowCamera);
  38806. /**
  38807. * Add keyboard input support to the input manager.
  38808. * @returns the current input manager
  38809. */
  38810. addKeyboard(): FollowCameraInputsManager;
  38811. /**
  38812. * Add mouse wheel input support to the input manager.
  38813. * @returns the current input manager
  38814. */
  38815. addMouseWheel(): FollowCameraInputsManager;
  38816. /**
  38817. * Add pointers input support to the input manager.
  38818. * @returns the current input manager
  38819. */
  38820. addPointers(): FollowCameraInputsManager;
  38821. /**
  38822. * Add orientation input support to the input manager.
  38823. * @returns the current input manager
  38824. */
  38825. addVRDeviceOrientation(): FollowCameraInputsManager;
  38826. }
  38827. }
  38828. declare module "babylonjs/Cameras/followCamera" {
  38829. import { Nullable } from "babylonjs/types";
  38830. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { Vector3 } from "babylonjs/Maths/math.vector";
  38833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38834. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38835. /**
  38836. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38837. * an arc rotate version arcFollowCamera are available.
  38838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38839. */
  38840. export class FollowCamera extends TargetCamera {
  38841. /**
  38842. * Distance the follow camera should follow an object at
  38843. */
  38844. radius: number;
  38845. /**
  38846. * Minimum allowed distance of the camera to the axis of rotation
  38847. * (The camera can not get closer).
  38848. * This can help limiting how the Camera is able to move in the scene.
  38849. */
  38850. lowerRadiusLimit: Nullable<number>;
  38851. /**
  38852. * Maximum allowed distance of the camera to the axis of rotation
  38853. * (The camera can not get further).
  38854. * This can help limiting how the Camera is able to move in the scene.
  38855. */
  38856. upperRadiusLimit: Nullable<number>;
  38857. /**
  38858. * Define a rotation offset between the camera and the object it follows
  38859. */
  38860. rotationOffset: number;
  38861. /**
  38862. * Minimum allowed angle to camera position relative to target object.
  38863. * This can help limiting how the Camera is able to move in the scene.
  38864. */
  38865. lowerRotationOffsetLimit: Nullable<number>;
  38866. /**
  38867. * Maximum allowed angle to camera position relative to target object.
  38868. * This can help limiting how the Camera is able to move in the scene.
  38869. */
  38870. upperRotationOffsetLimit: Nullable<number>;
  38871. /**
  38872. * Define a height offset between the camera and the object it follows.
  38873. * It can help following an object from the top (like a car chaing a plane)
  38874. */
  38875. heightOffset: number;
  38876. /**
  38877. * Minimum allowed height of camera position relative to target object.
  38878. * This can help limiting how the Camera is able to move in the scene.
  38879. */
  38880. lowerHeightOffsetLimit: Nullable<number>;
  38881. /**
  38882. * Maximum allowed height of camera position relative to target object.
  38883. * This can help limiting how the Camera is able to move in the scene.
  38884. */
  38885. upperHeightOffsetLimit: Nullable<number>;
  38886. /**
  38887. * Define how fast the camera can accelerate to follow it s target.
  38888. */
  38889. cameraAcceleration: number;
  38890. /**
  38891. * Define the speed limit of the camera following an object.
  38892. */
  38893. maxCameraSpeed: number;
  38894. /**
  38895. * Define the target of the camera.
  38896. */
  38897. lockedTarget: Nullable<AbstractMesh>;
  38898. /**
  38899. * Defines the input associated with the camera.
  38900. */
  38901. inputs: FollowCameraInputsManager;
  38902. /**
  38903. * Instantiates the follow camera.
  38904. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38905. * @param name Define the name of the camera in the scene
  38906. * @param position Define the position of the camera
  38907. * @param scene Define the scene the camera belong to
  38908. * @param lockedTarget Define the target of the camera
  38909. */
  38910. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38911. private _follow;
  38912. /**
  38913. * Attached controls to the current camera.
  38914. * @param element Defines the element the controls should be listened from
  38915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38916. */
  38917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38918. /**
  38919. * Detach the current controls from the camera.
  38920. * The camera will stop reacting to inputs.
  38921. * @param element Defines the element to stop listening the inputs from
  38922. */
  38923. detachControl(element: HTMLElement): void;
  38924. /** @hidden */
  38925. _checkInputs(): void;
  38926. private _checkLimits;
  38927. /**
  38928. * Gets the camera class name.
  38929. * @returns the class name
  38930. */
  38931. getClassName(): string;
  38932. }
  38933. /**
  38934. * Arc Rotate version of the follow camera.
  38935. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38936. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38937. */
  38938. export class ArcFollowCamera extends TargetCamera {
  38939. /** The longitudinal angle of the camera */
  38940. alpha: number;
  38941. /** The latitudinal angle of the camera */
  38942. beta: number;
  38943. /** The radius of the camera from its target */
  38944. radius: number;
  38945. /** Define the camera target (the messh it should follow) */
  38946. target: Nullable<AbstractMesh>;
  38947. private _cartesianCoordinates;
  38948. /**
  38949. * Instantiates a new ArcFollowCamera
  38950. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38951. * @param name Define the name of the camera
  38952. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38953. * @param beta Define the rotation angle of the camera around the elevation axis
  38954. * @param radius Define the radius of the camera from its target point
  38955. * @param target Define the target of the camera
  38956. * @param scene Define the scene the camera belongs to
  38957. */
  38958. constructor(name: string,
  38959. /** The longitudinal angle of the camera */
  38960. alpha: number,
  38961. /** The latitudinal angle of the camera */
  38962. beta: number,
  38963. /** The radius of the camera from its target */
  38964. radius: number,
  38965. /** Define the camera target (the messh it should follow) */
  38966. target: Nullable<AbstractMesh>, scene: Scene);
  38967. private _follow;
  38968. /** @hidden */
  38969. _checkInputs(): void;
  38970. /**
  38971. * Returns the class name of the object.
  38972. * It is mostly used internally for serialization purposes.
  38973. */
  38974. getClassName(): string;
  38975. }
  38976. }
  38977. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38978. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38979. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38980. import { Nullable } from "babylonjs/types";
  38981. /**
  38982. * Manage the keyboard inputs to control the movement of a follow camera.
  38983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38984. */
  38985. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38986. /**
  38987. * Defines the camera the input is attached to.
  38988. */
  38989. camera: FollowCamera;
  38990. /**
  38991. * Defines the list of key codes associated with the up action (increase heightOffset)
  38992. */
  38993. keysHeightOffsetIncr: number[];
  38994. /**
  38995. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38996. */
  38997. keysHeightOffsetDecr: number[];
  38998. /**
  38999. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39000. */
  39001. keysHeightOffsetModifierAlt: boolean;
  39002. /**
  39003. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39004. */
  39005. keysHeightOffsetModifierCtrl: boolean;
  39006. /**
  39007. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39008. */
  39009. keysHeightOffsetModifierShift: boolean;
  39010. /**
  39011. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39012. */
  39013. keysRotationOffsetIncr: number[];
  39014. /**
  39015. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39016. */
  39017. keysRotationOffsetDecr: number[];
  39018. /**
  39019. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39020. */
  39021. keysRotationOffsetModifierAlt: boolean;
  39022. /**
  39023. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39024. */
  39025. keysRotationOffsetModifierCtrl: boolean;
  39026. /**
  39027. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39028. */
  39029. keysRotationOffsetModifierShift: boolean;
  39030. /**
  39031. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39032. */
  39033. keysRadiusIncr: number[];
  39034. /**
  39035. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39036. */
  39037. keysRadiusDecr: number[];
  39038. /**
  39039. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39040. */
  39041. keysRadiusModifierAlt: boolean;
  39042. /**
  39043. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39044. */
  39045. keysRadiusModifierCtrl: boolean;
  39046. /**
  39047. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39048. */
  39049. keysRadiusModifierShift: boolean;
  39050. /**
  39051. * Defines the rate of change of heightOffset.
  39052. */
  39053. heightSensibility: number;
  39054. /**
  39055. * Defines the rate of change of rotationOffset.
  39056. */
  39057. rotationSensibility: number;
  39058. /**
  39059. * Defines the rate of change of radius.
  39060. */
  39061. radiusSensibility: number;
  39062. private _keys;
  39063. private _ctrlPressed;
  39064. private _altPressed;
  39065. private _shiftPressed;
  39066. private _onCanvasBlurObserver;
  39067. private _onKeyboardObserver;
  39068. private _engine;
  39069. private _scene;
  39070. /**
  39071. * Attach the input controls to a specific dom element to get the input from.
  39072. * @param element Defines the element the controls should be listened from
  39073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39074. */
  39075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39076. /**
  39077. * Detach the current controls from the specified dom element.
  39078. * @param element Defines the element to stop listening the inputs from
  39079. */
  39080. detachControl(element: Nullable<HTMLElement>): void;
  39081. /**
  39082. * Update the current camera state depending on the inputs that have been used this frame.
  39083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39084. */
  39085. checkInputs(): void;
  39086. /**
  39087. * Gets the class name of the current input.
  39088. * @returns the class name
  39089. */
  39090. getClassName(): string;
  39091. /**
  39092. * Get the friendly name associated with the input class.
  39093. * @returns the input friendly name
  39094. */
  39095. getSimpleName(): string;
  39096. /**
  39097. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39098. * allow modification of the heightOffset value.
  39099. */
  39100. private _modifierHeightOffset;
  39101. /**
  39102. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39103. * allow modification of the rotationOffset value.
  39104. */
  39105. private _modifierRotationOffset;
  39106. /**
  39107. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39108. * allow modification of the radius value.
  39109. */
  39110. private _modifierRadius;
  39111. }
  39112. }
  39113. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39114. import { Nullable } from "babylonjs/types";
  39115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39116. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39117. import { Observable } from "babylonjs/Misc/observable";
  39118. module "babylonjs/Cameras/freeCameraInputsManager" {
  39119. interface FreeCameraInputsManager {
  39120. /**
  39121. * @hidden
  39122. */
  39123. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39124. /**
  39125. * Add orientation input support to the input manager.
  39126. * @returns the current input manager
  39127. */
  39128. addDeviceOrientation(): FreeCameraInputsManager;
  39129. }
  39130. }
  39131. /**
  39132. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39133. * Screen rotation is taken into account.
  39134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39135. */
  39136. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39137. private _camera;
  39138. private _screenOrientationAngle;
  39139. private _constantTranform;
  39140. private _screenQuaternion;
  39141. private _alpha;
  39142. private _beta;
  39143. private _gamma;
  39144. /**
  39145. * Can be used to detect if a device orientation sensor is availible on a device
  39146. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39147. * @returns a promise that will resolve on orientation change
  39148. */
  39149. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39150. /**
  39151. * @hidden
  39152. */
  39153. _onDeviceOrientationChangedObservable: Observable<void>;
  39154. /**
  39155. * Instantiates a new input
  39156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39157. */
  39158. constructor();
  39159. /**
  39160. * Define the camera controlled by the input.
  39161. */
  39162. camera: FreeCamera;
  39163. /**
  39164. * Attach the input controls to a specific dom element to get the input from.
  39165. * @param element Defines the element the controls should be listened from
  39166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39167. */
  39168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39169. private _orientationChanged;
  39170. private _deviceOrientation;
  39171. /**
  39172. * Detach the current controls from the specified dom element.
  39173. * @param element Defines the element to stop listening the inputs from
  39174. */
  39175. detachControl(element: Nullable<HTMLElement>): void;
  39176. /**
  39177. * Update the current camera state depending on the inputs that have been used this frame.
  39178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39179. */
  39180. checkInputs(): void;
  39181. /**
  39182. * Gets the class name of the current intput.
  39183. * @returns the class name
  39184. */
  39185. getClassName(): string;
  39186. /**
  39187. * Get the friendly name associated with the input class.
  39188. * @returns the input friendly name
  39189. */
  39190. getSimpleName(): string;
  39191. }
  39192. }
  39193. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39194. import { Nullable } from "babylonjs/types";
  39195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39197. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39198. /**
  39199. * Manage the gamepad inputs to control a free camera.
  39200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39201. */
  39202. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39203. /**
  39204. * Define the camera the input is attached to.
  39205. */
  39206. camera: FreeCamera;
  39207. /**
  39208. * Define the Gamepad controlling the input
  39209. */
  39210. gamepad: Nullable<Gamepad>;
  39211. /**
  39212. * Defines the gamepad rotation sensiblity.
  39213. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39214. */
  39215. gamepadAngularSensibility: number;
  39216. /**
  39217. * Defines the gamepad move sensiblity.
  39218. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39219. */
  39220. gamepadMoveSensibility: number;
  39221. private _onGamepadConnectedObserver;
  39222. private _onGamepadDisconnectedObserver;
  39223. private _cameraTransform;
  39224. private _deltaTransform;
  39225. private _vector3;
  39226. private _vector2;
  39227. /**
  39228. * Attach the input controls to a specific dom element to get the input from.
  39229. * @param element Defines the element the controls should be listened from
  39230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39231. */
  39232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39233. /**
  39234. * Detach the current controls from the specified dom element.
  39235. * @param element Defines the element to stop listening the inputs from
  39236. */
  39237. detachControl(element: Nullable<HTMLElement>): void;
  39238. /**
  39239. * Update the current camera state depending on the inputs that have been used this frame.
  39240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39241. */
  39242. checkInputs(): void;
  39243. /**
  39244. * Gets the class name of the current intput.
  39245. * @returns the class name
  39246. */
  39247. getClassName(): string;
  39248. /**
  39249. * Get the friendly name associated with the input class.
  39250. * @returns the input friendly name
  39251. */
  39252. getSimpleName(): string;
  39253. }
  39254. }
  39255. declare module "babylonjs/Misc/virtualJoystick" {
  39256. import { Nullable } from "babylonjs/types";
  39257. import { Vector3 } from "babylonjs/Maths/math.vector";
  39258. /**
  39259. * Defines the potential axis of a Joystick
  39260. */
  39261. export enum JoystickAxis {
  39262. /** X axis */
  39263. X = 0,
  39264. /** Y axis */
  39265. Y = 1,
  39266. /** Z axis */
  39267. Z = 2
  39268. }
  39269. /**
  39270. * Class used to define virtual joystick (used in touch mode)
  39271. */
  39272. export class VirtualJoystick {
  39273. /**
  39274. * Gets or sets a boolean indicating that left and right values must be inverted
  39275. */
  39276. reverseLeftRight: boolean;
  39277. /**
  39278. * Gets or sets a boolean indicating that up and down values must be inverted
  39279. */
  39280. reverseUpDown: boolean;
  39281. /**
  39282. * Gets the offset value for the position (ie. the change of the position value)
  39283. */
  39284. deltaPosition: Vector3;
  39285. /**
  39286. * Gets a boolean indicating if the virtual joystick was pressed
  39287. */
  39288. pressed: boolean;
  39289. /**
  39290. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39291. */
  39292. static Canvas: Nullable<HTMLCanvasElement>;
  39293. private static _globalJoystickIndex;
  39294. private static vjCanvasContext;
  39295. private static vjCanvasWidth;
  39296. private static vjCanvasHeight;
  39297. private static halfWidth;
  39298. private _action;
  39299. private _axisTargetedByLeftAndRight;
  39300. private _axisTargetedByUpAndDown;
  39301. private _joystickSensibility;
  39302. private _inversedSensibility;
  39303. private _joystickPointerID;
  39304. private _joystickColor;
  39305. private _joystickPointerPos;
  39306. private _joystickPreviousPointerPos;
  39307. private _joystickPointerStartPos;
  39308. private _deltaJoystickVector;
  39309. private _leftJoystick;
  39310. private _touches;
  39311. private _onPointerDownHandlerRef;
  39312. private _onPointerMoveHandlerRef;
  39313. private _onPointerUpHandlerRef;
  39314. private _onResize;
  39315. /**
  39316. * Creates a new virtual joystick
  39317. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39318. */
  39319. constructor(leftJoystick?: boolean);
  39320. /**
  39321. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39322. * @param newJoystickSensibility defines the new sensibility
  39323. */
  39324. setJoystickSensibility(newJoystickSensibility: number): void;
  39325. private _onPointerDown;
  39326. private _onPointerMove;
  39327. private _onPointerUp;
  39328. /**
  39329. * Change the color of the virtual joystick
  39330. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39331. */
  39332. setJoystickColor(newColor: string): void;
  39333. /**
  39334. * Defines a callback to call when the joystick is touched
  39335. * @param action defines the callback
  39336. */
  39337. setActionOnTouch(action: () => any): void;
  39338. /**
  39339. * Defines which axis you'd like to control for left & right
  39340. * @param axis defines the axis to use
  39341. */
  39342. setAxisForLeftRight(axis: JoystickAxis): void;
  39343. /**
  39344. * Defines which axis you'd like to control for up & down
  39345. * @param axis defines the axis to use
  39346. */
  39347. setAxisForUpDown(axis: JoystickAxis): void;
  39348. private _drawVirtualJoystick;
  39349. /**
  39350. * Release internal HTML canvas
  39351. */
  39352. releaseCanvas(): void;
  39353. }
  39354. }
  39355. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39356. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39357. import { Nullable } from "babylonjs/types";
  39358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39360. module "babylonjs/Cameras/freeCameraInputsManager" {
  39361. interface FreeCameraInputsManager {
  39362. /**
  39363. * Add virtual joystick input support to the input manager.
  39364. * @returns the current input manager
  39365. */
  39366. addVirtualJoystick(): FreeCameraInputsManager;
  39367. }
  39368. }
  39369. /**
  39370. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39372. */
  39373. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39374. /**
  39375. * Defines the camera the input is attached to.
  39376. */
  39377. camera: FreeCamera;
  39378. private _leftjoystick;
  39379. private _rightjoystick;
  39380. /**
  39381. * Gets the left stick of the virtual joystick.
  39382. * @returns The virtual Joystick
  39383. */
  39384. getLeftJoystick(): VirtualJoystick;
  39385. /**
  39386. * Gets the right stick of the virtual joystick.
  39387. * @returns The virtual Joystick
  39388. */
  39389. getRightJoystick(): VirtualJoystick;
  39390. /**
  39391. * Update the current camera state depending on the inputs that have been used this frame.
  39392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39393. */
  39394. checkInputs(): void;
  39395. /**
  39396. * Attach the input controls to a specific dom element to get the input from.
  39397. * @param element Defines the element the controls should be listened from
  39398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39399. */
  39400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39401. /**
  39402. * Detach the current controls from the specified dom element.
  39403. * @param element Defines the element to stop listening the inputs from
  39404. */
  39405. detachControl(element: Nullable<HTMLElement>): void;
  39406. /**
  39407. * Gets the class name of the current intput.
  39408. * @returns the class name
  39409. */
  39410. getClassName(): string;
  39411. /**
  39412. * Get the friendly name associated with the input class.
  39413. * @returns the input friendly name
  39414. */
  39415. getSimpleName(): string;
  39416. }
  39417. }
  39418. declare module "babylonjs/Cameras/Inputs/index" {
  39419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39422. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39423. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39424. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39425. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39426. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39427. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39428. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39429. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39430. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39431. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39432. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39433. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39434. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39435. }
  39436. declare module "babylonjs/Cameras/touchCamera" {
  39437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39438. import { Scene } from "babylonjs/scene";
  39439. import { Vector3 } from "babylonjs/Maths/math.vector";
  39440. /**
  39441. * This represents a FPS type of camera controlled by touch.
  39442. * This is like a universal camera minus the Gamepad controls.
  39443. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39444. */
  39445. export class TouchCamera extends FreeCamera {
  39446. /**
  39447. * Defines the touch sensibility for rotation.
  39448. * The higher the faster.
  39449. */
  39450. touchAngularSensibility: number;
  39451. /**
  39452. * Defines the touch sensibility for move.
  39453. * The higher the faster.
  39454. */
  39455. touchMoveSensibility: number;
  39456. /**
  39457. * Instantiates a new touch camera.
  39458. * This represents a FPS type of camera controlled by touch.
  39459. * This is like a universal camera minus the Gamepad controls.
  39460. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39461. * @param name Define the name of the camera in the scene
  39462. * @param position Define the start position of the camera in the scene
  39463. * @param scene Define the scene the camera belongs to
  39464. */
  39465. constructor(name: string, position: Vector3, scene: Scene);
  39466. /**
  39467. * Gets the current object class name.
  39468. * @return the class name
  39469. */
  39470. getClassName(): string;
  39471. /** @hidden */
  39472. _setupInputs(): void;
  39473. }
  39474. }
  39475. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39476. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39477. import { Scene } from "babylonjs/scene";
  39478. import { Vector3 } from "babylonjs/Maths/math.vector";
  39479. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39480. import { Axis } from "babylonjs/Maths/math.axis";
  39481. /**
  39482. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39483. * being tilted forward or back and left or right.
  39484. */
  39485. export class DeviceOrientationCamera extends FreeCamera {
  39486. private _initialQuaternion;
  39487. private _quaternionCache;
  39488. private _tmpDragQuaternion;
  39489. private _disablePointerInputWhenUsingDeviceOrientation;
  39490. /**
  39491. * Creates a new device orientation camera
  39492. * @param name The name of the camera
  39493. * @param position The start position camera
  39494. * @param scene The scene the camera belongs to
  39495. */
  39496. constructor(name: string, position: Vector3, scene: Scene);
  39497. /**
  39498. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39499. */
  39500. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39501. private _dragFactor;
  39502. /**
  39503. * Enabled turning on the y axis when the orientation sensor is active
  39504. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39505. */
  39506. enableHorizontalDragging(dragFactor?: number): void;
  39507. /**
  39508. * Gets the current instance class name ("DeviceOrientationCamera").
  39509. * This helps avoiding instanceof at run time.
  39510. * @returns the class name
  39511. */
  39512. getClassName(): string;
  39513. /**
  39514. * @hidden
  39515. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39516. */
  39517. _checkInputs(): void;
  39518. /**
  39519. * Reset the camera to its default orientation on the specified axis only.
  39520. * @param axis The axis to reset
  39521. */
  39522. resetToCurrentRotation(axis?: Axis): void;
  39523. }
  39524. }
  39525. declare module "babylonjs/Gamepads/xboxGamepad" {
  39526. import { Observable } from "babylonjs/Misc/observable";
  39527. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39528. /**
  39529. * Defines supported buttons for XBox360 compatible gamepads
  39530. */
  39531. export enum Xbox360Button {
  39532. /** A */
  39533. A = 0,
  39534. /** B */
  39535. B = 1,
  39536. /** X */
  39537. X = 2,
  39538. /** Y */
  39539. Y = 3,
  39540. /** Start */
  39541. Start = 4,
  39542. /** Back */
  39543. Back = 5,
  39544. /** Left button */
  39545. LB = 6,
  39546. /** Right button */
  39547. RB = 7,
  39548. /** Left stick */
  39549. LeftStick = 8,
  39550. /** Right stick */
  39551. RightStick = 9
  39552. }
  39553. /** Defines values for XBox360 DPad */
  39554. export enum Xbox360Dpad {
  39555. /** Up */
  39556. Up = 0,
  39557. /** Down */
  39558. Down = 1,
  39559. /** Left */
  39560. Left = 2,
  39561. /** Right */
  39562. Right = 3
  39563. }
  39564. /**
  39565. * Defines a XBox360 gamepad
  39566. */
  39567. export class Xbox360Pad extends Gamepad {
  39568. private _leftTrigger;
  39569. private _rightTrigger;
  39570. private _onlefttriggerchanged;
  39571. private _onrighttriggerchanged;
  39572. private _onbuttondown;
  39573. private _onbuttonup;
  39574. private _ondpaddown;
  39575. private _ondpadup;
  39576. /** Observable raised when a button is pressed */
  39577. onButtonDownObservable: Observable<Xbox360Button>;
  39578. /** Observable raised when a button is released */
  39579. onButtonUpObservable: Observable<Xbox360Button>;
  39580. /** Observable raised when a pad is pressed */
  39581. onPadDownObservable: Observable<Xbox360Dpad>;
  39582. /** Observable raised when a pad is released */
  39583. onPadUpObservable: Observable<Xbox360Dpad>;
  39584. private _buttonA;
  39585. private _buttonB;
  39586. private _buttonX;
  39587. private _buttonY;
  39588. private _buttonBack;
  39589. private _buttonStart;
  39590. private _buttonLB;
  39591. private _buttonRB;
  39592. private _buttonLeftStick;
  39593. private _buttonRightStick;
  39594. private _dPadUp;
  39595. private _dPadDown;
  39596. private _dPadLeft;
  39597. private _dPadRight;
  39598. private _isXboxOnePad;
  39599. /**
  39600. * Creates a new XBox360 gamepad object
  39601. * @param id defines the id of this gamepad
  39602. * @param index defines its index
  39603. * @param gamepad defines the internal HTML gamepad object
  39604. * @param xboxOne defines if it is a XBox One gamepad
  39605. */
  39606. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39607. /**
  39608. * Defines the callback to call when left trigger is pressed
  39609. * @param callback defines the callback to use
  39610. */
  39611. onlefttriggerchanged(callback: (value: number) => void): void;
  39612. /**
  39613. * Defines the callback to call when right trigger is pressed
  39614. * @param callback defines the callback to use
  39615. */
  39616. onrighttriggerchanged(callback: (value: number) => void): void;
  39617. /**
  39618. * Gets the left trigger value
  39619. */
  39620. /**
  39621. * Sets the left trigger value
  39622. */
  39623. leftTrigger: number;
  39624. /**
  39625. * Gets the right trigger value
  39626. */
  39627. /**
  39628. * Sets the right trigger value
  39629. */
  39630. rightTrigger: number;
  39631. /**
  39632. * Defines the callback to call when a button is pressed
  39633. * @param callback defines the callback to use
  39634. */
  39635. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39636. /**
  39637. * Defines the callback to call when a button is released
  39638. * @param callback defines the callback to use
  39639. */
  39640. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39641. /**
  39642. * Defines the callback to call when a pad is pressed
  39643. * @param callback defines the callback to use
  39644. */
  39645. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39646. /**
  39647. * Defines the callback to call when a pad is released
  39648. * @param callback defines the callback to use
  39649. */
  39650. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39651. private _setButtonValue;
  39652. private _setDPadValue;
  39653. /**
  39654. * Gets the value of the `A` button
  39655. */
  39656. /**
  39657. * Sets the value of the `A` button
  39658. */
  39659. buttonA: number;
  39660. /**
  39661. * Gets the value of the `B` button
  39662. */
  39663. /**
  39664. * Sets the value of the `B` button
  39665. */
  39666. buttonB: number;
  39667. /**
  39668. * Gets the value of the `X` button
  39669. */
  39670. /**
  39671. * Sets the value of the `X` button
  39672. */
  39673. buttonX: number;
  39674. /**
  39675. * Gets the value of the `Y` button
  39676. */
  39677. /**
  39678. * Sets the value of the `Y` button
  39679. */
  39680. buttonY: number;
  39681. /**
  39682. * Gets the value of the `Start` button
  39683. */
  39684. /**
  39685. * Sets the value of the `Start` button
  39686. */
  39687. buttonStart: number;
  39688. /**
  39689. * Gets the value of the `Back` button
  39690. */
  39691. /**
  39692. * Sets the value of the `Back` button
  39693. */
  39694. buttonBack: number;
  39695. /**
  39696. * Gets the value of the `Left` button
  39697. */
  39698. /**
  39699. * Sets the value of the `Left` button
  39700. */
  39701. buttonLB: number;
  39702. /**
  39703. * Gets the value of the `Right` button
  39704. */
  39705. /**
  39706. * Sets the value of the `Right` button
  39707. */
  39708. buttonRB: number;
  39709. /**
  39710. * Gets the value of the Left joystick
  39711. */
  39712. /**
  39713. * Sets the value of the Left joystick
  39714. */
  39715. buttonLeftStick: number;
  39716. /**
  39717. * Gets the value of the Right joystick
  39718. */
  39719. /**
  39720. * Sets the value of the Right joystick
  39721. */
  39722. buttonRightStick: number;
  39723. /**
  39724. * Gets the value of D-pad up
  39725. */
  39726. /**
  39727. * Sets the value of D-pad up
  39728. */
  39729. dPadUp: number;
  39730. /**
  39731. * Gets the value of D-pad down
  39732. */
  39733. /**
  39734. * Sets the value of D-pad down
  39735. */
  39736. dPadDown: number;
  39737. /**
  39738. * Gets the value of D-pad left
  39739. */
  39740. /**
  39741. * Sets the value of D-pad left
  39742. */
  39743. dPadLeft: number;
  39744. /**
  39745. * Gets the value of D-pad right
  39746. */
  39747. /**
  39748. * Sets the value of D-pad right
  39749. */
  39750. dPadRight: number;
  39751. /**
  39752. * Force the gamepad to synchronize with device values
  39753. */
  39754. update(): void;
  39755. /**
  39756. * Disposes the gamepad
  39757. */
  39758. dispose(): void;
  39759. }
  39760. }
  39761. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39762. import { Observable } from "babylonjs/Misc/observable";
  39763. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39764. /**
  39765. * Defines supported buttons for DualShock compatible gamepads
  39766. */
  39767. export enum DualShockButton {
  39768. /** Cross */
  39769. Cross = 0,
  39770. /** Circle */
  39771. Circle = 1,
  39772. /** Square */
  39773. Square = 2,
  39774. /** Triangle */
  39775. Triangle = 3,
  39776. /** Options */
  39777. Options = 4,
  39778. /** Share */
  39779. Share = 5,
  39780. /** L1 */
  39781. L1 = 6,
  39782. /** R1 */
  39783. R1 = 7,
  39784. /** Left stick */
  39785. LeftStick = 8,
  39786. /** Right stick */
  39787. RightStick = 9
  39788. }
  39789. /** Defines values for DualShock DPad */
  39790. export enum DualShockDpad {
  39791. /** Up */
  39792. Up = 0,
  39793. /** Down */
  39794. Down = 1,
  39795. /** Left */
  39796. Left = 2,
  39797. /** Right */
  39798. Right = 3
  39799. }
  39800. /**
  39801. * Defines a DualShock gamepad
  39802. */
  39803. export class DualShockPad extends Gamepad {
  39804. private _leftTrigger;
  39805. private _rightTrigger;
  39806. private _onlefttriggerchanged;
  39807. private _onrighttriggerchanged;
  39808. private _onbuttondown;
  39809. private _onbuttonup;
  39810. private _ondpaddown;
  39811. private _ondpadup;
  39812. /** Observable raised when a button is pressed */
  39813. onButtonDownObservable: Observable<DualShockButton>;
  39814. /** Observable raised when a button is released */
  39815. onButtonUpObservable: Observable<DualShockButton>;
  39816. /** Observable raised when a pad is pressed */
  39817. onPadDownObservable: Observable<DualShockDpad>;
  39818. /** Observable raised when a pad is released */
  39819. onPadUpObservable: Observable<DualShockDpad>;
  39820. private _buttonCross;
  39821. private _buttonCircle;
  39822. private _buttonSquare;
  39823. private _buttonTriangle;
  39824. private _buttonShare;
  39825. private _buttonOptions;
  39826. private _buttonL1;
  39827. private _buttonR1;
  39828. private _buttonLeftStick;
  39829. private _buttonRightStick;
  39830. private _dPadUp;
  39831. private _dPadDown;
  39832. private _dPadLeft;
  39833. private _dPadRight;
  39834. /**
  39835. * Creates a new DualShock gamepad object
  39836. * @param id defines the id of this gamepad
  39837. * @param index defines its index
  39838. * @param gamepad defines the internal HTML gamepad object
  39839. */
  39840. constructor(id: string, index: number, gamepad: any);
  39841. /**
  39842. * Defines the callback to call when left trigger is pressed
  39843. * @param callback defines the callback to use
  39844. */
  39845. onlefttriggerchanged(callback: (value: number) => void): void;
  39846. /**
  39847. * Defines the callback to call when right trigger is pressed
  39848. * @param callback defines the callback to use
  39849. */
  39850. onrighttriggerchanged(callback: (value: number) => void): void;
  39851. /**
  39852. * Gets the left trigger value
  39853. */
  39854. /**
  39855. * Sets the left trigger value
  39856. */
  39857. leftTrigger: number;
  39858. /**
  39859. * Gets the right trigger value
  39860. */
  39861. /**
  39862. * Sets the right trigger value
  39863. */
  39864. rightTrigger: number;
  39865. /**
  39866. * Defines the callback to call when a button is pressed
  39867. * @param callback defines the callback to use
  39868. */
  39869. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39870. /**
  39871. * Defines the callback to call when a button is released
  39872. * @param callback defines the callback to use
  39873. */
  39874. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39875. /**
  39876. * Defines the callback to call when a pad is pressed
  39877. * @param callback defines the callback to use
  39878. */
  39879. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39880. /**
  39881. * Defines the callback to call when a pad is released
  39882. * @param callback defines the callback to use
  39883. */
  39884. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39885. private _setButtonValue;
  39886. private _setDPadValue;
  39887. /**
  39888. * Gets the value of the `Cross` button
  39889. */
  39890. /**
  39891. * Sets the value of the `Cross` button
  39892. */
  39893. buttonCross: number;
  39894. /**
  39895. * Gets the value of the `Circle` button
  39896. */
  39897. /**
  39898. * Sets the value of the `Circle` button
  39899. */
  39900. buttonCircle: number;
  39901. /**
  39902. * Gets the value of the `Square` button
  39903. */
  39904. /**
  39905. * Sets the value of the `Square` button
  39906. */
  39907. buttonSquare: number;
  39908. /**
  39909. * Gets the value of the `Triangle` button
  39910. */
  39911. /**
  39912. * Sets the value of the `Triangle` button
  39913. */
  39914. buttonTriangle: number;
  39915. /**
  39916. * Gets the value of the `Options` button
  39917. */
  39918. /**
  39919. * Sets the value of the `Options` button
  39920. */
  39921. buttonOptions: number;
  39922. /**
  39923. * Gets the value of the `Share` button
  39924. */
  39925. /**
  39926. * Sets the value of the `Share` button
  39927. */
  39928. buttonShare: number;
  39929. /**
  39930. * Gets the value of the `L1` button
  39931. */
  39932. /**
  39933. * Sets the value of the `L1` button
  39934. */
  39935. buttonL1: number;
  39936. /**
  39937. * Gets the value of the `R1` button
  39938. */
  39939. /**
  39940. * Sets the value of the `R1` button
  39941. */
  39942. buttonR1: number;
  39943. /**
  39944. * Gets the value of the Left joystick
  39945. */
  39946. /**
  39947. * Sets the value of the Left joystick
  39948. */
  39949. buttonLeftStick: number;
  39950. /**
  39951. * Gets the value of the Right joystick
  39952. */
  39953. /**
  39954. * Sets the value of the Right joystick
  39955. */
  39956. buttonRightStick: number;
  39957. /**
  39958. * Gets the value of D-pad up
  39959. */
  39960. /**
  39961. * Sets the value of D-pad up
  39962. */
  39963. dPadUp: number;
  39964. /**
  39965. * Gets the value of D-pad down
  39966. */
  39967. /**
  39968. * Sets the value of D-pad down
  39969. */
  39970. dPadDown: number;
  39971. /**
  39972. * Gets the value of D-pad left
  39973. */
  39974. /**
  39975. * Sets the value of D-pad left
  39976. */
  39977. dPadLeft: number;
  39978. /**
  39979. * Gets the value of D-pad right
  39980. */
  39981. /**
  39982. * Sets the value of D-pad right
  39983. */
  39984. dPadRight: number;
  39985. /**
  39986. * Force the gamepad to synchronize with device values
  39987. */
  39988. update(): void;
  39989. /**
  39990. * Disposes the gamepad
  39991. */
  39992. dispose(): void;
  39993. }
  39994. }
  39995. declare module "babylonjs/Gamepads/gamepadManager" {
  39996. import { Observable } from "babylonjs/Misc/observable";
  39997. import { Nullable } from "babylonjs/types";
  39998. import { Scene } from "babylonjs/scene";
  39999. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40000. /**
  40001. * Manager for handling gamepads
  40002. */
  40003. export class GamepadManager {
  40004. private _scene?;
  40005. private _babylonGamepads;
  40006. private _oneGamepadConnected;
  40007. /** @hidden */
  40008. _isMonitoring: boolean;
  40009. private _gamepadEventSupported;
  40010. private _gamepadSupport;
  40011. /**
  40012. * observable to be triggered when the gamepad controller has been connected
  40013. */
  40014. onGamepadConnectedObservable: Observable<Gamepad>;
  40015. /**
  40016. * observable to be triggered when the gamepad controller has been disconnected
  40017. */
  40018. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40019. private _onGamepadConnectedEvent;
  40020. private _onGamepadDisconnectedEvent;
  40021. /**
  40022. * Initializes the gamepad manager
  40023. * @param _scene BabylonJS scene
  40024. */
  40025. constructor(_scene?: Scene | undefined);
  40026. /**
  40027. * The gamepads in the game pad manager
  40028. */
  40029. readonly gamepads: Gamepad[];
  40030. /**
  40031. * Get the gamepad controllers based on type
  40032. * @param type The type of gamepad controller
  40033. * @returns Nullable gamepad
  40034. */
  40035. getGamepadByType(type?: number): Nullable<Gamepad>;
  40036. /**
  40037. * Disposes the gamepad manager
  40038. */
  40039. dispose(): void;
  40040. private _addNewGamepad;
  40041. private _startMonitoringGamepads;
  40042. private _stopMonitoringGamepads;
  40043. /** @hidden */
  40044. _checkGamepadsStatus(): void;
  40045. private _updateGamepadObjects;
  40046. }
  40047. }
  40048. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40049. import { Nullable } from "babylonjs/types";
  40050. import { Scene } from "babylonjs/scene";
  40051. import { ISceneComponent } from "babylonjs/sceneComponent";
  40052. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40053. module "babylonjs/scene" {
  40054. interface Scene {
  40055. /** @hidden */
  40056. _gamepadManager: Nullable<GamepadManager>;
  40057. /**
  40058. * Gets the gamepad manager associated with the scene
  40059. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40060. */
  40061. gamepadManager: GamepadManager;
  40062. }
  40063. }
  40064. module "babylonjs/Cameras/freeCameraInputsManager" {
  40065. /**
  40066. * Interface representing a free camera inputs manager
  40067. */
  40068. interface FreeCameraInputsManager {
  40069. /**
  40070. * Adds gamepad input support to the FreeCameraInputsManager.
  40071. * @returns the FreeCameraInputsManager
  40072. */
  40073. addGamepad(): FreeCameraInputsManager;
  40074. }
  40075. }
  40076. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40077. /**
  40078. * Interface representing an arc rotate camera inputs manager
  40079. */
  40080. interface ArcRotateCameraInputsManager {
  40081. /**
  40082. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40083. * @returns the camera inputs manager
  40084. */
  40085. addGamepad(): ArcRotateCameraInputsManager;
  40086. }
  40087. }
  40088. /**
  40089. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40090. */
  40091. export class GamepadSystemSceneComponent implements ISceneComponent {
  40092. /**
  40093. * The component name helpfull to identify the component in the list of scene components.
  40094. */
  40095. readonly name: string;
  40096. /**
  40097. * The scene the component belongs to.
  40098. */
  40099. scene: Scene;
  40100. /**
  40101. * Creates a new instance of the component for the given scene
  40102. * @param scene Defines the scene to register the component in
  40103. */
  40104. constructor(scene: Scene);
  40105. /**
  40106. * Registers the component in a given scene
  40107. */
  40108. register(): void;
  40109. /**
  40110. * Rebuilds the elements related to this component in case of
  40111. * context lost for instance.
  40112. */
  40113. rebuild(): void;
  40114. /**
  40115. * Disposes the component and the associated ressources
  40116. */
  40117. dispose(): void;
  40118. private _beforeCameraUpdate;
  40119. }
  40120. }
  40121. declare module "babylonjs/Cameras/universalCamera" {
  40122. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40123. import { Scene } from "babylonjs/scene";
  40124. import { Vector3 } from "babylonjs/Maths/math.vector";
  40125. import "babylonjs/Gamepads/gamepadSceneComponent";
  40126. /**
  40127. * 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,
  40128. * which still works and will still be found in many Playgrounds.
  40129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40130. */
  40131. export class UniversalCamera extends TouchCamera {
  40132. /**
  40133. * Defines the gamepad rotation sensiblity.
  40134. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40135. */
  40136. gamepadAngularSensibility: number;
  40137. /**
  40138. * Defines the gamepad move sensiblity.
  40139. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40140. */
  40141. gamepadMoveSensibility: number;
  40142. /**
  40143. * 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,
  40144. * which still works and will still be found in many Playgrounds.
  40145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40146. * @param name Define the name of the camera in the scene
  40147. * @param position Define the start position of the camera in the scene
  40148. * @param scene Define the scene the camera belongs to
  40149. */
  40150. constructor(name: string, position: Vector3, scene: Scene);
  40151. /**
  40152. * Gets the current object class name.
  40153. * @return the class name
  40154. */
  40155. getClassName(): string;
  40156. }
  40157. }
  40158. declare module "babylonjs/Cameras/gamepadCamera" {
  40159. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40160. import { Scene } from "babylonjs/scene";
  40161. import { Vector3 } from "babylonjs/Maths/math.vector";
  40162. /**
  40163. * This represents a FPS type of camera. This is only here for back compat purpose.
  40164. * Please use the UniversalCamera instead as both are identical.
  40165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40166. */
  40167. export class GamepadCamera extends UniversalCamera {
  40168. /**
  40169. * Instantiates a new Gamepad Camera
  40170. * This represents a FPS type of camera. This is only here for back compat purpose.
  40171. * Please use the UniversalCamera instead as both are identical.
  40172. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40173. * @param name Define the name of the camera in the scene
  40174. * @param position Define the start position of the camera in the scene
  40175. * @param scene Define the scene the camera belongs to
  40176. */
  40177. constructor(name: string, position: Vector3, scene: Scene);
  40178. /**
  40179. * Gets the current object class name.
  40180. * @return the class name
  40181. */
  40182. getClassName(): string;
  40183. }
  40184. }
  40185. declare module "babylonjs/Shaders/pass.fragment" {
  40186. /** @hidden */
  40187. export var passPixelShader: {
  40188. name: string;
  40189. shader: string;
  40190. };
  40191. }
  40192. declare module "babylonjs/Shaders/passCube.fragment" {
  40193. /** @hidden */
  40194. export var passCubePixelShader: {
  40195. name: string;
  40196. shader: string;
  40197. };
  40198. }
  40199. declare module "babylonjs/PostProcesses/passPostProcess" {
  40200. import { Nullable } from "babylonjs/types";
  40201. import { Camera } from "babylonjs/Cameras/camera";
  40202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40203. import { Engine } from "babylonjs/Engines/engine";
  40204. import "babylonjs/Shaders/pass.fragment";
  40205. import "babylonjs/Shaders/passCube.fragment";
  40206. /**
  40207. * PassPostProcess which produces an output the same as it's input
  40208. */
  40209. export class PassPostProcess extends PostProcess {
  40210. /**
  40211. * Creates the PassPostProcess
  40212. * @param name The name of the effect.
  40213. * @param options The required width/height ratio to downsize to before computing the render pass.
  40214. * @param camera The camera to apply the render pass to.
  40215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40216. * @param engine The engine which the post process will be applied. (default: current engine)
  40217. * @param reusable If the post process can be reused on the same frame. (default: false)
  40218. * @param textureType The type of texture to be used when performing the post processing.
  40219. * @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)
  40220. */
  40221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40222. }
  40223. /**
  40224. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40225. */
  40226. export class PassCubePostProcess extends PostProcess {
  40227. private _face;
  40228. /**
  40229. * Gets or sets the cube face to display.
  40230. * * 0 is +X
  40231. * * 1 is -X
  40232. * * 2 is +Y
  40233. * * 3 is -Y
  40234. * * 4 is +Z
  40235. * * 5 is -Z
  40236. */
  40237. face: number;
  40238. /**
  40239. * Creates the PassCubePostProcess
  40240. * @param name The name of the effect.
  40241. * @param options The required width/height ratio to downsize to before computing the render pass.
  40242. * @param camera The camera to apply the render pass to.
  40243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40244. * @param engine The engine which the post process will be applied. (default: current engine)
  40245. * @param reusable If the post process can be reused on the same frame. (default: false)
  40246. * @param textureType The type of texture to be used when performing the post processing.
  40247. * @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)
  40248. */
  40249. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40250. }
  40251. }
  40252. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40253. /** @hidden */
  40254. export var anaglyphPixelShader: {
  40255. name: string;
  40256. shader: string;
  40257. };
  40258. }
  40259. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40260. import { Engine } from "babylonjs/Engines/engine";
  40261. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40262. import { Camera } from "babylonjs/Cameras/camera";
  40263. import "babylonjs/Shaders/anaglyph.fragment";
  40264. /**
  40265. * Postprocess used to generate anaglyphic rendering
  40266. */
  40267. export class AnaglyphPostProcess extends PostProcess {
  40268. private _passedProcess;
  40269. /**
  40270. * Creates a new AnaglyphPostProcess
  40271. * @param name defines postprocess name
  40272. * @param options defines creation options or target ratio scale
  40273. * @param rigCameras defines cameras using this postprocess
  40274. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40275. * @param engine defines hosting engine
  40276. * @param reusable defines if the postprocess will be reused multiple times per frame
  40277. */
  40278. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40279. }
  40280. }
  40281. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40282. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40283. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40284. import { Scene } from "babylonjs/scene";
  40285. import { Vector3 } from "babylonjs/Maths/math.vector";
  40286. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40287. /**
  40288. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40289. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40290. */
  40291. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40292. /**
  40293. * Creates a new AnaglyphArcRotateCamera
  40294. * @param name defines camera name
  40295. * @param alpha defines alpha angle (in radians)
  40296. * @param beta defines beta angle (in radians)
  40297. * @param radius defines radius
  40298. * @param target defines camera target
  40299. * @param interaxialDistance defines distance between each color axis
  40300. * @param scene defines the hosting scene
  40301. */
  40302. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40303. /**
  40304. * Gets camera class name
  40305. * @returns AnaglyphArcRotateCamera
  40306. */
  40307. getClassName(): string;
  40308. }
  40309. }
  40310. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40311. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40312. import { Scene } from "babylonjs/scene";
  40313. import { Vector3 } from "babylonjs/Maths/math.vector";
  40314. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40315. /**
  40316. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40317. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40318. */
  40319. export class AnaglyphFreeCamera extends FreeCamera {
  40320. /**
  40321. * Creates a new AnaglyphFreeCamera
  40322. * @param name defines camera name
  40323. * @param position defines initial position
  40324. * @param interaxialDistance defines distance between each color axis
  40325. * @param scene defines the hosting scene
  40326. */
  40327. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40328. /**
  40329. * Gets camera class name
  40330. * @returns AnaglyphFreeCamera
  40331. */
  40332. getClassName(): string;
  40333. }
  40334. }
  40335. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40336. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40337. import { Scene } from "babylonjs/scene";
  40338. import { Vector3 } from "babylonjs/Maths/math.vector";
  40339. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40340. /**
  40341. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40342. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40343. */
  40344. export class AnaglyphGamepadCamera extends GamepadCamera {
  40345. /**
  40346. * Creates a new AnaglyphGamepadCamera
  40347. * @param name defines camera name
  40348. * @param position defines initial position
  40349. * @param interaxialDistance defines distance between each color axis
  40350. * @param scene defines the hosting scene
  40351. */
  40352. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40353. /**
  40354. * Gets camera class name
  40355. * @returns AnaglyphGamepadCamera
  40356. */
  40357. getClassName(): string;
  40358. }
  40359. }
  40360. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40361. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40362. import { Scene } from "babylonjs/scene";
  40363. import { Vector3 } from "babylonjs/Maths/math.vector";
  40364. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40365. /**
  40366. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40367. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40368. */
  40369. export class AnaglyphUniversalCamera extends UniversalCamera {
  40370. /**
  40371. * Creates a new AnaglyphUniversalCamera
  40372. * @param name defines camera name
  40373. * @param position defines initial position
  40374. * @param interaxialDistance defines distance between each color axis
  40375. * @param scene defines the hosting scene
  40376. */
  40377. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40378. /**
  40379. * Gets camera class name
  40380. * @returns AnaglyphUniversalCamera
  40381. */
  40382. getClassName(): string;
  40383. }
  40384. }
  40385. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40386. /** @hidden */
  40387. export var stereoscopicInterlacePixelShader: {
  40388. name: string;
  40389. shader: string;
  40390. };
  40391. }
  40392. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40393. import { Camera } from "babylonjs/Cameras/camera";
  40394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40395. import { Engine } from "babylonjs/Engines/engine";
  40396. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40397. /**
  40398. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40399. */
  40400. export class StereoscopicInterlacePostProcess extends PostProcess {
  40401. private _stepSize;
  40402. private _passedProcess;
  40403. /**
  40404. * Initializes a StereoscopicInterlacePostProcess
  40405. * @param name The name of the effect.
  40406. * @param rigCameras The rig cameras to be appled to the post process
  40407. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40409. * @param engine The engine which the post process will be applied. (default: current engine)
  40410. * @param reusable If the post process can be reused on the same frame. (default: false)
  40411. */
  40412. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40413. }
  40414. }
  40415. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40416. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40417. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40418. import { Scene } from "babylonjs/scene";
  40419. import { Vector3 } from "babylonjs/Maths/math.vector";
  40420. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40421. /**
  40422. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40423. * @see http://doc.babylonjs.com/features/cameras
  40424. */
  40425. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40426. /**
  40427. * Creates a new StereoscopicArcRotateCamera
  40428. * @param name defines camera name
  40429. * @param alpha defines alpha angle (in radians)
  40430. * @param beta defines beta angle (in radians)
  40431. * @param radius defines radius
  40432. * @param target defines camera target
  40433. * @param interaxialDistance defines distance between each color axis
  40434. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40435. * @param scene defines the hosting scene
  40436. */
  40437. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40438. /**
  40439. * Gets camera class name
  40440. * @returns StereoscopicArcRotateCamera
  40441. */
  40442. getClassName(): string;
  40443. }
  40444. }
  40445. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40446. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40447. import { Scene } from "babylonjs/scene";
  40448. import { Vector3 } from "babylonjs/Maths/math.vector";
  40449. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40450. /**
  40451. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40452. * @see http://doc.babylonjs.com/features/cameras
  40453. */
  40454. export class StereoscopicFreeCamera extends FreeCamera {
  40455. /**
  40456. * Creates a new StereoscopicFreeCamera
  40457. * @param name defines camera name
  40458. * @param position defines initial position
  40459. * @param interaxialDistance defines distance between each color axis
  40460. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40461. * @param scene defines the hosting scene
  40462. */
  40463. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40464. /**
  40465. * Gets camera class name
  40466. * @returns StereoscopicFreeCamera
  40467. */
  40468. getClassName(): string;
  40469. }
  40470. }
  40471. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40472. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40473. import { Scene } from "babylonjs/scene";
  40474. import { Vector3 } from "babylonjs/Maths/math.vector";
  40475. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40476. /**
  40477. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40478. * @see http://doc.babylonjs.com/features/cameras
  40479. */
  40480. export class StereoscopicGamepadCamera extends GamepadCamera {
  40481. /**
  40482. * Creates a new StereoscopicGamepadCamera
  40483. * @param name defines camera name
  40484. * @param position defines initial position
  40485. * @param interaxialDistance defines distance between each color axis
  40486. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40487. * @param scene defines the hosting scene
  40488. */
  40489. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40490. /**
  40491. * Gets camera class name
  40492. * @returns StereoscopicGamepadCamera
  40493. */
  40494. getClassName(): string;
  40495. }
  40496. }
  40497. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40498. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40499. import { Scene } from "babylonjs/scene";
  40500. import { Vector3 } from "babylonjs/Maths/math.vector";
  40501. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40502. /**
  40503. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40504. * @see http://doc.babylonjs.com/features/cameras
  40505. */
  40506. export class StereoscopicUniversalCamera extends UniversalCamera {
  40507. /**
  40508. * Creates a new StereoscopicUniversalCamera
  40509. * @param name defines camera name
  40510. * @param position defines initial position
  40511. * @param interaxialDistance defines distance between each color axis
  40512. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40513. * @param scene defines the hosting scene
  40514. */
  40515. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40516. /**
  40517. * Gets camera class name
  40518. * @returns StereoscopicUniversalCamera
  40519. */
  40520. getClassName(): string;
  40521. }
  40522. }
  40523. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40524. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40525. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40526. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40527. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40528. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40529. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40530. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40531. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40532. }
  40533. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40534. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40535. import { Scene } from "babylonjs/scene";
  40536. import { Vector3 } from "babylonjs/Maths/math.vector";
  40537. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40538. /**
  40539. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40540. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40541. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40542. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40543. */
  40544. export class VirtualJoysticksCamera extends FreeCamera {
  40545. /**
  40546. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40547. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40548. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40549. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40550. * @param name Define the name of the camera in the scene
  40551. * @param position Define the start position of the camera in the scene
  40552. * @param scene Define the scene the camera belongs to
  40553. */
  40554. constructor(name: string, position: Vector3, scene: Scene);
  40555. /**
  40556. * Gets the current object class name.
  40557. * @return the class name
  40558. */
  40559. getClassName(): string;
  40560. }
  40561. }
  40562. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40563. import { Matrix } from "babylonjs/Maths/math.vector";
  40564. /**
  40565. * This represents all the required metrics to create a VR camera.
  40566. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40567. */
  40568. export class VRCameraMetrics {
  40569. /**
  40570. * Define the horizontal resolution off the screen.
  40571. */
  40572. hResolution: number;
  40573. /**
  40574. * Define the vertical resolution off the screen.
  40575. */
  40576. vResolution: number;
  40577. /**
  40578. * Define the horizontal screen size.
  40579. */
  40580. hScreenSize: number;
  40581. /**
  40582. * Define the vertical screen size.
  40583. */
  40584. vScreenSize: number;
  40585. /**
  40586. * Define the vertical screen center position.
  40587. */
  40588. vScreenCenter: number;
  40589. /**
  40590. * Define the distance of the eyes to the screen.
  40591. */
  40592. eyeToScreenDistance: number;
  40593. /**
  40594. * Define the distance between both lenses
  40595. */
  40596. lensSeparationDistance: number;
  40597. /**
  40598. * Define the distance between both viewer's eyes.
  40599. */
  40600. interpupillaryDistance: number;
  40601. /**
  40602. * Define the distortion factor of the VR postprocess.
  40603. * Please, touch with care.
  40604. */
  40605. distortionK: number[];
  40606. /**
  40607. * Define the chromatic aberration correction factors for the VR post process.
  40608. */
  40609. chromaAbCorrection: number[];
  40610. /**
  40611. * Define the scale factor of the post process.
  40612. * The smaller the better but the slower.
  40613. */
  40614. postProcessScaleFactor: number;
  40615. /**
  40616. * Define an offset for the lens center.
  40617. */
  40618. lensCenterOffset: number;
  40619. /**
  40620. * Define if the current vr camera should compensate the distortion of the lense or not.
  40621. */
  40622. compensateDistortion: boolean;
  40623. /**
  40624. * Defines if multiview should be enabled when rendering (Default: false)
  40625. */
  40626. multiviewEnabled: boolean;
  40627. /**
  40628. * Gets the rendering aspect ratio based on the provided resolutions.
  40629. */
  40630. readonly aspectRatio: number;
  40631. /**
  40632. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40633. */
  40634. readonly aspectRatioFov: number;
  40635. /**
  40636. * @hidden
  40637. */
  40638. readonly leftHMatrix: Matrix;
  40639. /**
  40640. * @hidden
  40641. */
  40642. readonly rightHMatrix: Matrix;
  40643. /**
  40644. * @hidden
  40645. */
  40646. readonly leftPreViewMatrix: Matrix;
  40647. /**
  40648. * @hidden
  40649. */
  40650. readonly rightPreViewMatrix: Matrix;
  40651. /**
  40652. * Get the default VRMetrics based on the most generic setup.
  40653. * @returns the default vr metrics
  40654. */
  40655. static GetDefault(): VRCameraMetrics;
  40656. }
  40657. }
  40658. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40659. /** @hidden */
  40660. export var vrDistortionCorrectionPixelShader: {
  40661. name: string;
  40662. shader: string;
  40663. };
  40664. }
  40665. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40666. import { Camera } from "babylonjs/Cameras/camera";
  40667. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40669. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40670. /**
  40671. * VRDistortionCorrectionPostProcess used for mobile VR
  40672. */
  40673. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40674. private _isRightEye;
  40675. private _distortionFactors;
  40676. private _postProcessScaleFactor;
  40677. private _lensCenterOffset;
  40678. private _scaleIn;
  40679. private _scaleFactor;
  40680. private _lensCenter;
  40681. /**
  40682. * Initializes the VRDistortionCorrectionPostProcess
  40683. * @param name The name of the effect.
  40684. * @param camera The camera to apply the render pass to.
  40685. * @param isRightEye If this is for the right eye distortion
  40686. * @param vrMetrics All the required metrics for the VR camera
  40687. */
  40688. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40689. }
  40690. }
  40691. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40692. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40693. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40694. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40695. import { Scene } from "babylonjs/scene";
  40696. import { Vector3 } from "babylonjs/Maths/math.vector";
  40697. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40698. import "babylonjs/Cameras/RigModes/vrRigMode";
  40699. /**
  40700. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40701. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40702. */
  40703. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40704. /**
  40705. * Creates a new VRDeviceOrientationArcRotateCamera
  40706. * @param name defines camera name
  40707. * @param alpha defines the camera rotation along the logitudinal axis
  40708. * @param beta defines the camera rotation along the latitudinal axis
  40709. * @param radius defines the camera distance from its target
  40710. * @param target defines the camera target
  40711. * @param scene defines the scene the camera belongs to
  40712. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40713. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40714. */
  40715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40716. /**
  40717. * Gets camera class name
  40718. * @returns VRDeviceOrientationArcRotateCamera
  40719. */
  40720. getClassName(): string;
  40721. }
  40722. }
  40723. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40724. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40725. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40726. import { Scene } from "babylonjs/scene";
  40727. import { Vector3 } from "babylonjs/Maths/math.vector";
  40728. import "babylonjs/Cameras/RigModes/vrRigMode";
  40729. /**
  40730. * Camera used to simulate VR rendering (based on FreeCamera)
  40731. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40732. */
  40733. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40734. /**
  40735. * Creates a new VRDeviceOrientationFreeCamera
  40736. * @param name defines camera name
  40737. * @param position defines the start position of the camera
  40738. * @param scene defines the scene the camera belongs to
  40739. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40740. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40741. */
  40742. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40743. /**
  40744. * Gets camera class name
  40745. * @returns VRDeviceOrientationFreeCamera
  40746. */
  40747. getClassName(): string;
  40748. }
  40749. }
  40750. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40751. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40752. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40753. import { Scene } from "babylonjs/scene";
  40754. import { Vector3 } from "babylonjs/Maths/math.vector";
  40755. import "babylonjs/Gamepads/gamepadSceneComponent";
  40756. /**
  40757. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40758. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40759. */
  40760. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40761. /**
  40762. * Creates a new VRDeviceOrientationGamepadCamera
  40763. * @param name defines camera name
  40764. * @param position defines the start position of the camera
  40765. * @param scene defines the scene the camera belongs to
  40766. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40767. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40768. */
  40769. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40770. /**
  40771. * Gets camera class name
  40772. * @returns VRDeviceOrientationGamepadCamera
  40773. */
  40774. getClassName(): string;
  40775. }
  40776. }
  40777. declare module "babylonjs/Materials/pushMaterial" {
  40778. import { Nullable } from "babylonjs/types";
  40779. import { Scene } from "babylonjs/scene";
  40780. import { Matrix } from "babylonjs/Maths/math.vector";
  40781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40782. import { Mesh } from "babylonjs/Meshes/mesh";
  40783. import { Material } from "babylonjs/Materials/material";
  40784. import { Effect } from "babylonjs/Materials/effect";
  40785. /**
  40786. * Base class of materials working in push mode in babylon JS
  40787. * @hidden
  40788. */
  40789. export class PushMaterial extends Material {
  40790. protected _activeEffect: Effect;
  40791. protected _normalMatrix: Matrix;
  40792. /**
  40793. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40794. * This means that the material can keep using a previous shader while a new one is being compiled.
  40795. * This is mostly used when shader parallel compilation is supported (true by default)
  40796. */
  40797. allowShaderHotSwapping: boolean;
  40798. constructor(name: string, scene: Scene);
  40799. getEffect(): Effect;
  40800. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40801. /**
  40802. * Binds the given world matrix to the active effect
  40803. *
  40804. * @param world the matrix to bind
  40805. */
  40806. bindOnlyWorldMatrix(world: Matrix): void;
  40807. /**
  40808. * Binds the given normal matrix to the active effect
  40809. *
  40810. * @param normalMatrix the matrix to bind
  40811. */
  40812. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40813. bind(world: Matrix, mesh?: Mesh): void;
  40814. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40815. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40816. }
  40817. }
  40818. declare module "babylonjs/Materials/materialFlags" {
  40819. /**
  40820. * This groups all the flags used to control the materials channel.
  40821. */
  40822. export class MaterialFlags {
  40823. private static _DiffuseTextureEnabled;
  40824. /**
  40825. * Are diffuse textures enabled in the application.
  40826. */
  40827. static DiffuseTextureEnabled: boolean;
  40828. private static _AmbientTextureEnabled;
  40829. /**
  40830. * Are ambient textures enabled in the application.
  40831. */
  40832. static AmbientTextureEnabled: boolean;
  40833. private static _OpacityTextureEnabled;
  40834. /**
  40835. * Are opacity textures enabled in the application.
  40836. */
  40837. static OpacityTextureEnabled: boolean;
  40838. private static _ReflectionTextureEnabled;
  40839. /**
  40840. * Are reflection textures enabled in the application.
  40841. */
  40842. static ReflectionTextureEnabled: boolean;
  40843. private static _EmissiveTextureEnabled;
  40844. /**
  40845. * Are emissive textures enabled in the application.
  40846. */
  40847. static EmissiveTextureEnabled: boolean;
  40848. private static _SpecularTextureEnabled;
  40849. /**
  40850. * Are specular textures enabled in the application.
  40851. */
  40852. static SpecularTextureEnabled: boolean;
  40853. private static _BumpTextureEnabled;
  40854. /**
  40855. * Are bump textures enabled in the application.
  40856. */
  40857. static BumpTextureEnabled: boolean;
  40858. private static _LightmapTextureEnabled;
  40859. /**
  40860. * Are lightmap textures enabled in the application.
  40861. */
  40862. static LightmapTextureEnabled: boolean;
  40863. private static _RefractionTextureEnabled;
  40864. /**
  40865. * Are refraction textures enabled in the application.
  40866. */
  40867. static RefractionTextureEnabled: boolean;
  40868. private static _ColorGradingTextureEnabled;
  40869. /**
  40870. * Are color grading textures enabled in the application.
  40871. */
  40872. static ColorGradingTextureEnabled: boolean;
  40873. private static _FresnelEnabled;
  40874. /**
  40875. * Are fresnels enabled in the application.
  40876. */
  40877. static FresnelEnabled: boolean;
  40878. private static _ClearCoatTextureEnabled;
  40879. /**
  40880. * Are clear coat textures enabled in the application.
  40881. */
  40882. static ClearCoatTextureEnabled: boolean;
  40883. private static _ClearCoatBumpTextureEnabled;
  40884. /**
  40885. * Are clear coat bump textures enabled in the application.
  40886. */
  40887. static ClearCoatBumpTextureEnabled: boolean;
  40888. private static _ClearCoatTintTextureEnabled;
  40889. /**
  40890. * Are clear coat tint textures enabled in the application.
  40891. */
  40892. static ClearCoatTintTextureEnabled: boolean;
  40893. private static _SheenTextureEnabled;
  40894. /**
  40895. * Are sheen textures enabled in the application.
  40896. */
  40897. static SheenTextureEnabled: boolean;
  40898. private static _AnisotropicTextureEnabled;
  40899. /**
  40900. * Are anisotropic textures enabled in the application.
  40901. */
  40902. static AnisotropicTextureEnabled: boolean;
  40903. private static _ThicknessTextureEnabled;
  40904. /**
  40905. * Are thickness textures enabled in the application.
  40906. */
  40907. static ThicknessTextureEnabled: boolean;
  40908. }
  40909. }
  40910. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40911. /** @hidden */
  40912. export var defaultFragmentDeclaration: {
  40913. name: string;
  40914. shader: string;
  40915. };
  40916. }
  40917. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40918. /** @hidden */
  40919. export var defaultUboDeclaration: {
  40920. name: string;
  40921. shader: string;
  40922. };
  40923. }
  40924. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40925. /** @hidden */
  40926. export var lightFragmentDeclaration: {
  40927. name: string;
  40928. shader: string;
  40929. };
  40930. }
  40931. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40932. /** @hidden */
  40933. export var lightUboDeclaration: {
  40934. name: string;
  40935. shader: string;
  40936. };
  40937. }
  40938. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40939. /** @hidden */
  40940. export var lightsFragmentFunctions: {
  40941. name: string;
  40942. shader: string;
  40943. };
  40944. }
  40945. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40946. /** @hidden */
  40947. export var shadowsFragmentFunctions: {
  40948. name: string;
  40949. shader: string;
  40950. };
  40951. }
  40952. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40953. /** @hidden */
  40954. export var fresnelFunction: {
  40955. name: string;
  40956. shader: string;
  40957. };
  40958. }
  40959. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40960. /** @hidden */
  40961. export var reflectionFunction: {
  40962. name: string;
  40963. shader: string;
  40964. };
  40965. }
  40966. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40967. /** @hidden */
  40968. export var bumpFragmentFunctions: {
  40969. name: string;
  40970. shader: string;
  40971. };
  40972. }
  40973. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40974. /** @hidden */
  40975. export var logDepthDeclaration: {
  40976. name: string;
  40977. shader: string;
  40978. };
  40979. }
  40980. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40981. /** @hidden */
  40982. export var bumpFragment: {
  40983. name: string;
  40984. shader: string;
  40985. };
  40986. }
  40987. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40988. /** @hidden */
  40989. export var depthPrePass: {
  40990. name: string;
  40991. shader: string;
  40992. };
  40993. }
  40994. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40995. /** @hidden */
  40996. export var lightFragment: {
  40997. name: string;
  40998. shader: string;
  40999. };
  41000. }
  41001. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41002. /** @hidden */
  41003. export var logDepthFragment: {
  41004. name: string;
  41005. shader: string;
  41006. };
  41007. }
  41008. declare module "babylonjs/Shaders/default.fragment" {
  41009. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41010. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41012. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41013. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41014. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41015. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41016. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41019. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41020. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41022. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41023. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41024. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41025. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41026. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41027. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41030. /** @hidden */
  41031. export var defaultPixelShader: {
  41032. name: string;
  41033. shader: string;
  41034. };
  41035. }
  41036. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41037. /** @hidden */
  41038. export var defaultVertexDeclaration: {
  41039. name: string;
  41040. shader: string;
  41041. };
  41042. }
  41043. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41044. /** @hidden */
  41045. export var bumpVertexDeclaration: {
  41046. name: string;
  41047. shader: string;
  41048. };
  41049. }
  41050. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41051. /** @hidden */
  41052. export var bumpVertex: {
  41053. name: string;
  41054. shader: string;
  41055. };
  41056. }
  41057. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41058. /** @hidden */
  41059. export var fogVertex: {
  41060. name: string;
  41061. shader: string;
  41062. };
  41063. }
  41064. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41065. /** @hidden */
  41066. export var shadowsVertex: {
  41067. name: string;
  41068. shader: string;
  41069. };
  41070. }
  41071. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41072. /** @hidden */
  41073. export var pointCloudVertex: {
  41074. name: string;
  41075. shader: string;
  41076. };
  41077. }
  41078. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41079. /** @hidden */
  41080. export var logDepthVertex: {
  41081. name: string;
  41082. shader: string;
  41083. };
  41084. }
  41085. declare module "babylonjs/Shaders/default.vertex" {
  41086. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41087. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41089. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41091. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41092. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41093. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41094. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41095. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41096. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41098. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41102. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41103. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41104. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41105. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41106. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41108. /** @hidden */
  41109. export var defaultVertexShader: {
  41110. name: string;
  41111. shader: string;
  41112. };
  41113. }
  41114. declare module "babylonjs/Materials/standardMaterial" {
  41115. import { SmartArray } from "babylonjs/Misc/smartArray";
  41116. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41117. import { Nullable } from "babylonjs/types";
  41118. import { Scene } from "babylonjs/scene";
  41119. import { Matrix } from "babylonjs/Maths/math.vector";
  41120. import { Color3 } from "babylonjs/Maths/math.color";
  41121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41123. import { Mesh } from "babylonjs/Meshes/mesh";
  41124. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41126. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41127. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41128. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41131. import "babylonjs/Shaders/default.fragment";
  41132. import "babylonjs/Shaders/default.vertex";
  41133. /** @hidden */
  41134. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41135. MAINUV1: boolean;
  41136. MAINUV2: boolean;
  41137. DIFFUSE: boolean;
  41138. DIFFUSEDIRECTUV: number;
  41139. AMBIENT: boolean;
  41140. AMBIENTDIRECTUV: number;
  41141. OPACITY: boolean;
  41142. OPACITYDIRECTUV: number;
  41143. OPACITYRGB: boolean;
  41144. REFLECTION: boolean;
  41145. EMISSIVE: boolean;
  41146. EMISSIVEDIRECTUV: number;
  41147. SPECULAR: boolean;
  41148. SPECULARDIRECTUV: number;
  41149. BUMP: boolean;
  41150. BUMPDIRECTUV: number;
  41151. PARALLAX: boolean;
  41152. PARALLAXOCCLUSION: boolean;
  41153. SPECULAROVERALPHA: boolean;
  41154. CLIPPLANE: boolean;
  41155. CLIPPLANE2: boolean;
  41156. CLIPPLANE3: boolean;
  41157. CLIPPLANE4: boolean;
  41158. ALPHATEST: boolean;
  41159. DEPTHPREPASS: boolean;
  41160. ALPHAFROMDIFFUSE: boolean;
  41161. POINTSIZE: boolean;
  41162. FOG: boolean;
  41163. SPECULARTERM: boolean;
  41164. DIFFUSEFRESNEL: boolean;
  41165. OPACITYFRESNEL: boolean;
  41166. REFLECTIONFRESNEL: boolean;
  41167. REFRACTIONFRESNEL: boolean;
  41168. EMISSIVEFRESNEL: boolean;
  41169. FRESNEL: boolean;
  41170. NORMAL: boolean;
  41171. UV1: boolean;
  41172. UV2: boolean;
  41173. VERTEXCOLOR: boolean;
  41174. VERTEXALPHA: boolean;
  41175. NUM_BONE_INFLUENCERS: number;
  41176. BonesPerMesh: number;
  41177. BONETEXTURE: boolean;
  41178. INSTANCES: boolean;
  41179. GLOSSINESS: boolean;
  41180. ROUGHNESS: boolean;
  41181. EMISSIVEASILLUMINATION: boolean;
  41182. LINKEMISSIVEWITHDIFFUSE: boolean;
  41183. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41184. LIGHTMAP: boolean;
  41185. LIGHTMAPDIRECTUV: number;
  41186. OBJECTSPACE_NORMALMAP: boolean;
  41187. USELIGHTMAPASSHADOWMAP: boolean;
  41188. REFLECTIONMAP_3D: boolean;
  41189. REFLECTIONMAP_SPHERICAL: boolean;
  41190. REFLECTIONMAP_PLANAR: boolean;
  41191. REFLECTIONMAP_CUBIC: boolean;
  41192. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41193. REFLECTIONMAP_PROJECTION: boolean;
  41194. REFLECTIONMAP_SKYBOX: boolean;
  41195. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41196. REFLECTIONMAP_EXPLICIT: boolean;
  41197. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41198. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41199. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41200. INVERTCUBICMAP: boolean;
  41201. LOGARITHMICDEPTH: boolean;
  41202. REFRACTION: boolean;
  41203. REFRACTIONMAP_3D: boolean;
  41204. REFLECTIONOVERALPHA: boolean;
  41205. TWOSIDEDLIGHTING: boolean;
  41206. SHADOWFLOAT: boolean;
  41207. MORPHTARGETS: boolean;
  41208. MORPHTARGETS_NORMAL: boolean;
  41209. MORPHTARGETS_TANGENT: boolean;
  41210. MORPHTARGETS_UV: boolean;
  41211. NUM_MORPH_INFLUENCERS: number;
  41212. NONUNIFORMSCALING: boolean;
  41213. PREMULTIPLYALPHA: boolean;
  41214. IMAGEPROCESSING: boolean;
  41215. VIGNETTE: boolean;
  41216. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41217. VIGNETTEBLENDMODEOPAQUE: boolean;
  41218. TONEMAPPING: boolean;
  41219. TONEMAPPING_ACES: boolean;
  41220. CONTRAST: boolean;
  41221. COLORCURVES: boolean;
  41222. COLORGRADING: boolean;
  41223. COLORGRADING3D: boolean;
  41224. SAMPLER3DGREENDEPTH: boolean;
  41225. SAMPLER3DBGRMAP: boolean;
  41226. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41227. MULTIVIEW: boolean;
  41228. /**
  41229. * If the reflection texture on this material is in linear color space
  41230. * @hidden
  41231. */
  41232. IS_REFLECTION_LINEAR: boolean;
  41233. /**
  41234. * If the refraction texture on this material is in linear color space
  41235. * @hidden
  41236. */
  41237. IS_REFRACTION_LINEAR: boolean;
  41238. EXPOSURE: boolean;
  41239. constructor();
  41240. setReflectionMode(modeToEnable: string): void;
  41241. }
  41242. /**
  41243. * This is the default material used in Babylon. It is the best trade off between quality
  41244. * and performances.
  41245. * @see http://doc.babylonjs.com/babylon101/materials
  41246. */
  41247. export class StandardMaterial extends PushMaterial {
  41248. private _diffuseTexture;
  41249. /**
  41250. * The basic texture of the material as viewed under a light.
  41251. */
  41252. diffuseTexture: Nullable<BaseTexture>;
  41253. private _ambientTexture;
  41254. /**
  41255. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41256. */
  41257. ambientTexture: Nullable<BaseTexture>;
  41258. private _opacityTexture;
  41259. /**
  41260. * Define the transparency of the material from a texture.
  41261. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41262. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41263. */
  41264. opacityTexture: Nullable<BaseTexture>;
  41265. private _reflectionTexture;
  41266. /**
  41267. * Define the texture used to display the reflection.
  41268. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41269. */
  41270. reflectionTexture: Nullable<BaseTexture>;
  41271. private _emissiveTexture;
  41272. /**
  41273. * Define texture of the material as if self lit.
  41274. * This will be mixed in the final result even in the absence of light.
  41275. */
  41276. emissiveTexture: Nullable<BaseTexture>;
  41277. private _specularTexture;
  41278. /**
  41279. * Define how the color and intensity of the highlight given by the light in the material.
  41280. */
  41281. specularTexture: Nullable<BaseTexture>;
  41282. private _bumpTexture;
  41283. /**
  41284. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41285. * 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.
  41286. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41287. */
  41288. bumpTexture: Nullable<BaseTexture>;
  41289. private _lightmapTexture;
  41290. /**
  41291. * Complex lighting can be computationally expensive to compute at runtime.
  41292. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41293. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41294. */
  41295. lightmapTexture: Nullable<BaseTexture>;
  41296. private _refractionTexture;
  41297. /**
  41298. * Define the texture used to display the refraction.
  41299. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41300. */
  41301. refractionTexture: Nullable<BaseTexture>;
  41302. /**
  41303. * The color of the material lit by the environmental background lighting.
  41304. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41305. */
  41306. ambientColor: Color3;
  41307. /**
  41308. * The basic color of the material as viewed under a light.
  41309. */
  41310. diffuseColor: Color3;
  41311. /**
  41312. * Define how the color and intensity of the highlight given by the light in the material.
  41313. */
  41314. specularColor: Color3;
  41315. /**
  41316. * Define the color of the material as if self lit.
  41317. * This will be mixed in the final result even in the absence of light.
  41318. */
  41319. emissiveColor: Color3;
  41320. /**
  41321. * Defines how sharp are the highlights in the material.
  41322. * The bigger the value the sharper giving a more glossy feeling to the result.
  41323. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41324. */
  41325. specularPower: number;
  41326. private _useAlphaFromDiffuseTexture;
  41327. /**
  41328. * Does the transparency come from the diffuse texture alpha channel.
  41329. */
  41330. useAlphaFromDiffuseTexture: boolean;
  41331. private _useEmissiveAsIllumination;
  41332. /**
  41333. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41334. */
  41335. useEmissiveAsIllumination: boolean;
  41336. private _linkEmissiveWithDiffuse;
  41337. /**
  41338. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41339. * the emissive level when the final color is close to one.
  41340. */
  41341. linkEmissiveWithDiffuse: boolean;
  41342. private _useSpecularOverAlpha;
  41343. /**
  41344. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41345. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41346. */
  41347. useSpecularOverAlpha: boolean;
  41348. private _useReflectionOverAlpha;
  41349. /**
  41350. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41351. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41352. */
  41353. useReflectionOverAlpha: boolean;
  41354. private _disableLighting;
  41355. /**
  41356. * Does lights from the scene impacts this material.
  41357. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41358. */
  41359. disableLighting: boolean;
  41360. private _useObjectSpaceNormalMap;
  41361. /**
  41362. * Allows using an object space normal map (instead of tangent space).
  41363. */
  41364. useObjectSpaceNormalMap: boolean;
  41365. private _useParallax;
  41366. /**
  41367. * Is parallax enabled or not.
  41368. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41369. */
  41370. useParallax: boolean;
  41371. private _useParallaxOcclusion;
  41372. /**
  41373. * Is parallax occlusion enabled or not.
  41374. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41375. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41376. */
  41377. useParallaxOcclusion: boolean;
  41378. /**
  41379. * 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.
  41380. */
  41381. parallaxScaleBias: number;
  41382. private _roughness;
  41383. /**
  41384. * Helps to define how blurry the reflections should appears in the material.
  41385. */
  41386. roughness: number;
  41387. /**
  41388. * In case of refraction, define the value of the index of refraction.
  41389. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41390. */
  41391. indexOfRefraction: number;
  41392. /**
  41393. * Invert the refraction texture alongside the y axis.
  41394. * It can be useful with procedural textures or probe for instance.
  41395. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41396. */
  41397. invertRefractionY: boolean;
  41398. /**
  41399. * Defines the alpha limits in alpha test mode.
  41400. */
  41401. alphaCutOff: number;
  41402. private _useLightmapAsShadowmap;
  41403. /**
  41404. * In case of light mapping, define whether the map contains light or shadow informations.
  41405. */
  41406. useLightmapAsShadowmap: boolean;
  41407. private _diffuseFresnelParameters;
  41408. /**
  41409. * Define the diffuse fresnel parameters of the material.
  41410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41411. */
  41412. diffuseFresnelParameters: FresnelParameters;
  41413. private _opacityFresnelParameters;
  41414. /**
  41415. * Define the opacity fresnel parameters of the material.
  41416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41417. */
  41418. opacityFresnelParameters: FresnelParameters;
  41419. private _reflectionFresnelParameters;
  41420. /**
  41421. * Define the reflection fresnel parameters of the material.
  41422. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41423. */
  41424. reflectionFresnelParameters: FresnelParameters;
  41425. private _refractionFresnelParameters;
  41426. /**
  41427. * Define the refraction fresnel parameters of the material.
  41428. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41429. */
  41430. refractionFresnelParameters: FresnelParameters;
  41431. private _emissiveFresnelParameters;
  41432. /**
  41433. * Define the emissive fresnel parameters of the material.
  41434. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41435. */
  41436. emissiveFresnelParameters: FresnelParameters;
  41437. private _useReflectionFresnelFromSpecular;
  41438. /**
  41439. * If true automatically deducts the fresnels values from the material specularity.
  41440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41441. */
  41442. useReflectionFresnelFromSpecular: boolean;
  41443. private _useGlossinessFromSpecularMapAlpha;
  41444. /**
  41445. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41446. */
  41447. useGlossinessFromSpecularMapAlpha: boolean;
  41448. private _maxSimultaneousLights;
  41449. /**
  41450. * Defines the maximum number of lights that can be used in the material
  41451. */
  41452. maxSimultaneousLights: number;
  41453. private _invertNormalMapX;
  41454. /**
  41455. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41456. */
  41457. invertNormalMapX: boolean;
  41458. private _invertNormalMapY;
  41459. /**
  41460. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41461. */
  41462. invertNormalMapY: boolean;
  41463. private _twoSidedLighting;
  41464. /**
  41465. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41466. */
  41467. twoSidedLighting: boolean;
  41468. /**
  41469. * Default configuration related to image processing available in the standard Material.
  41470. */
  41471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41472. /**
  41473. * Gets the image processing configuration used either in this material.
  41474. */
  41475. /**
  41476. * Sets the Default image processing configuration used either in the this material.
  41477. *
  41478. * If sets to null, the scene one is in use.
  41479. */
  41480. imageProcessingConfiguration: ImageProcessingConfiguration;
  41481. /**
  41482. * Keep track of the image processing observer to allow dispose and replace.
  41483. */
  41484. private _imageProcessingObserver;
  41485. /**
  41486. * Attaches a new image processing configuration to the Standard Material.
  41487. * @param configuration
  41488. */
  41489. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41490. /**
  41491. * Gets wether the color curves effect is enabled.
  41492. */
  41493. /**
  41494. * Sets wether the color curves effect is enabled.
  41495. */
  41496. cameraColorCurvesEnabled: boolean;
  41497. /**
  41498. * Gets wether the color grading effect is enabled.
  41499. */
  41500. /**
  41501. * Gets wether the color grading effect is enabled.
  41502. */
  41503. cameraColorGradingEnabled: boolean;
  41504. /**
  41505. * Gets wether tonemapping is enabled or not.
  41506. */
  41507. /**
  41508. * Sets wether tonemapping is enabled or not
  41509. */
  41510. cameraToneMappingEnabled: boolean;
  41511. /**
  41512. * The camera exposure used on this material.
  41513. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41514. * This corresponds to a photographic exposure.
  41515. */
  41516. /**
  41517. * The camera exposure used on this material.
  41518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41519. * This corresponds to a photographic exposure.
  41520. */
  41521. cameraExposure: number;
  41522. /**
  41523. * Gets The camera contrast used on this material.
  41524. */
  41525. /**
  41526. * Sets The camera contrast used on this material.
  41527. */
  41528. cameraContrast: number;
  41529. /**
  41530. * Gets the Color Grading 2D Lookup Texture.
  41531. */
  41532. /**
  41533. * Sets the Color Grading 2D Lookup Texture.
  41534. */
  41535. cameraColorGradingTexture: Nullable<BaseTexture>;
  41536. /**
  41537. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41538. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41539. * 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;
  41540. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41541. */
  41542. /**
  41543. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41544. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41545. * 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;
  41546. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41547. */
  41548. cameraColorCurves: Nullable<ColorCurves>;
  41549. /**
  41550. * Custom callback helping to override the default shader used in the material.
  41551. */
  41552. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41553. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41554. protected _worldViewProjectionMatrix: Matrix;
  41555. protected _globalAmbientColor: Color3;
  41556. protected _useLogarithmicDepth: boolean;
  41557. /**
  41558. * Instantiates a new standard material.
  41559. * This is the default material used in Babylon. It is the best trade off between quality
  41560. * and performances.
  41561. * @see http://doc.babylonjs.com/babylon101/materials
  41562. * @param name Define the name of the material in the scene
  41563. * @param scene Define the scene the material belong to
  41564. */
  41565. constructor(name: string, scene: Scene);
  41566. /**
  41567. * Gets a boolean indicating that current material needs to register RTT
  41568. */
  41569. readonly hasRenderTargetTextures: boolean;
  41570. /**
  41571. * Gets the current class name of the material e.g. "StandardMaterial"
  41572. * Mainly use in serialization.
  41573. * @returns the class name
  41574. */
  41575. getClassName(): string;
  41576. /**
  41577. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41578. * You can try switching to logarithmic depth.
  41579. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41580. */
  41581. useLogarithmicDepth: boolean;
  41582. /**
  41583. * Specifies if the material will require alpha blending
  41584. * @returns a boolean specifying if alpha blending is needed
  41585. */
  41586. needAlphaBlending(): boolean;
  41587. /**
  41588. * Specifies if this material should be rendered in alpha test mode
  41589. * @returns a boolean specifying if an alpha test is needed.
  41590. */
  41591. needAlphaTesting(): boolean;
  41592. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41593. /**
  41594. * Get the texture used for alpha test purpose.
  41595. * @returns the diffuse texture in case of the standard material.
  41596. */
  41597. getAlphaTestTexture(): Nullable<BaseTexture>;
  41598. /**
  41599. * Get if the submesh is ready to be used and all its information available.
  41600. * Child classes can use it to update shaders
  41601. * @param mesh defines the mesh to check
  41602. * @param subMesh defines which submesh to check
  41603. * @param useInstances specifies that instances should be used
  41604. * @returns a boolean indicating that the submesh is ready or not
  41605. */
  41606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41607. /**
  41608. * Builds the material UBO layouts.
  41609. * Used internally during the effect preparation.
  41610. */
  41611. buildUniformLayout(): void;
  41612. /**
  41613. * Unbinds the material from the mesh
  41614. */
  41615. unbind(): void;
  41616. /**
  41617. * Binds the submesh to this material by preparing the effect and shader to draw
  41618. * @param world defines the world transformation matrix
  41619. * @param mesh defines the mesh containing the submesh
  41620. * @param subMesh defines the submesh to bind the material to
  41621. */
  41622. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41623. /**
  41624. * Get the list of animatables in the material.
  41625. * @returns the list of animatables object used in the material
  41626. */
  41627. getAnimatables(): IAnimatable[];
  41628. /**
  41629. * Gets the active textures from the material
  41630. * @returns an array of textures
  41631. */
  41632. getActiveTextures(): BaseTexture[];
  41633. /**
  41634. * Specifies if the material uses a texture
  41635. * @param texture defines the texture to check against the material
  41636. * @returns a boolean specifying if the material uses the texture
  41637. */
  41638. hasTexture(texture: BaseTexture): boolean;
  41639. /**
  41640. * Disposes the material
  41641. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41642. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41643. */
  41644. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41645. /**
  41646. * Makes a duplicate of the material, and gives it a new name
  41647. * @param name defines the new name for the duplicated material
  41648. * @returns the cloned material
  41649. */
  41650. clone(name: string): StandardMaterial;
  41651. /**
  41652. * Serializes this material in a JSON representation
  41653. * @returns the serialized material object
  41654. */
  41655. serialize(): any;
  41656. /**
  41657. * Creates a standard material from parsed material data
  41658. * @param source defines the JSON representation of the material
  41659. * @param scene defines the hosting scene
  41660. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41661. * @returns a new standard material
  41662. */
  41663. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41664. /**
  41665. * Are diffuse textures enabled in the application.
  41666. */
  41667. static DiffuseTextureEnabled: boolean;
  41668. /**
  41669. * Are ambient textures enabled in the application.
  41670. */
  41671. static AmbientTextureEnabled: boolean;
  41672. /**
  41673. * Are opacity textures enabled in the application.
  41674. */
  41675. static OpacityTextureEnabled: boolean;
  41676. /**
  41677. * Are reflection textures enabled in the application.
  41678. */
  41679. static ReflectionTextureEnabled: boolean;
  41680. /**
  41681. * Are emissive textures enabled in the application.
  41682. */
  41683. static EmissiveTextureEnabled: boolean;
  41684. /**
  41685. * Are specular textures enabled in the application.
  41686. */
  41687. static SpecularTextureEnabled: boolean;
  41688. /**
  41689. * Are bump textures enabled in the application.
  41690. */
  41691. static BumpTextureEnabled: boolean;
  41692. /**
  41693. * Are lightmap textures enabled in the application.
  41694. */
  41695. static LightmapTextureEnabled: boolean;
  41696. /**
  41697. * Are refraction textures enabled in the application.
  41698. */
  41699. static RefractionTextureEnabled: boolean;
  41700. /**
  41701. * Are color grading textures enabled in the application.
  41702. */
  41703. static ColorGradingTextureEnabled: boolean;
  41704. /**
  41705. * Are fresnels enabled in the application.
  41706. */
  41707. static FresnelEnabled: boolean;
  41708. }
  41709. }
  41710. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41711. import { Scene } from "babylonjs/scene";
  41712. import { Texture } from "babylonjs/Materials/Textures/texture";
  41713. /**
  41714. * A class extending Texture allowing drawing on a texture
  41715. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41716. */
  41717. export class DynamicTexture extends Texture {
  41718. private _generateMipMaps;
  41719. private _canvas;
  41720. private _context;
  41721. private _engine;
  41722. /**
  41723. * Creates a DynamicTexture
  41724. * @param name defines the name of the texture
  41725. * @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
  41726. * @param scene defines the scene where you want the texture
  41727. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41728. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41729. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41730. */
  41731. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41732. /**
  41733. * Get the current class name of the texture useful for serialization or dynamic coding.
  41734. * @returns "DynamicTexture"
  41735. */
  41736. getClassName(): string;
  41737. /**
  41738. * Gets the current state of canRescale
  41739. */
  41740. readonly canRescale: boolean;
  41741. private _recreate;
  41742. /**
  41743. * Scales the texture
  41744. * @param ratio the scale factor to apply to both width and height
  41745. */
  41746. scale(ratio: number): void;
  41747. /**
  41748. * Resizes the texture
  41749. * @param width the new width
  41750. * @param height the new height
  41751. */
  41752. scaleTo(width: number, height: number): void;
  41753. /**
  41754. * Gets the context of the canvas used by the texture
  41755. * @returns the canvas context of the dynamic texture
  41756. */
  41757. getContext(): CanvasRenderingContext2D;
  41758. /**
  41759. * Clears the texture
  41760. */
  41761. clear(): void;
  41762. /**
  41763. * Updates the texture
  41764. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41765. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41766. */
  41767. update(invertY?: boolean, premulAlpha?: boolean): void;
  41768. /**
  41769. * Draws text onto the texture
  41770. * @param text defines the text to be drawn
  41771. * @param x defines the placement of the text from the left
  41772. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41773. * @param font defines the font to be used with font-style, font-size, font-name
  41774. * @param color defines the color used for the text
  41775. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41776. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41777. * @param update defines whether texture is immediately update (default is true)
  41778. */
  41779. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41780. /**
  41781. * Clones the texture
  41782. * @returns the clone of the texture.
  41783. */
  41784. clone(): DynamicTexture;
  41785. /**
  41786. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41787. * @returns a serialized dynamic texture object
  41788. */
  41789. serialize(): any;
  41790. /** @hidden */
  41791. _rebuild(): void;
  41792. }
  41793. }
  41794. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41797. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41798. /** @hidden */
  41799. export var imageProcessingPixelShader: {
  41800. name: string;
  41801. shader: string;
  41802. };
  41803. }
  41804. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41805. import { Nullable } from "babylonjs/types";
  41806. import { Color4 } from "babylonjs/Maths/math.color";
  41807. import { Camera } from "babylonjs/Cameras/camera";
  41808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41809. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41810. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41812. import { Engine } from "babylonjs/Engines/engine";
  41813. import "babylonjs/Shaders/imageProcessing.fragment";
  41814. import "babylonjs/Shaders/postprocess.vertex";
  41815. /**
  41816. * ImageProcessingPostProcess
  41817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41818. */
  41819. export class ImageProcessingPostProcess extends PostProcess {
  41820. /**
  41821. * Default configuration related to image processing available in the PBR Material.
  41822. */
  41823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41824. /**
  41825. * Gets the image processing configuration used either in this material.
  41826. */
  41827. /**
  41828. * Sets the Default image processing configuration used either in the this material.
  41829. *
  41830. * If sets to null, the scene one is in use.
  41831. */
  41832. imageProcessingConfiguration: ImageProcessingConfiguration;
  41833. /**
  41834. * Keep track of the image processing observer to allow dispose and replace.
  41835. */
  41836. private _imageProcessingObserver;
  41837. /**
  41838. * Attaches a new image processing configuration to the PBR Material.
  41839. * @param configuration
  41840. */
  41841. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41842. /**
  41843. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41844. */
  41845. /**
  41846. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41847. */
  41848. colorCurves: Nullable<ColorCurves>;
  41849. /**
  41850. * Gets wether the color curves effect is enabled.
  41851. */
  41852. /**
  41853. * Sets wether the color curves effect is enabled.
  41854. */
  41855. colorCurvesEnabled: boolean;
  41856. /**
  41857. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41858. */
  41859. /**
  41860. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41861. */
  41862. colorGradingTexture: Nullable<BaseTexture>;
  41863. /**
  41864. * Gets wether the color grading effect is enabled.
  41865. */
  41866. /**
  41867. * Gets wether the color grading effect is enabled.
  41868. */
  41869. colorGradingEnabled: boolean;
  41870. /**
  41871. * Gets exposure used in the effect.
  41872. */
  41873. /**
  41874. * Sets exposure used in the effect.
  41875. */
  41876. exposure: number;
  41877. /**
  41878. * Gets wether tonemapping is enabled or not.
  41879. */
  41880. /**
  41881. * Sets wether tonemapping is enabled or not
  41882. */
  41883. toneMappingEnabled: boolean;
  41884. /**
  41885. * Gets the type of tone mapping effect.
  41886. */
  41887. /**
  41888. * Sets the type of tone mapping effect.
  41889. */
  41890. toneMappingType: number;
  41891. /**
  41892. * Gets contrast used in the effect.
  41893. */
  41894. /**
  41895. * Sets contrast used in the effect.
  41896. */
  41897. contrast: number;
  41898. /**
  41899. * Gets Vignette stretch size.
  41900. */
  41901. /**
  41902. * Sets Vignette stretch size.
  41903. */
  41904. vignetteStretch: number;
  41905. /**
  41906. * Gets Vignette centre X Offset.
  41907. */
  41908. /**
  41909. * Sets Vignette centre X Offset.
  41910. */
  41911. vignetteCentreX: number;
  41912. /**
  41913. * Gets Vignette centre Y Offset.
  41914. */
  41915. /**
  41916. * Sets Vignette centre Y Offset.
  41917. */
  41918. vignetteCentreY: number;
  41919. /**
  41920. * Gets Vignette weight or intensity of the vignette effect.
  41921. */
  41922. /**
  41923. * Sets Vignette weight or intensity of the vignette effect.
  41924. */
  41925. vignetteWeight: number;
  41926. /**
  41927. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41928. * if vignetteEnabled is set to true.
  41929. */
  41930. /**
  41931. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41932. * if vignetteEnabled is set to true.
  41933. */
  41934. vignetteColor: Color4;
  41935. /**
  41936. * Gets Camera field of view used by the Vignette effect.
  41937. */
  41938. /**
  41939. * Sets Camera field of view used by the Vignette effect.
  41940. */
  41941. vignetteCameraFov: number;
  41942. /**
  41943. * Gets the vignette blend mode allowing different kind of effect.
  41944. */
  41945. /**
  41946. * Sets the vignette blend mode allowing different kind of effect.
  41947. */
  41948. vignetteBlendMode: number;
  41949. /**
  41950. * Gets wether the vignette effect is enabled.
  41951. */
  41952. /**
  41953. * Sets wether the vignette effect is enabled.
  41954. */
  41955. vignetteEnabled: boolean;
  41956. private _fromLinearSpace;
  41957. /**
  41958. * Gets wether the input of the processing is in Gamma or Linear Space.
  41959. */
  41960. /**
  41961. * Sets wether the input of the processing is in Gamma or Linear Space.
  41962. */
  41963. fromLinearSpace: boolean;
  41964. /**
  41965. * Defines cache preventing GC.
  41966. */
  41967. private _defines;
  41968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41969. /**
  41970. * "ImageProcessingPostProcess"
  41971. * @returns "ImageProcessingPostProcess"
  41972. */
  41973. getClassName(): string;
  41974. protected _updateParameters(): void;
  41975. dispose(camera?: Camera): void;
  41976. }
  41977. }
  41978. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41979. import { Scene } from "babylonjs/scene";
  41980. import { Color3 } from "babylonjs/Maths/math.color";
  41981. import { Mesh } from "babylonjs/Meshes/mesh";
  41982. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41983. import { Nullable } from "babylonjs/types";
  41984. /**
  41985. * Class containing static functions to help procedurally build meshes
  41986. */
  41987. export class GroundBuilder {
  41988. /**
  41989. * Creates a ground mesh
  41990. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41991. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41993. * @param name defines the name of the mesh
  41994. * @param options defines the options used to create the mesh
  41995. * @param scene defines the hosting scene
  41996. * @returns the ground mesh
  41997. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41998. */
  41999. static CreateGround(name: string, options: {
  42000. width?: number;
  42001. height?: number;
  42002. subdivisions?: number;
  42003. subdivisionsX?: number;
  42004. subdivisionsY?: number;
  42005. updatable?: boolean;
  42006. }, scene: any): Mesh;
  42007. /**
  42008. * Creates a tiled ground mesh
  42009. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42010. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42011. * * 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
  42012. * * 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
  42013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42014. * @param name defines the name of the mesh
  42015. * @param options defines the options used to create the mesh
  42016. * @param scene defines the hosting scene
  42017. * @returns the tiled ground mesh
  42018. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42019. */
  42020. static CreateTiledGround(name: string, options: {
  42021. xmin: number;
  42022. zmin: number;
  42023. xmax: number;
  42024. zmax: number;
  42025. subdivisions?: {
  42026. w: number;
  42027. h: number;
  42028. };
  42029. precision?: {
  42030. w: number;
  42031. h: number;
  42032. };
  42033. updatable?: boolean;
  42034. }, scene?: Nullable<Scene>): Mesh;
  42035. /**
  42036. * Creates a ground mesh from a height map
  42037. * * The parameter `url` sets the URL of the height map image resource.
  42038. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42039. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42040. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42041. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42042. * * 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.
  42043. * * 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).
  42044. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42046. * @param name defines the name of the mesh
  42047. * @param url defines the url to the height map
  42048. * @param options defines the options used to create the mesh
  42049. * @param scene defines the hosting scene
  42050. * @returns the ground mesh
  42051. * @see https://doc.babylonjs.com/babylon101/height_map
  42052. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42053. */
  42054. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42055. width?: number;
  42056. height?: number;
  42057. subdivisions?: number;
  42058. minHeight?: number;
  42059. maxHeight?: number;
  42060. colorFilter?: Color3;
  42061. alphaFilter?: number;
  42062. updatable?: boolean;
  42063. onReady?: (mesh: GroundMesh) => void;
  42064. }, scene?: Nullable<Scene>): GroundMesh;
  42065. }
  42066. }
  42067. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42068. import { Vector4 } from "babylonjs/Maths/math.vector";
  42069. import { Mesh } from "babylonjs/Meshes/mesh";
  42070. /**
  42071. * Class containing static functions to help procedurally build meshes
  42072. */
  42073. export class TorusBuilder {
  42074. /**
  42075. * Creates a torus mesh
  42076. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42077. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42078. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42082. * @param name defines the name of the mesh
  42083. * @param options defines the options used to create the mesh
  42084. * @param scene defines the hosting scene
  42085. * @returns the torus mesh
  42086. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42087. */
  42088. static CreateTorus(name: string, options: {
  42089. diameter?: number;
  42090. thickness?: number;
  42091. tessellation?: number;
  42092. updatable?: boolean;
  42093. sideOrientation?: number;
  42094. frontUVs?: Vector4;
  42095. backUVs?: Vector4;
  42096. }, scene: any): Mesh;
  42097. }
  42098. }
  42099. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42100. import { Vector4 } from "babylonjs/Maths/math.vector";
  42101. import { Color4 } from "babylonjs/Maths/math.color";
  42102. import { Mesh } from "babylonjs/Meshes/mesh";
  42103. /**
  42104. * Class containing static functions to help procedurally build meshes
  42105. */
  42106. export class CylinderBuilder {
  42107. /**
  42108. * Creates a cylinder or a cone mesh
  42109. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42110. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42111. * * 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.
  42112. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42113. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42114. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42115. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42116. * * 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).
  42117. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42118. * * 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).
  42119. * * 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
  42120. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42121. * * 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
  42122. * * 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.
  42123. * * If `enclose` is false, a ring surface is one element.
  42124. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42125. * * 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
  42126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param options defines the options used to create the mesh
  42131. * @param scene defines the hosting scene
  42132. * @returns the cylinder mesh
  42133. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42134. */
  42135. static CreateCylinder(name: string, options: {
  42136. height?: number;
  42137. diameterTop?: number;
  42138. diameterBottom?: number;
  42139. diameter?: number;
  42140. tessellation?: number;
  42141. subdivisions?: number;
  42142. arc?: number;
  42143. faceColors?: Color4[];
  42144. faceUV?: Vector4[];
  42145. updatable?: boolean;
  42146. hasRings?: boolean;
  42147. enclose?: boolean;
  42148. cap?: number;
  42149. sideOrientation?: number;
  42150. frontUVs?: Vector4;
  42151. backUVs?: Vector4;
  42152. }, scene: any): Mesh;
  42153. }
  42154. }
  42155. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42156. import { Observable } from "babylonjs/Misc/observable";
  42157. import { Nullable } from "babylonjs/types";
  42158. import { Camera } from "babylonjs/Cameras/camera";
  42159. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42160. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42161. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42162. import { Scene } from "babylonjs/scene";
  42163. import { Vector3 } from "babylonjs/Maths/math.vector";
  42164. import { Color3 } from "babylonjs/Maths/math.color";
  42165. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42167. import { Mesh } from "babylonjs/Meshes/mesh";
  42168. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42169. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42170. import "babylonjs/Meshes/Builders/groundBuilder";
  42171. import "babylonjs/Meshes/Builders/torusBuilder";
  42172. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42173. import "babylonjs/Gamepads/gamepadSceneComponent";
  42174. import "babylonjs/Animations/animatable";
  42175. /**
  42176. * Options to modify the vr teleportation behavior.
  42177. */
  42178. export interface VRTeleportationOptions {
  42179. /**
  42180. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42181. */
  42182. floorMeshName?: string;
  42183. /**
  42184. * A list of meshes to be used as the teleportation floor. (default: empty)
  42185. */
  42186. floorMeshes?: Mesh[];
  42187. }
  42188. /**
  42189. * Options to modify the vr experience helper's behavior.
  42190. */
  42191. export interface VRExperienceHelperOptions extends WebVROptions {
  42192. /**
  42193. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42194. */
  42195. createDeviceOrientationCamera?: boolean;
  42196. /**
  42197. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42198. */
  42199. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42200. /**
  42201. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42202. */
  42203. laserToggle?: boolean;
  42204. /**
  42205. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42206. */
  42207. floorMeshes?: Mesh[];
  42208. /**
  42209. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42210. */
  42211. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42212. }
  42213. /**
  42214. * Event containing information after VR has been entered
  42215. */
  42216. export class OnAfterEnteringVRObservableEvent {
  42217. /**
  42218. * If entering vr was successful
  42219. */
  42220. success: boolean;
  42221. }
  42222. /**
  42223. * Helps to quickly add VR support to an existing scene.
  42224. * See http://doc.babylonjs.com/how_to/webvr_helper
  42225. */
  42226. export class VRExperienceHelper {
  42227. /** Options to modify the vr experience helper's behavior. */
  42228. webVROptions: VRExperienceHelperOptions;
  42229. private _scene;
  42230. private _position;
  42231. private _btnVR;
  42232. private _btnVRDisplayed;
  42233. private _webVRsupported;
  42234. private _webVRready;
  42235. private _webVRrequesting;
  42236. private _webVRpresenting;
  42237. private _hasEnteredVR;
  42238. private _fullscreenVRpresenting;
  42239. private _canvas;
  42240. private _webVRCamera;
  42241. private _vrDeviceOrientationCamera;
  42242. private _deviceOrientationCamera;
  42243. private _existingCamera;
  42244. private _onKeyDown;
  42245. private _onVrDisplayPresentChange;
  42246. private _onVRDisplayChanged;
  42247. private _onVRRequestPresentStart;
  42248. private _onVRRequestPresentComplete;
  42249. /**
  42250. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42251. */
  42252. enableGazeEvenWhenNoPointerLock: boolean;
  42253. /**
  42254. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42255. */
  42256. exitVROnDoubleTap: boolean;
  42257. /**
  42258. * Observable raised right before entering VR.
  42259. */
  42260. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42261. /**
  42262. * Observable raised when entering VR has completed.
  42263. */
  42264. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42265. /**
  42266. * Observable raised when exiting VR.
  42267. */
  42268. onExitingVRObservable: Observable<VRExperienceHelper>;
  42269. /**
  42270. * Observable raised when controller mesh is loaded.
  42271. */
  42272. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42273. /** Return this.onEnteringVRObservable
  42274. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42275. */
  42276. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42277. /** Return this.onExitingVRObservable
  42278. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42279. */
  42280. readonly onExitingVR: Observable<VRExperienceHelper>;
  42281. /** Return this.onControllerMeshLoadedObservable
  42282. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42283. */
  42284. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42285. private _rayLength;
  42286. private _useCustomVRButton;
  42287. private _teleportationRequested;
  42288. private _teleportActive;
  42289. private _floorMeshName;
  42290. private _floorMeshesCollection;
  42291. private _rotationAllowed;
  42292. private _teleportBackwardsVector;
  42293. private _teleportationTarget;
  42294. private _isDefaultTeleportationTarget;
  42295. private _postProcessMove;
  42296. private _teleportationFillColor;
  42297. private _teleportationBorderColor;
  42298. private _rotationAngle;
  42299. private _haloCenter;
  42300. private _cameraGazer;
  42301. private _padSensibilityUp;
  42302. private _padSensibilityDown;
  42303. private _leftController;
  42304. private _rightController;
  42305. /**
  42306. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42307. */
  42308. onNewMeshSelected: Observable<AbstractMesh>;
  42309. /**
  42310. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42311. * This observable will provide the mesh and the controller used to select the mesh
  42312. */
  42313. onMeshSelectedWithController: Observable<{
  42314. mesh: AbstractMesh;
  42315. controller: WebVRController;
  42316. }>;
  42317. /**
  42318. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42319. */
  42320. onNewMeshPicked: Observable<PickingInfo>;
  42321. private _circleEase;
  42322. /**
  42323. * Observable raised before camera teleportation
  42324. */
  42325. onBeforeCameraTeleport: Observable<Vector3>;
  42326. /**
  42327. * Observable raised after camera teleportation
  42328. */
  42329. onAfterCameraTeleport: Observable<Vector3>;
  42330. /**
  42331. * Observable raised when current selected mesh gets unselected
  42332. */
  42333. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42334. private _raySelectionPredicate;
  42335. /**
  42336. * To be optionaly changed by user to define custom ray selection
  42337. */
  42338. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42339. /**
  42340. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42341. */
  42342. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42343. /**
  42344. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42345. */
  42346. teleportationEnabled: boolean;
  42347. private _defaultHeight;
  42348. private _teleportationInitialized;
  42349. private _interactionsEnabled;
  42350. private _interactionsRequested;
  42351. private _displayGaze;
  42352. private _displayLaserPointer;
  42353. /**
  42354. * The mesh used to display where the user is going to teleport.
  42355. */
  42356. /**
  42357. * Sets the mesh to be used to display where the user is going to teleport.
  42358. */
  42359. teleportationTarget: Mesh;
  42360. /**
  42361. * 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
  42362. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42363. * See http://doc.babylonjs.com/resources/baking_transformations
  42364. */
  42365. gazeTrackerMesh: Mesh;
  42366. /**
  42367. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42368. */
  42369. updateGazeTrackerScale: boolean;
  42370. /**
  42371. * If the gaze trackers color should be updated when selecting meshes
  42372. */
  42373. updateGazeTrackerColor: boolean;
  42374. /**
  42375. * The gaze tracking mesh corresponding to the left controller
  42376. */
  42377. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42378. /**
  42379. * The gaze tracking mesh corresponding to the right controller
  42380. */
  42381. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42382. /**
  42383. * If the ray of the gaze should be displayed.
  42384. */
  42385. /**
  42386. * Sets if the ray of the gaze should be displayed.
  42387. */
  42388. displayGaze: boolean;
  42389. /**
  42390. * If the ray of the LaserPointer should be displayed.
  42391. */
  42392. /**
  42393. * Sets if the ray of the LaserPointer should be displayed.
  42394. */
  42395. displayLaserPointer: boolean;
  42396. /**
  42397. * The deviceOrientationCamera used as the camera when not in VR.
  42398. */
  42399. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42400. /**
  42401. * Based on the current WebVR support, returns the current VR camera used.
  42402. */
  42403. readonly currentVRCamera: Nullable<Camera>;
  42404. /**
  42405. * The webVRCamera which is used when in VR.
  42406. */
  42407. readonly webVRCamera: WebVRFreeCamera;
  42408. /**
  42409. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42410. */
  42411. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42412. /**
  42413. * The html button that is used to trigger entering into VR.
  42414. */
  42415. readonly vrButton: Nullable<HTMLButtonElement>;
  42416. private readonly _teleportationRequestInitiated;
  42417. /**
  42418. * Defines wether or not Pointer lock should be requested when switching to
  42419. * full screen.
  42420. */
  42421. requestPointerLockOnFullScreen: boolean;
  42422. /**
  42423. * Instantiates a VRExperienceHelper.
  42424. * Helps to quickly add VR support to an existing scene.
  42425. * @param scene The scene the VRExperienceHelper belongs to.
  42426. * @param webVROptions Options to modify the vr experience helper's behavior.
  42427. */
  42428. constructor(scene: Scene,
  42429. /** Options to modify the vr experience helper's behavior. */
  42430. webVROptions?: VRExperienceHelperOptions);
  42431. private _onDefaultMeshLoaded;
  42432. private _onResize;
  42433. private _onFullscreenChange;
  42434. /**
  42435. * Gets a value indicating if we are currently in VR mode.
  42436. */
  42437. readonly isInVRMode: boolean;
  42438. private onVrDisplayPresentChange;
  42439. private onVRDisplayChanged;
  42440. private moveButtonToBottomRight;
  42441. private displayVRButton;
  42442. private updateButtonVisibility;
  42443. private _cachedAngularSensibility;
  42444. /**
  42445. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42446. * Otherwise, will use the fullscreen API.
  42447. */
  42448. enterVR(): void;
  42449. /**
  42450. * Attempt to exit VR, or fullscreen.
  42451. */
  42452. exitVR(): void;
  42453. /**
  42454. * The position of the vr experience helper.
  42455. */
  42456. /**
  42457. * Sets the position of the vr experience helper.
  42458. */
  42459. position: Vector3;
  42460. /**
  42461. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42462. */
  42463. enableInteractions(): void;
  42464. private readonly _noControllerIsActive;
  42465. private beforeRender;
  42466. private _isTeleportationFloor;
  42467. /**
  42468. * Adds a floor mesh to be used for teleportation.
  42469. * @param floorMesh the mesh to be used for teleportation.
  42470. */
  42471. addFloorMesh(floorMesh: Mesh): void;
  42472. /**
  42473. * Removes a floor mesh from being used for teleportation.
  42474. * @param floorMesh the mesh to be removed.
  42475. */
  42476. removeFloorMesh(floorMesh: Mesh): void;
  42477. /**
  42478. * Enables interactions and teleportation using the VR controllers and gaze.
  42479. * @param vrTeleportationOptions options to modify teleportation behavior.
  42480. */
  42481. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42482. private _onNewGamepadConnected;
  42483. private _tryEnableInteractionOnController;
  42484. private _onNewGamepadDisconnected;
  42485. private _enableInteractionOnController;
  42486. private _checkTeleportWithRay;
  42487. private _checkRotate;
  42488. private _checkTeleportBackwards;
  42489. private _enableTeleportationOnController;
  42490. private _createTeleportationCircles;
  42491. private _displayTeleportationTarget;
  42492. private _hideTeleportationTarget;
  42493. private _rotateCamera;
  42494. private _moveTeleportationSelectorTo;
  42495. private _workingVector;
  42496. private _workingQuaternion;
  42497. private _workingMatrix;
  42498. /**
  42499. * Teleports the users feet to the desired location
  42500. * @param location The location where the user's feet should be placed
  42501. */
  42502. teleportCamera(location: Vector3): void;
  42503. private _convertNormalToDirectionOfRay;
  42504. private _castRayAndSelectObject;
  42505. private _notifySelectedMeshUnselected;
  42506. /**
  42507. * Sets the color of the laser ray from the vr controllers.
  42508. * @param color new color for the ray.
  42509. */
  42510. changeLaserColor(color: Color3): void;
  42511. /**
  42512. * Sets the color of the ray from the vr headsets gaze.
  42513. * @param color new color for the ray.
  42514. */
  42515. changeGazeColor(color: Color3): void;
  42516. /**
  42517. * Exits VR and disposes of the vr experience helper
  42518. */
  42519. dispose(): void;
  42520. /**
  42521. * Gets the name of the VRExperienceHelper class
  42522. * @returns "VRExperienceHelper"
  42523. */
  42524. getClassName(): string;
  42525. }
  42526. }
  42527. declare module "babylonjs/Cameras/VR/index" {
  42528. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42529. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42530. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42531. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42532. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42533. export * from "babylonjs/Cameras/VR/webVRCamera";
  42534. }
  42535. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42536. import { Observable } from "babylonjs/Misc/observable";
  42537. import { Nullable } from "babylonjs/types";
  42538. import { IDisposable, Scene } from "babylonjs/scene";
  42539. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42540. /**
  42541. * Manages an XRSession to work with Babylon's engine
  42542. * @see https://doc.babylonjs.com/how_to/webxr
  42543. */
  42544. export class WebXRSessionManager implements IDisposable {
  42545. private scene;
  42546. /**
  42547. * Fires every time a new xrFrame arrives which can be used to update the camera
  42548. */
  42549. onXRFrameObservable: Observable<any>;
  42550. /**
  42551. * Fires when the xr session is ended either by the device or manually done
  42552. */
  42553. onXRSessionEnded: Observable<any>;
  42554. /**
  42555. * Underlying xr session
  42556. */
  42557. session: XRSession;
  42558. /**
  42559. * Type of reference space used when creating the session
  42560. */
  42561. referenceSpace: XRReferenceSpace;
  42562. /** @hidden */
  42563. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42564. /**
  42565. * Current XR frame
  42566. */
  42567. currentFrame: Nullable<XRFrame>;
  42568. private _xrNavigator;
  42569. private baseLayer;
  42570. /**
  42571. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42572. * @param scene The scene which the session should be created for
  42573. */
  42574. constructor(scene: Scene);
  42575. /**
  42576. * Initializes the manager
  42577. * After initialization enterXR can be called to start an XR session
  42578. * @returns Promise which resolves after it is initialized
  42579. */
  42580. initializeAsync(): Promise<void>;
  42581. /**
  42582. * Initializes an xr session
  42583. * @param xrSessionMode mode to initialize
  42584. * @returns a promise which will resolve once the session has been initialized
  42585. */
  42586. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42587. /**
  42588. * Sets the reference space on the xr session
  42589. * @param referenceSpace space to set
  42590. * @returns a promise that will resolve once the reference space has been set
  42591. */
  42592. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42593. /**
  42594. * Updates the render state of the session
  42595. * @param state state to set
  42596. * @returns a promise that resolves once the render state has been updated
  42597. */
  42598. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42599. /**
  42600. * Starts rendering to the xr layer
  42601. * @returns a promise that will resolve once rendering has started
  42602. */
  42603. startRenderingToXRAsync(): Promise<void>;
  42604. /**
  42605. * Stops the xrSession and restores the renderloop
  42606. * @returns Promise which resolves after it exits XR
  42607. */
  42608. exitXRAsync(): Promise<unknown>;
  42609. /**
  42610. * Checks if a session would be supported for the creation options specified
  42611. * @param sessionMode session mode to check if supported eg. immersive-vr
  42612. * @returns true if supported
  42613. */
  42614. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42615. /**
  42616. * @hidden
  42617. * Converts the render layer of xrSession to a render target
  42618. * @param session session to create render target for
  42619. * @param scene scene the new render target should be created for
  42620. */
  42621. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42622. /**
  42623. * Disposes of the session manager
  42624. */
  42625. dispose(): void;
  42626. }
  42627. }
  42628. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42629. import { Scene } from "babylonjs/scene";
  42630. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42631. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42632. /**
  42633. * WebXR Camera which holds the views for the xrSession
  42634. * @see https://doc.babylonjs.com/how_to/webxr
  42635. */
  42636. export class WebXRCamera extends FreeCamera {
  42637. private static _TmpMatrix;
  42638. /**
  42639. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42640. * @param name the name of the camera
  42641. * @param scene the scene to add the camera to
  42642. */
  42643. constructor(name: string, scene: Scene);
  42644. private _updateNumberOfRigCameras;
  42645. /** @hidden */
  42646. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42647. /**
  42648. * Updates the cameras position from the current pose information of the XR session
  42649. * @param xrSessionManager the session containing pose information
  42650. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42651. */
  42652. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42653. }
  42654. }
  42655. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42656. import { Nullable } from "babylonjs/types";
  42657. import { IDisposable } from "babylonjs/scene";
  42658. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42659. /**
  42660. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42661. */
  42662. export class WebXRManagedOutputCanvas implements IDisposable {
  42663. private helper;
  42664. private _canvas;
  42665. /**
  42666. * xrpresent context of the canvas which can be used to display/mirror xr content
  42667. */
  42668. canvasContext: WebGLRenderingContext;
  42669. /**
  42670. * xr layer for the canvas
  42671. */
  42672. xrLayer: Nullable<XRWebGLLayer>;
  42673. /**
  42674. * Initializes the xr layer for the session
  42675. * @param xrSession xr session
  42676. * @returns a promise that will resolve once the XR Layer has been created
  42677. */
  42678. initializeXRLayerAsync(xrSession: any): any;
  42679. /**
  42680. * Initializes the canvas to be added/removed upon entering/exiting xr
  42681. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42682. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42683. */
  42684. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42685. /**
  42686. * Disposes of the object
  42687. */
  42688. dispose(): void;
  42689. private _setManagedOutputCanvas;
  42690. private _addCanvas;
  42691. private _removeCanvas;
  42692. }
  42693. }
  42694. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42695. import { Observable } from "babylonjs/Misc/observable";
  42696. import { IDisposable, Scene } from "babylonjs/scene";
  42697. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42699. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42700. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42701. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42702. /**
  42703. * States of the webXR experience
  42704. */
  42705. export enum WebXRState {
  42706. /**
  42707. * Transitioning to being in XR mode
  42708. */
  42709. ENTERING_XR = 0,
  42710. /**
  42711. * Transitioning to non XR mode
  42712. */
  42713. EXITING_XR = 1,
  42714. /**
  42715. * In XR mode and presenting
  42716. */
  42717. IN_XR = 2,
  42718. /**
  42719. * Not entered XR mode
  42720. */
  42721. NOT_IN_XR = 3
  42722. }
  42723. /**
  42724. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42725. * @see https://doc.babylonjs.com/how_to/webxr
  42726. */
  42727. export class WebXRExperienceHelper implements IDisposable {
  42728. private scene;
  42729. /**
  42730. * 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
  42731. */
  42732. container: AbstractMesh;
  42733. /**
  42734. * Camera used to render xr content
  42735. */
  42736. camera: WebXRCamera;
  42737. /**
  42738. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42739. */
  42740. state: WebXRState;
  42741. private _setState;
  42742. private static _TmpVector;
  42743. /**
  42744. * Fires when the state of the experience helper has changed
  42745. */
  42746. onStateChangedObservable: Observable<WebXRState>;
  42747. /** Session manager used to keep track of xr session */
  42748. sessionManager: WebXRSessionManager;
  42749. private _nonVRCamera;
  42750. private _originalSceneAutoClear;
  42751. private _supported;
  42752. /**
  42753. * Creates the experience helper
  42754. * @param scene the scene to attach the experience helper to
  42755. * @returns a promise for the experience helper
  42756. */
  42757. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42758. /**
  42759. * Creates a WebXRExperienceHelper
  42760. * @param scene The scene the helper should be created in
  42761. */
  42762. private constructor();
  42763. /**
  42764. * Exits XR mode and returns the scene to its original state
  42765. * @returns promise that resolves after xr mode has exited
  42766. */
  42767. exitXRAsync(): Promise<unknown>;
  42768. /**
  42769. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42770. * @param sessionCreationOptions options for the XR session
  42771. * @param referenceSpaceType frame of reference of the XR session
  42772. * @param outputCanvas the output canvas that will be used to enter XR mode
  42773. * @returns promise that resolves after xr mode has entered
  42774. */
  42775. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42776. /**
  42777. * Updates the global position of the camera by moving the camera's container
  42778. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42779. * @param position The desired global position of the camera
  42780. */
  42781. setPositionOfCameraUsingContainer(position: Vector3): void;
  42782. /**
  42783. * Rotates the xr camera by rotating the camera's container around the camera's position
  42784. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42785. * @param rotation the desired quaternion rotation to apply to the camera
  42786. */
  42787. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42788. /**
  42789. * Disposes of the experience helper
  42790. */
  42791. dispose(): void;
  42792. }
  42793. }
  42794. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42795. import { Nullable } from "babylonjs/types";
  42796. import { Observable } from "babylonjs/Misc/observable";
  42797. import { IDisposable, Scene } from "babylonjs/scene";
  42798. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42799. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42800. /**
  42801. * Button which can be used to enter a different mode of XR
  42802. */
  42803. export class WebXREnterExitUIButton {
  42804. /** button element */
  42805. element: HTMLElement;
  42806. /** XR initialization options for the button */
  42807. sessionMode: XRSessionMode;
  42808. /** Reference space type */
  42809. referenceSpaceType: XRReferenceSpaceType;
  42810. /**
  42811. * Creates a WebXREnterExitUIButton
  42812. * @param element button element
  42813. * @param sessionMode XR initialization session mode
  42814. * @param referenceSpaceType the type of reference space to be used
  42815. */
  42816. constructor(
  42817. /** button element */
  42818. element: HTMLElement,
  42819. /** XR initialization options for the button */
  42820. sessionMode: XRSessionMode,
  42821. /** Reference space type */
  42822. referenceSpaceType: XRReferenceSpaceType);
  42823. /**
  42824. * Overwritable function which can be used to update the button's visuals when the state changes
  42825. * @param activeButton the current active button in the UI
  42826. */
  42827. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42828. }
  42829. /**
  42830. * Options to create the webXR UI
  42831. */
  42832. export class WebXREnterExitUIOptions {
  42833. /**
  42834. * Context to enter xr with
  42835. */
  42836. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42837. /**
  42838. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42839. */
  42840. customButtons?: Array<WebXREnterExitUIButton>;
  42841. }
  42842. /**
  42843. * UI to allow the user to enter/exit XR mode
  42844. */
  42845. export class WebXREnterExitUI implements IDisposable {
  42846. private scene;
  42847. private _overlay;
  42848. private _buttons;
  42849. private _activeButton;
  42850. /**
  42851. * Fired every time the active button is changed.
  42852. *
  42853. * When xr is entered via a button that launches xr that button will be the callback parameter
  42854. *
  42855. * When exiting xr the callback parameter will be null)
  42856. */
  42857. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42858. /**
  42859. * Creates UI to allow the user to enter/exit XR mode
  42860. * @param scene the scene to add the ui to
  42861. * @param helper the xr experience helper to enter/exit xr with
  42862. * @param options options to configure the UI
  42863. * @returns the created ui
  42864. */
  42865. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42866. private constructor();
  42867. private _updateButtons;
  42868. /**
  42869. * Disposes of the object
  42870. */
  42871. dispose(): void;
  42872. }
  42873. }
  42874. declare module "babylonjs/Cameras/XR/webXRController" {
  42875. import { Nullable } from "babylonjs/types";
  42876. import { Observable } from "babylonjs/Misc/observable";
  42877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42878. import { Ray } from "babylonjs/Culling/ray";
  42879. import { Scene } from "babylonjs/scene";
  42880. /**
  42881. * Represents an XR input
  42882. */
  42883. export class WebXRController {
  42884. private scene;
  42885. /** The underlying input source for the controller */
  42886. inputSource: XRInputSource;
  42887. private parentContainer;
  42888. /**
  42889. * 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
  42890. */
  42891. grip?: AbstractMesh;
  42892. /**
  42893. * Pointer which can be used to select objects or attach a visible laser to
  42894. */
  42895. pointer: AbstractMesh;
  42896. /**
  42897. * Event that fires when the controller is removed/disposed
  42898. */
  42899. onDisposeObservable: Observable<{}>;
  42900. private _tmpMatrix;
  42901. private _tmpQuaternion;
  42902. private _tmpVector;
  42903. /**
  42904. * Creates the controller
  42905. * @see https://doc.babylonjs.com/how_to/webxr
  42906. * @param scene the scene which the controller should be associated to
  42907. * @param inputSource the underlying input source for the controller
  42908. * @param parentContainer parent that the controller meshes should be children of
  42909. */
  42910. constructor(scene: Scene,
  42911. /** The underlying input source for the controller */
  42912. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42913. /**
  42914. * Updates the controller pose based on the given XRFrame
  42915. * @param xrFrame xr frame to update the pose with
  42916. * @param referenceSpace reference space to use
  42917. */
  42918. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42919. /**
  42920. * Gets a world space ray coming from the controller
  42921. * @param result the resulting ray
  42922. */
  42923. getWorldPointerRayToRef(result: Ray): void;
  42924. /**
  42925. * Disposes of the object
  42926. */
  42927. dispose(): void;
  42928. }
  42929. }
  42930. declare module "babylonjs/Cameras/XR/webXRInput" {
  42931. import { Observable } from "babylonjs/Misc/observable";
  42932. import { IDisposable } from "babylonjs/scene";
  42933. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42934. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42935. /**
  42936. * XR input used to track XR inputs such as controllers/rays
  42937. */
  42938. export class WebXRInput implements IDisposable {
  42939. /**
  42940. * Base experience the input listens to
  42941. */
  42942. baseExperience: WebXRExperienceHelper;
  42943. /**
  42944. * XR controllers being tracked
  42945. */
  42946. controllers: Array<WebXRController>;
  42947. private _frameObserver;
  42948. private _stateObserver;
  42949. /**
  42950. * Event when a controller has been connected/added
  42951. */
  42952. onControllerAddedObservable: Observable<WebXRController>;
  42953. /**
  42954. * Event when a controller has been removed/disconnected
  42955. */
  42956. onControllerRemovedObservable: Observable<WebXRController>;
  42957. /**
  42958. * Initializes the WebXRInput
  42959. * @param baseExperience experience helper which the input should be created for
  42960. */
  42961. constructor(
  42962. /**
  42963. * Base experience the input listens to
  42964. */
  42965. baseExperience: WebXRExperienceHelper);
  42966. private _onInputSourcesChange;
  42967. private _addAndRemoveControllers;
  42968. /**
  42969. * Disposes of the object
  42970. */
  42971. dispose(): void;
  42972. }
  42973. }
  42974. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42976. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42977. /**
  42978. * Enables teleportation
  42979. */
  42980. export class WebXRControllerTeleportation {
  42981. private _teleportationFillColor;
  42982. private _teleportationBorderColor;
  42983. private _tmpRay;
  42984. private _tmpVector;
  42985. /**
  42986. * Creates a WebXRControllerTeleportation
  42987. * @param input input manager to add teleportation to
  42988. * @param floorMeshes floormeshes which can be teleported to
  42989. */
  42990. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42991. }
  42992. }
  42993. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42994. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42995. /**
  42996. * Handles pointer input automatically for the pointer of XR controllers
  42997. */
  42998. export class WebXRControllerPointerSelection {
  42999. private static _idCounter;
  43000. private _tmpRay;
  43001. /**
  43002. * Creates a WebXRControllerPointerSelection
  43003. * @param input input manager to setup pointer selection
  43004. */
  43005. constructor(input: WebXRInput);
  43006. private _convertNormalToDirectionOfRay;
  43007. private _updatePointerDistance;
  43008. }
  43009. }
  43010. declare module "babylonjs/Loading/sceneLoader" {
  43011. import { Observable } from "babylonjs/Misc/observable";
  43012. import { Nullable } from "babylonjs/types";
  43013. import { Scene } from "babylonjs/scene";
  43014. import { Engine } from "babylonjs/Engines/engine";
  43015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43016. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43017. import { AssetContainer } from "babylonjs/assetContainer";
  43018. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43019. import { Skeleton } from "babylonjs/Bones/skeleton";
  43020. /**
  43021. * Class used to represent data loading progression
  43022. */
  43023. export class SceneLoaderProgressEvent {
  43024. /** defines if data length to load can be evaluated */
  43025. readonly lengthComputable: boolean;
  43026. /** defines the loaded data length */
  43027. readonly loaded: number;
  43028. /** defines the data length to load */
  43029. readonly total: number;
  43030. /**
  43031. * Create a new progress event
  43032. * @param lengthComputable defines if data length to load can be evaluated
  43033. * @param loaded defines the loaded data length
  43034. * @param total defines the data length to load
  43035. */
  43036. constructor(
  43037. /** defines if data length to load can be evaluated */
  43038. lengthComputable: boolean,
  43039. /** defines the loaded data length */
  43040. loaded: number,
  43041. /** defines the data length to load */
  43042. total: number);
  43043. /**
  43044. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43045. * @param event defines the source event
  43046. * @returns a new SceneLoaderProgressEvent
  43047. */
  43048. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43049. }
  43050. /**
  43051. * Interface used by SceneLoader plugins to define supported file extensions
  43052. */
  43053. export interface ISceneLoaderPluginExtensions {
  43054. /**
  43055. * Defines the list of supported extensions
  43056. */
  43057. [extension: string]: {
  43058. isBinary: boolean;
  43059. };
  43060. }
  43061. /**
  43062. * Interface used by SceneLoader plugin factory
  43063. */
  43064. export interface ISceneLoaderPluginFactory {
  43065. /**
  43066. * Defines the name of the factory
  43067. */
  43068. name: string;
  43069. /**
  43070. * Function called to create a new plugin
  43071. * @return the new plugin
  43072. */
  43073. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43074. /**
  43075. * Boolean indicating if the plugin can direct load specific data
  43076. */
  43077. canDirectLoad?: (data: string) => boolean;
  43078. }
  43079. /**
  43080. * Interface used to define a SceneLoader plugin
  43081. */
  43082. export interface ISceneLoaderPlugin {
  43083. /**
  43084. * The friendly name of this plugin.
  43085. */
  43086. name: string;
  43087. /**
  43088. * The file extensions supported by this plugin.
  43089. */
  43090. extensions: string | ISceneLoaderPluginExtensions;
  43091. /**
  43092. * Import meshes into a scene.
  43093. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43094. * @param scene The scene to import into
  43095. * @param data The data to import
  43096. * @param rootUrl The root url for scene and resources
  43097. * @param meshes The meshes array to import into
  43098. * @param particleSystems The particle systems array to import into
  43099. * @param skeletons The skeletons array to import into
  43100. * @param onError The callback when import fails
  43101. * @returns True if successful or false otherwise
  43102. */
  43103. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43104. /**
  43105. * Load into a scene.
  43106. * @param scene The scene to load into
  43107. * @param data The data to import
  43108. * @param rootUrl The root url for scene and resources
  43109. * @param onError The callback when import fails
  43110. * @returns true if successful or false otherwise
  43111. */
  43112. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43113. /**
  43114. * The callback that returns true if the data can be directly loaded.
  43115. */
  43116. canDirectLoad?: (data: string) => boolean;
  43117. /**
  43118. * The callback that allows custom handling of the root url based on the response url.
  43119. */
  43120. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43121. /**
  43122. * Load into an asset container.
  43123. * @param scene The scene to load into
  43124. * @param data The data to import
  43125. * @param rootUrl The root url for scene and resources
  43126. * @param onError The callback when import fails
  43127. * @returns The loaded asset container
  43128. */
  43129. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43130. }
  43131. /**
  43132. * Interface used to define an async SceneLoader plugin
  43133. */
  43134. export interface ISceneLoaderPluginAsync {
  43135. /**
  43136. * The friendly name of this plugin.
  43137. */
  43138. name: string;
  43139. /**
  43140. * The file extensions supported by this plugin.
  43141. */
  43142. extensions: string | ISceneLoaderPluginExtensions;
  43143. /**
  43144. * Import meshes into a scene.
  43145. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43146. * @param scene The scene to import into
  43147. * @param data The data to import
  43148. * @param rootUrl The root url for scene and resources
  43149. * @param onProgress The callback when the load progresses
  43150. * @param fileName Defines the name of the file to load
  43151. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43152. */
  43153. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43154. meshes: AbstractMesh[];
  43155. particleSystems: IParticleSystem[];
  43156. skeletons: Skeleton[];
  43157. animationGroups: AnimationGroup[];
  43158. }>;
  43159. /**
  43160. * Load into a scene.
  43161. * @param scene The scene to load into
  43162. * @param data The data to import
  43163. * @param rootUrl The root url for scene and resources
  43164. * @param onProgress The callback when the load progresses
  43165. * @param fileName Defines the name of the file to load
  43166. * @returns Nothing
  43167. */
  43168. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43169. /**
  43170. * The callback that returns true if the data can be directly loaded.
  43171. */
  43172. canDirectLoad?: (data: string) => boolean;
  43173. /**
  43174. * The callback that allows custom handling of the root url based on the response url.
  43175. */
  43176. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43177. /**
  43178. * Load into an asset container.
  43179. * @param scene The scene to load into
  43180. * @param data The data to import
  43181. * @param rootUrl The root url for scene and resources
  43182. * @param onProgress The callback when the load progresses
  43183. * @param fileName Defines the name of the file to load
  43184. * @returns The loaded asset container
  43185. */
  43186. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43187. }
  43188. /**
  43189. * Class used to load scene from various file formats using registered plugins
  43190. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43191. */
  43192. export class SceneLoader {
  43193. /**
  43194. * No logging while loading
  43195. */
  43196. static readonly NO_LOGGING: number;
  43197. /**
  43198. * Minimal logging while loading
  43199. */
  43200. static readonly MINIMAL_LOGGING: number;
  43201. /**
  43202. * Summary logging while loading
  43203. */
  43204. static readonly SUMMARY_LOGGING: number;
  43205. /**
  43206. * Detailled logging while loading
  43207. */
  43208. static readonly DETAILED_LOGGING: number;
  43209. /**
  43210. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43211. */
  43212. static ForceFullSceneLoadingForIncremental: boolean;
  43213. /**
  43214. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43215. */
  43216. static ShowLoadingScreen: boolean;
  43217. /**
  43218. * Defines the current logging level (while loading the scene)
  43219. * @ignorenaming
  43220. */
  43221. static loggingLevel: number;
  43222. /**
  43223. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43224. */
  43225. static CleanBoneMatrixWeights: boolean;
  43226. /**
  43227. * Event raised when a plugin is used to load a scene
  43228. */
  43229. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43230. private static _registeredPlugins;
  43231. private static _getDefaultPlugin;
  43232. private static _getPluginForExtension;
  43233. private static _getPluginForDirectLoad;
  43234. private static _getPluginForFilename;
  43235. private static _getDirectLoad;
  43236. private static _loadData;
  43237. private static _getFileInfo;
  43238. /**
  43239. * Gets a plugin that can load the given extension
  43240. * @param extension defines the extension to load
  43241. * @returns a plugin or null if none works
  43242. */
  43243. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43244. /**
  43245. * Gets a boolean indicating that the given extension can be loaded
  43246. * @param extension defines the extension to load
  43247. * @returns true if the extension is supported
  43248. */
  43249. static IsPluginForExtensionAvailable(extension: string): boolean;
  43250. /**
  43251. * Adds a new plugin to the list of registered plugins
  43252. * @param plugin defines the plugin to add
  43253. */
  43254. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43255. /**
  43256. * Import meshes into a scene
  43257. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43258. * @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)
  43259. * @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)
  43260. * @param scene the instance of BABYLON.Scene to append to
  43261. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43262. * @param onProgress a callback with a progress event for each file being loaded
  43263. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43264. * @param pluginExtension the extension used to determine the plugin
  43265. * @returns The loaded plugin
  43266. */
  43267. 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>;
  43268. /**
  43269. * Import meshes into a scene
  43270. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43271. * @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)
  43272. * @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)
  43273. * @param scene the instance of BABYLON.Scene to append to
  43274. * @param onProgress a callback with a progress event for each file being loaded
  43275. * @param pluginExtension the extension used to determine the plugin
  43276. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43277. */
  43278. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43279. meshes: AbstractMesh[];
  43280. particleSystems: IParticleSystem[];
  43281. skeletons: Skeleton[];
  43282. animationGroups: AnimationGroup[];
  43283. }>;
  43284. /**
  43285. * Load a scene
  43286. * @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)
  43287. * @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)
  43288. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43289. * @param onSuccess a callback with the scene when import succeeds
  43290. * @param onProgress a callback with a progress event for each file being loaded
  43291. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43292. * @param pluginExtension the extension used to determine the plugin
  43293. * @returns The loaded plugin
  43294. */
  43295. 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>;
  43296. /**
  43297. * Load a scene
  43298. * @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)
  43299. * @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)
  43300. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43301. * @param onProgress a callback with a progress event for each file being loaded
  43302. * @param pluginExtension the extension used to determine the plugin
  43303. * @returns The loaded scene
  43304. */
  43305. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43306. /**
  43307. * Append a scene
  43308. * @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)
  43309. * @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)
  43310. * @param scene is the instance of BABYLON.Scene to append to
  43311. * @param onSuccess a callback with the scene when import succeeds
  43312. * @param onProgress a callback with a progress event for each file being loaded
  43313. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43314. * @param pluginExtension the extension used to determine the plugin
  43315. * @returns The loaded plugin
  43316. */
  43317. 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>;
  43318. /**
  43319. * Append a scene
  43320. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43321. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43322. * @param scene is the instance of BABYLON.Scene to append to
  43323. * @param onProgress a callback with a progress event for each file being loaded
  43324. * @param pluginExtension the extension used to determine the plugin
  43325. * @returns The given scene
  43326. */
  43327. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43328. /**
  43329. * Load a scene into an asset container
  43330. * @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)
  43331. * @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)
  43332. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43333. * @param onSuccess a callback with the scene when import succeeds
  43334. * @param onProgress a callback with a progress event for each file being loaded
  43335. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43336. * @param pluginExtension the extension used to determine the plugin
  43337. * @returns The loaded plugin
  43338. */
  43339. 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>;
  43340. /**
  43341. * Load a scene into an asset container
  43342. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43343. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  43344. * @param scene is the instance of Scene to append to
  43345. * @param onProgress a callback with a progress event for each file being loaded
  43346. * @param pluginExtension the extension used to determine the plugin
  43347. * @returns The loaded asset container
  43348. */
  43349. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43350. }
  43351. }
  43352. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43353. import { Scene } from "babylonjs/scene";
  43354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43355. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43356. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43357. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43358. /**
  43359. * Generic Controller
  43360. */
  43361. export class GenericController extends WebVRController {
  43362. /**
  43363. * Base Url for the controller model.
  43364. */
  43365. static readonly MODEL_BASE_URL: string;
  43366. /**
  43367. * File name for the controller model.
  43368. */
  43369. static readonly MODEL_FILENAME: string;
  43370. /**
  43371. * Creates a new GenericController from a gamepad
  43372. * @param vrGamepad the gamepad that the controller should be created from
  43373. */
  43374. constructor(vrGamepad: any);
  43375. /**
  43376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43377. * @param scene scene in which to add meshes
  43378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43379. */
  43380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43381. /**
  43382. * Called once for each button that changed state since the last frame
  43383. * @param buttonIdx Which button index changed
  43384. * @param state New state of the button
  43385. * @param changes Which properties on the state changed since last frame
  43386. */
  43387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43388. }
  43389. }
  43390. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43391. import { Observable } from "babylonjs/Misc/observable";
  43392. import { Scene } from "babylonjs/scene";
  43393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43394. import { Ray } from "babylonjs/Culling/ray";
  43395. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43396. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43397. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43398. /**
  43399. * Defines the WindowsMotionController object that the state of the windows motion controller
  43400. */
  43401. export class WindowsMotionController extends WebVRController {
  43402. /**
  43403. * The base url used to load the left and right controller models
  43404. */
  43405. static MODEL_BASE_URL: string;
  43406. /**
  43407. * The name of the left controller model file
  43408. */
  43409. static MODEL_LEFT_FILENAME: string;
  43410. /**
  43411. * The name of the right controller model file
  43412. */
  43413. static MODEL_RIGHT_FILENAME: string;
  43414. /**
  43415. * The controller name prefix for this controller type
  43416. */
  43417. static readonly GAMEPAD_ID_PREFIX: string;
  43418. /**
  43419. * The controller id pattern for this controller type
  43420. */
  43421. private static readonly GAMEPAD_ID_PATTERN;
  43422. private _loadedMeshInfo;
  43423. private readonly _mapping;
  43424. /**
  43425. * Fired when the trackpad on this controller is clicked
  43426. */
  43427. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43428. /**
  43429. * Fired when the trackpad on this controller is modified
  43430. */
  43431. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43432. /**
  43433. * The current x and y values of this controller's trackpad
  43434. */
  43435. trackpad: StickValues;
  43436. /**
  43437. * Creates a new WindowsMotionController from a gamepad
  43438. * @param vrGamepad the gamepad that the controller should be created from
  43439. */
  43440. constructor(vrGamepad: any);
  43441. /**
  43442. * Fired when the trigger on this controller is modified
  43443. */
  43444. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43445. /**
  43446. * Fired when the menu button on this controller is modified
  43447. */
  43448. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43449. /**
  43450. * Fired when the grip button on this controller is modified
  43451. */
  43452. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43453. /**
  43454. * Fired when the thumbstick button on this controller is modified
  43455. */
  43456. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43457. /**
  43458. * Fired when the touchpad button on this controller is modified
  43459. */
  43460. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43461. /**
  43462. * Fired when the touchpad values on this controller are modified
  43463. */
  43464. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43465. private _updateTrackpad;
  43466. /**
  43467. * Called once per frame by the engine.
  43468. */
  43469. update(): void;
  43470. /**
  43471. * Called once for each button that changed state since the last frame
  43472. * @param buttonIdx Which button index changed
  43473. * @param state New state of the button
  43474. * @param changes Which properties on the state changed since last frame
  43475. */
  43476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43477. /**
  43478. * Moves the buttons on the controller mesh based on their current state
  43479. * @param buttonName the name of the button to move
  43480. * @param buttonValue the value of the button which determines the buttons new position
  43481. */
  43482. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43483. /**
  43484. * Moves the axis on the controller mesh based on its current state
  43485. * @param axis the index of the axis
  43486. * @param axisValue the value of the axis which determines the meshes new position
  43487. * @hidden
  43488. */
  43489. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43490. /**
  43491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43492. * @param scene scene in which to add meshes
  43493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43494. */
  43495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43496. /**
  43497. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43498. * can be transformed by button presses and axes values, based on this._mapping.
  43499. *
  43500. * @param scene scene in which the meshes exist
  43501. * @param meshes list of meshes that make up the controller model to process
  43502. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43503. */
  43504. private processModel;
  43505. private createMeshInfo;
  43506. /**
  43507. * Gets the ray of the controller in the direction the controller is pointing
  43508. * @param length the length the resulting ray should be
  43509. * @returns a ray in the direction the controller is pointing
  43510. */
  43511. getForwardRay(length?: number): Ray;
  43512. /**
  43513. * Disposes of the controller
  43514. */
  43515. dispose(): void;
  43516. }
  43517. }
  43518. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43519. import { Observable } from "babylonjs/Misc/observable";
  43520. import { Scene } from "babylonjs/scene";
  43521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43522. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43523. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43524. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43525. /**
  43526. * Oculus Touch Controller
  43527. */
  43528. export class OculusTouchController extends WebVRController {
  43529. /**
  43530. * Base Url for the controller model.
  43531. */
  43532. static MODEL_BASE_URL: string;
  43533. /**
  43534. * File name for the left controller model.
  43535. */
  43536. static MODEL_LEFT_FILENAME: string;
  43537. /**
  43538. * File name for the right controller model.
  43539. */
  43540. static MODEL_RIGHT_FILENAME: string;
  43541. /**
  43542. * Base Url for the Quest controller model.
  43543. */
  43544. static QUEST_MODEL_BASE_URL: string;
  43545. /**
  43546. * @hidden
  43547. * If the controllers are running on a device that needs the updated Quest controller models
  43548. */
  43549. static _IsQuest: boolean;
  43550. /**
  43551. * Fired when the secondary trigger on this controller is modified
  43552. */
  43553. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43554. /**
  43555. * Fired when the thumb rest on this controller is modified
  43556. */
  43557. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43558. /**
  43559. * Creates a new OculusTouchController from a gamepad
  43560. * @param vrGamepad the gamepad that the controller should be created from
  43561. */
  43562. constructor(vrGamepad: any);
  43563. /**
  43564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43565. * @param scene scene in which to add meshes
  43566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43567. */
  43568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43569. /**
  43570. * Fired when the A button on this controller is modified
  43571. */
  43572. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43573. /**
  43574. * Fired when the B button on this controller is modified
  43575. */
  43576. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43577. /**
  43578. * Fired when the X button on this controller is modified
  43579. */
  43580. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43581. /**
  43582. * Fired when the Y button on this controller is modified
  43583. */
  43584. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Called once for each button that changed state since the last frame
  43587. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43588. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43589. * 2) secondary trigger (same)
  43590. * 3) A (right) X (left), touch, pressed = value
  43591. * 4) B / Y
  43592. * 5) thumb rest
  43593. * @param buttonIdx Which button index changed
  43594. * @param state New state of the button
  43595. * @param changes Which properties on the state changed since last frame
  43596. */
  43597. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43598. }
  43599. }
  43600. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43601. import { Scene } from "babylonjs/scene";
  43602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43603. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43604. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43605. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. /**
  43608. * Vive Controller
  43609. */
  43610. export class ViveController extends WebVRController {
  43611. /**
  43612. * Base Url for the controller model.
  43613. */
  43614. static MODEL_BASE_URL: string;
  43615. /**
  43616. * File name for the controller model.
  43617. */
  43618. static MODEL_FILENAME: string;
  43619. /**
  43620. * Creates a new ViveController from a gamepad
  43621. * @param vrGamepad the gamepad that the controller should be created from
  43622. */
  43623. constructor(vrGamepad: any);
  43624. /**
  43625. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43626. * @param scene scene in which to add meshes
  43627. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43628. */
  43629. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43630. /**
  43631. * Fired when the left button on this controller is modified
  43632. */
  43633. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43634. /**
  43635. * Fired when the right button on this controller is modified
  43636. */
  43637. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43638. /**
  43639. * Fired when the menu button on this controller is modified
  43640. */
  43641. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43642. /**
  43643. * Called once for each button that changed state since the last frame
  43644. * Vive mapping:
  43645. * 0: touchpad
  43646. * 1: trigger
  43647. * 2: left AND right buttons
  43648. * 3: menu button
  43649. * @param buttonIdx Which button index changed
  43650. * @param state New state of the button
  43651. * @param changes Which properties on the state changed since last frame
  43652. */
  43653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43654. }
  43655. }
  43656. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43657. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43658. /**
  43659. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43660. */
  43661. export class WebXRControllerModelLoader {
  43662. /**
  43663. * Creates the WebXRControllerModelLoader
  43664. * @param input xr input that creates the controllers
  43665. */
  43666. constructor(input: WebXRInput);
  43667. }
  43668. }
  43669. declare module "babylonjs/Cameras/XR/index" {
  43670. export * from "babylonjs/Cameras/XR/webXRCamera";
  43671. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43672. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43673. export * from "babylonjs/Cameras/XR/webXRInput";
  43674. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43675. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43676. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43677. export * from "babylonjs/Cameras/XR/webXRController";
  43678. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43679. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43680. }
  43681. declare module "babylonjs/Cameras/RigModes/index" {
  43682. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43683. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43684. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43685. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43686. }
  43687. declare module "babylonjs/Cameras/index" {
  43688. export * from "babylonjs/Cameras/Inputs/index";
  43689. export * from "babylonjs/Cameras/cameraInputsManager";
  43690. export * from "babylonjs/Cameras/camera";
  43691. export * from "babylonjs/Cameras/targetCamera";
  43692. export * from "babylonjs/Cameras/freeCamera";
  43693. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43694. export * from "babylonjs/Cameras/touchCamera";
  43695. export * from "babylonjs/Cameras/arcRotateCamera";
  43696. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43697. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43698. export * from "babylonjs/Cameras/flyCamera";
  43699. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43700. export * from "babylonjs/Cameras/followCamera";
  43701. export * from "babylonjs/Cameras/gamepadCamera";
  43702. export * from "babylonjs/Cameras/Stereoscopic/index";
  43703. export * from "babylonjs/Cameras/universalCamera";
  43704. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43705. export * from "babylonjs/Cameras/VR/index";
  43706. export * from "babylonjs/Cameras/XR/index";
  43707. export * from "babylonjs/Cameras/RigModes/index";
  43708. }
  43709. declare module "babylonjs/Collisions/index" {
  43710. export * from "babylonjs/Collisions/collider";
  43711. export * from "babylonjs/Collisions/collisionCoordinator";
  43712. export * from "babylonjs/Collisions/pickingInfo";
  43713. export * from "babylonjs/Collisions/intersectionInfo";
  43714. export * from "babylonjs/Collisions/meshCollisionData";
  43715. }
  43716. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43717. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43718. import { Vector3 } from "babylonjs/Maths/math.vector";
  43719. import { Ray } from "babylonjs/Culling/ray";
  43720. import { Plane } from "babylonjs/Maths/math.plane";
  43721. /**
  43722. * Contains an array of blocks representing the octree
  43723. */
  43724. export interface IOctreeContainer<T> {
  43725. /**
  43726. * Blocks within the octree
  43727. */
  43728. blocks: Array<OctreeBlock<T>>;
  43729. }
  43730. /**
  43731. * Class used to store a cell in an octree
  43732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43733. */
  43734. export class OctreeBlock<T> {
  43735. /**
  43736. * Gets the content of the current block
  43737. */
  43738. entries: T[];
  43739. /**
  43740. * Gets the list of block children
  43741. */
  43742. blocks: Array<OctreeBlock<T>>;
  43743. private _depth;
  43744. private _maxDepth;
  43745. private _capacity;
  43746. private _minPoint;
  43747. private _maxPoint;
  43748. private _boundingVectors;
  43749. private _creationFunc;
  43750. /**
  43751. * Creates a new block
  43752. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43753. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43754. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43755. * @param depth defines the current depth of this block in the octree
  43756. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43757. * @param creationFunc defines a callback to call when an element is added to the block
  43758. */
  43759. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43760. /**
  43761. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43762. */
  43763. readonly capacity: number;
  43764. /**
  43765. * Gets the minimum vector (in world space) of the block's bounding box
  43766. */
  43767. readonly minPoint: Vector3;
  43768. /**
  43769. * Gets the maximum vector (in world space) of the block's bounding box
  43770. */
  43771. readonly maxPoint: Vector3;
  43772. /**
  43773. * Add a new element to this block
  43774. * @param entry defines the element to add
  43775. */
  43776. addEntry(entry: T): void;
  43777. /**
  43778. * Remove an element from this block
  43779. * @param entry defines the element to remove
  43780. */
  43781. removeEntry(entry: T): void;
  43782. /**
  43783. * Add an array of elements to this block
  43784. * @param entries defines the array of elements to add
  43785. */
  43786. addEntries(entries: T[]): void;
  43787. /**
  43788. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43789. * @param frustumPlanes defines the frustum planes to test
  43790. * @param selection defines the array to store current content if selection is positive
  43791. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43792. */
  43793. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43794. /**
  43795. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43796. * @param sphereCenter defines the bounding sphere center
  43797. * @param sphereRadius defines the bounding sphere radius
  43798. * @param selection defines the array to store current content if selection is positive
  43799. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43800. */
  43801. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43802. /**
  43803. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43804. * @param ray defines the ray to test with
  43805. * @param selection defines the array to store current content if selection is positive
  43806. */
  43807. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43808. /**
  43809. * Subdivide the content into child blocks (this block will then be empty)
  43810. */
  43811. createInnerBlocks(): void;
  43812. /**
  43813. * @hidden
  43814. */
  43815. 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;
  43816. }
  43817. }
  43818. declare module "babylonjs/Culling/Octrees/octree" {
  43819. import { SmartArray } from "babylonjs/Misc/smartArray";
  43820. import { Vector3 } from "babylonjs/Maths/math.vector";
  43821. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43823. import { Ray } from "babylonjs/Culling/ray";
  43824. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43825. import { Plane } from "babylonjs/Maths/math.plane";
  43826. /**
  43827. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43828. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43829. */
  43830. export class Octree<T> {
  43831. /** 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.) */
  43832. maxDepth: number;
  43833. /**
  43834. * Blocks within the octree containing objects
  43835. */
  43836. blocks: Array<OctreeBlock<T>>;
  43837. /**
  43838. * Content stored in the octree
  43839. */
  43840. dynamicContent: T[];
  43841. private _maxBlockCapacity;
  43842. private _selectionContent;
  43843. private _creationFunc;
  43844. /**
  43845. * Creates a octree
  43846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43847. * @param creationFunc function to be used to instatiate the octree
  43848. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43849. * @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.)
  43850. */
  43851. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43852. /** 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.) */
  43853. maxDepth?: number);
  43854. /**
  43855. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43856. * @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);
  43857. * @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);
  43858. * @param entries meshes to be added to the octree blocks
  43859. */
  43860. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43861. /**
  43862. * Adds a mesh to the octree
  43863. * @param entry Mesh to add to the octree
  43864. */
  43865. addMesh(entry: T): void;
  43866. /**
  43867. * Remove an element from the octree
  43868. * @param entry defines the element to remove
  43869. */
  43870. removeMesh(entry: T): void;
  43871. /**
  43872. * Selects an array of meshes within the frustum
  43873. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43874. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43875. * @returns array of meshes within the frustum
  43876. */
  43877. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43878. /**
  43879. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43880. * @param sphereCenter defines the bounding sphere center
  43881. * @param sphereRadius defines the bounding sphere radius
  43882. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43883. * @returns an array of objects that intersect the sphere
  43884. */
  43885. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43886. /**
  43887. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43888. * @param ray defines the ray to test with
  43889. * @returns array of intersected objects
  43890. */
  43891. intersectsRay(ray: Ray): SmartArray<T>;
  43892. /**
  43893. * Adds a mesh into the octree block if it intersects the block
  43894. */
  43895. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43896. /**
  43897. * Adds a submesh into the octree block if it intersects the block
  43898. */
  43899. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43900. }
  43901. }
  43902. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43903. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43904. import { Scene } from "babylonjs/scene";
  43905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43907. import { Ray } from "babylonjs/Culling/ray";
  43908. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43909. import { Collider } from "babylonjs/Collisions/collider";
  43910. module "babylonjs/scene" {
  43911. interface Scene {
  43912. /**
  43913. * @hidden
  43914. * Backing Filed
  43915. */
  43916. _selectionOctree: Octree<AbstractMesh>;
  43917. /**
  43918. * Gets the octree used to boost mesh selection (picking)
  43919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43920. */
  43921. selectionOctree: Octree<AbstractMesh>;
  43922. /**
  43923. * Creates or updates the octree used to boost selection (picking)
  43924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43925. * @param maxCapacity defines the maximum capacity per leaf
  43926. * @param maxDepth defines the maximum depth of the octree
  43927. * @returns an octree of AbstractMesh
  43928. */
  43929. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43930. }
  43931. }
  43932. module "babylonjs/Meshes/abstractMesh" {
  43933. interface AbstractMesh {
  43934. /**
  43935. * @hidden
  43936. * Backing Field
  43937. */
  43938. _submeshesOctree: Octree<SubMesh>;
  43939. /**
  43940. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43941. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43942. * @param maxCapacity defines the maximum size of each block (64 by default)
  43943. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43944. * @returns the new octree
  43945. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43947. */
  43948. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43949. }
  43950. }
  43951. /**
  43952. * Defines the octree scene component responsible to manage any octrees
  43953. * in a given scene.
  43954. */
  43955. export class OctreeSceneComponent {
  43956. /**
  43957. * The component name help to identify the component in the list of scene components.
  43958. */
  43959. readonly name: string;
  43960. /**
  43961. * The scene the component belongs to.
  43962. */
  43963. scene: Scene;
  43964. /**
  43965. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43966. */
  43967. readonly checksIsEnabled: boolean;
  43968. /**
  43969. * Creates a new instance of the component for the given scene
  43970. * @param scene Defines the scene to register the component in
  43971. */
  43972. constructor(scene: Scene);
  43973. /**
  43974. * Registers the component in a given scene
  43975. */
  43976. register(): void;
  43977. /**
  43978. * Return the list of active meshes
  43979. * @returns the list of active meshes
  43980. */
  43981. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43982. /**
  43983. * Return the list of active sub meshes
  43984. * @param mesh The mesh to get the candidates sub meshes from
  43985. * @returns the list of active sub meshes
  43986. */
  43987. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43988. private _tempRay;
  43989. /**
  43990. * Return the list of sub meshes intersecting with a given local ray
  43991. * @param mesh defines the mesh to find the submesh for
  43992. * @param localRay defines the ray in local space
  43993. * @returns the list of intersecting sub meshes
  43994. */
  43995. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43996. /**
  43997. * Return the list of sub meshes colliding with a collider
  43998. * @param mesh defines the mesh to find the submesh for
  43999. * @param collider defines the collider to evaluate the collision against
  44000. * @returns the list of colliding sub meshes
  44001. */
  44002. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44003. /**
  44004. * Rebuilds the elements related to this component in case of
  44005. * context lost for instance.
  44006. */
  44007. rebuild(): void;
  44008. /**
  44009. * Disposes the component and the associated ressources.
  44010. */
  44011. dispose(): void;
  44012. }
  44013. }
  44014. declare module "babylonjs/Culling/Octrees/index" {
  44015. export * from "babylonjs/Culling/Octrees/octree";
  44016. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44017. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44018. }
  44019. declare module "babylonjs/Culling/index" {
  44020. export * from "babylonjs/Culling/boundingBox";
  44021. export * from "babylonjs/Culling/boundingInfo";
  44022. export * from "babylonjs/Culling/boundingSphere";
  44023. export * from "babylonjs/Culling/Octrees/index";
  44024. export * from "babylonjs/Culling/ray";
  44025. }
  44026. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44027. import { IDisposable, Scene } from "babylonjs/scene";
  44028. import { Nullable } from "babylonjs/types";
  44029. import { Observable } from "babylonjs/Misc/observable";
  44030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44031. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44032. import { Camera } from "babylonjs/Cameras/camera";
  44033. /**
  44034. * Renders a layer on top of an existing scene
  44035. */
  44036. export class UtilityLayerRenderer implements IDisposable {
  44037. /** the original scene that will be rendered on top of */
  44038. originalScene: Scene;
  44039. private _pointerCaptures;
  44040. private _lastPointerEvents;
  44041. private static _DefaultUtilityLayer;
  44042. private static _DefaultKeepDepthUtilityLayer;
  44043. private _sharedGizmoLight;
  44044. private _renderCamera;
  44045. /**
  44046. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44047. * @returns the camera that is used when rendering the utility layer
  44048. */
  44049. getRenderCamera(): Nullable<Camera>;
  44050. /**
  44051. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44052. * @param cam the camera that should be used when rendering the utility layer
  44053. */
  44054. setRenderCamera(cam: Nullable<Camera>): void;
  44055. /**
  44056. * @hidden
  44057. * Light which used by gizmos to get light shading
  44058. */
  44059. _getSharedGizmoLight(): HemisphericLight;
  44060. /**
  44061. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44062. */
  44063. pickUtilitySceneFirst: boolean;
  44064. /**
  44065. * 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)
  44066. */
  44067. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44068. /**
  44069. * 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)
  44070. */
  44071. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44072. /**
  44073. * The scene that is rendered on top of the original scene
  44074. */
  44075. utilityLayerScene: Scene;
  44076. /**
  44077. * If the utility layer should automatically be rendered on top of existing scene
  44078. */
  44079. shouldRender: boolean;
  44080. /**
  44081. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44082. */
  44083. onlyCheckPointerDownEvents: boolean;
  44084. /**
  44085. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44086. */
  44087. processAllEvents: boolean;
  44088. /**
  44089. * Observable raised when the pointer move from the utility layer scene to the main scene
  44090. */
  44091. onPointerOutObservable: Observable<number>;
  44092. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44093. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44094. private _afterRenderObserver;
  44095. private _sceneDisposeObserver;
  44096. private _originalPointerObserver;
  44097. /**
  44098. * Instantiates a UtilityLayerRenderer
  44099. * @param originalScene the original scene that will be rendered on top of
  44100. * @param handleEvents boolean indicating if the utility layer should handle events
  44101. */
  44102. constructor(
  44103. /** the original scene that will be rendered on top of */
  44104. originalScene: Scene, handleEvents?: boolean);
  44105. private _notifyObservers;
  44106. /**
  44107. * Renders the utility layers scene on top of the original scene
  44108. */
  44109. render(): void;
  44110. /**
  44111. * Disposes of the renderer
  44112. */
  44113. dispose(): void;
  44114. private _updateCamera;
  44115. }
  44116. }
  44117. declare module "babylonjs/Gizmos/gizmo" {
  44118. import { Nullable } from "babylonjs/types";
  44119. import { IDisposable } from "babylonjs/scene";
  44120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44121. import { Mesh } from "babylonjs/Meshes/mesh";
  44122. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44123. /**
  44124. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44125. */
  44126. export class Gizmo implements IDisposable {
  44127. /** The utility layer the gizmo will be added to */
  44128. gizmoLayer: UtilityLayerRenderer;
  44129. /**
  44130. * The root mesh of the gizmo
  44131. */
  44132. _rootMesh: Mesh;
  44133. private _attachedMesh;
  44134. /**
  44135. * Ratio for the scale of the gizmo (Default: 1)
  44136. */
  44137. scaleRatio: number;
  44138. /**
  44139. * If a custom mesh has been set (Default: false)
  44140. */
  44141. protected _customMeshSet: boolean;
  44142. /**
  44143. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44144. * * When set, interactions will be enabled
  44145. */
  44146. attachedMesh: Nullable<AbstractMesh>;
  44147. /**
  44148. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44149. * @param mesh The mesh to replace the default mesh of the gizmo
  44150. */
  44151. setCustomMesh(mesh: Mesh): void;
  44152. /**
  44153. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44154. */
  44155. updateGizmoRotationToMatchAttachedMesh: boolean;
  44156. /**
  44157. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44158. */
  44159. updateGizmoPositionToMatchAttachedMesh: boolean;
  44160. /**
  44161. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44162. */
  44163. updateScale: boolean;
  44164. protected _interactionsEnabled: boolean;
  44165. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44166. private _beforeRenderObserver;
  44167. private _tempVector;
  44168. /**
  44169. * Creates a gizmo
  44170. * @param gizmoLayer The utility layer the gizmo will be added to
  44171. */
  44172. constructor(
  44173. /** The utility layer the gizmo will be added to */
  44174. gizmoLayer?: UtilityLayerRenderer);
  44175. /**
  44176. * Updates the gizmo to match the attached mesh's position/rotation
  44177. */
  44178. protected _update(): void;
  44179. /**
  44180. * Disposes of the gizmo
  44181. */
  44182. dispose(): void;
  44183. }
  44184. }
  44185. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44186. import { Observable } from "babylonjs/Misc/observable";
  44187. import { Nullable } from "babylonjs/types";
  44188. import { Vector3 } from "babylonjs/Maths/math.vector";
  44189. import { Color3 } from "babylonjs/Maths/math.color";
  44190. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44192. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44193. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44194. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44195. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44196. import { Scene } from "babylonjs/scene";
  44197. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44198. /**
  44199. * Single plane drag gizmo
  44200. */
  44201. export class PlaneDragGizmo extends Gizmo {
  44202. /**
  44203. * Drag behavior responsible for the gizmos dragging interactions
  44204. */
  44205. dragBehavior: PointerDragBehavior;
  44206. private _pointerObserver;
  44207. /**
  44208. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44209. */
  44210. snapDistance: number;
  44211. /**
  44212. * Event that fires each time the gizmo snaps to a new location.
  44213. * * snapDistance is the the change in distance
  44214. */
  44215. onSnapObservable: Observable<{
  44216. snapDistance: number;
  44217. }>;
  44218. private _plane;
  44219. private _coloredMaterial;
  44220. private _hoverMaterial;
  44221. private _isEnabled;
  44222. private _parent;
  44223. /** @hidden */
  44224. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44225. /** @hidden */
  44226. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44227. /**
  44228. * Creates a PlaneDragGizmo
  44229. * @param gizmoLayer The utility layer the gizmo will be added to
  44230. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44231. * @param color The color of the gizmo
  44232. */
  44233. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44234. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44235. /**
  44236. * If the gizmo is enabled
  44237. */
  44238. isEnabled: boolean;
  44239. /**
  44240. * Disposes of the gizmo
  44241. */
  44242. dispose(): void;
  44243. }
  44244. }
  44245. declare module "babylonjs/Gizmos/positionGizmo" {
  44246. import { Observable } from "babylonjs/Misc/observable";
  44247. import { Nullable } from "babylonjs/types";
  44248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44249. import { Mesh } from "babylonjs/Meshes/mesh";
  44250. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44251. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44252. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44253. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44254. /**
  44255. * Gizmo that enables dragging a mesh along 3 axis
  44256. */
  44257. export class PositionGizmo extends Gizmo {
  44258. /**
  44259. * Internal gizmo used for interactions on the x axis
  44260. */
  44261. xGizmo: AxisDragGizmo;
  44262. /**
  44263. * Internal gizmo used for interactions on the y axis
  44264. */
  44265. yGizmo: AxisDragGizmo;
  44266. /**
  44267. * Internal gizmo used for interactions on the z axis
  44268. */
  44269. zGizmo: AxisDragGizmo;
  44270. /**
  44271. * Internal gizmo used for interactions on the yz plane
  44272. */
  44273. xPlaneGizmo: PlaneDragGizmo;
  44274. /**
  44275. * Internal gizmo used for interactions on the xz plane
  44276. */
  44277. yPlaneGizmo: PlaneDragGizmo;
  44278. /**
  44279. * Internal gizmo used for interactions on the xy plane
  44280. */
  44281. zPlaneGizmo: PlaneDragGizmo;
  44282. /**
  44283. * private variables
  44284. */
  44285. private _meshAttached;
  44286. private _updateGizmoRotationToMatchAttachedMesh;
  44287. private _snapDistance;
  44288. private _scaleRatio;
  44289. /** Fires an event when any of it's sub gizmos are dragged */
  44290. onDragStartObservable: Observable<unknown>;
  44291. /** Fires an event when any of it's sub gizmos are released from dragging */
  44292. onDragEndObservable: Observable<unknown>;
  44293. /**
  44294. * If set to true, planar drag is enabled
  44295. */
  44296. private _planarGizmoEnabled;
  44297. attachedMesh: Nullable<AbstractMesh>;
  44298. /**
  44299. * Creates a PositionGizmo
  44300. * @param gizmoLayer The utility layer the gizmo will be added to
  44301. */
  44302. constructor(gizmoLayer?: UtilityLayerRenderer);
  44303. /**
  44304. * If the planar drag gizmo is enabled
  44305. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44306. */
  44307. planarGizmoEnabled: boolean;
  44308. updateGizmoRotationToMatchAttachedMesh: boolean;
  44309. /**
  44310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44311. */
  44312. snapDistance: number;
  44313. /**
  44314. * Ratio for the scale of the gizmo (Default: 1)
  44315. */
  44316. scaleRatio: number;
  44317. /**
  44318. * Disposes of the gizmo
  44319. */
  44320. dispose(): void;
  44321. /**
  44322. * CustomMeshes are not supported by this gizmo
  44323. * @param mesh The mesh to replace the default mesh of the gizmo
  44324. */
  44325. setCustomMesh(mesh: Mesh): void;
  44326. }
  44327. }
  44328. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44329. import { Observable } from "babylonjs/Misc/observable";
  44330. import { Nullable } from "babylonjs/types";
  44331. import { Vector3 } from "babylonjs/Maths/math.vector";
  44332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44334. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44335. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44336. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44337. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44338. import { Scene } from "babylonjs/scene";
  44339. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44340. import { Color3 } from "babylonjs/Maths/math.color";
  44341. /**
  44342. * Single axis drag gizmo
  44343. */
  44344. export class AxisDragGizmo extends Gizmo {
  44345. /**
  44346. * Drag behavior responsible for the gizmos dragging interactions
  44347. */
  44348. dragBehavior: PointerDragBehavior;
  44349. private _pointerObserver;
  44350. /**
  44351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44352. */
  44353. snapDistance: number;
  44354. /**
  44355. * Event that fires each time the gizmo snaps to a new location.
  44356. * * snapDistance is the the change in distance
  44357. */
  44358. onSnapObservable: Observable<{
  44359. snapDistance: number;
  44360. }>;
  44361. private _isEnabled;
  44362. private _parent;
  44363. private _arrow;
  44364. private _coloredMaterial;
  44365. private _hoverMaterial;
  44366. /** @hidden */
  44367. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44368. /** @hidden */
  44369. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44370. /**
  44371. * Creates an AxisDragGizmo
  44372. * @param gizmoLayer The utility layer the gizmo will be added to
  44373. * @param dragAxis The axis which the gizmo will be able to drag on
  44374. * @param color The color of the gizmo
  44375. */
  44376. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44377. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44378. /**
  44379. * If the gizmo is enabled
  44380. */
  44381. isEnabled: boolean;
  44382. /**
  44383. * Disposes of the gizmo
  44384. */
  44385. dispose(): void;
  44386. }
  44387. }
  44388. declare module "babylonjs/Debug/axesViewer" {
  44389. import { Vector3 } from "babylonjs/Maths/math.vector";
  44390. import { Nullable } from "babylonjs/types";
  44391. import { Scene } from "babylonjs/scene";
  44392. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44393. /**
  44394. * The Axes viewer will show 3 axes in a specific point in space
  44395. */
  44396. export class AxesViewer {
  44397. private _xAxis;
  44398. private _yAxis;
  44399. private _zAxis;
  44400. private _scaleLinesFactor;
  44401. private _instanced;
  44402. /**
  44403. * Gets the hosting scene
  44404. */
  44405. scene: Scene;
  44406. /**
  44407. * Gets or sets a number used to scale line length
  44408. */
  44409. scaleLines: number;
  44410. /** Gets the node hierarchy used to render x-axis */
  44411. readonly xAxis: TransformNode;
  44412. /** Gets the node hierarchy used to render y-axis */
  44413. readonly yAxis: TransformNode;
  44414. /** Gets the node hierarchy used to render z-axis */
  44415. readonly zAxis: TransformNode;
  44416. /**
  44417. * Creates a new AxesViewer
  44418. * @param scene defines the hosting scene
  44419. * @param scaleLines defines a number used to scale line length (1 by default)
  44420. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44421. * @param xAxis defines the node hierarchy used to render the x-axis
  44422. * @param yAxis defines the node hierarchy used to render the y-axis
  44423. * @param zAxis defines the node hierarchy used to render the z-axis
  44424. */
  44425. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44426. /**
  44427. * Force the viewer to update
  44428. * @param position defines the position of the viewer
  44429. * @param xaxis defines the x axis of the viewer
  44430. * @param yaxis defines the y axis of the viewer
  44431. * @param zaxis defines the z axis of the viewer
  44432. */
  44433. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44434. /**
  44435. * Creates an instance of this axes viewer.
  44436. * @returns a new axes viewer with instanced meshes
  44437. */
  44438. createInstance(): AxesViewer;
  44439. /** Releases resources */
  44440. dispose(): void;
  44441. private static _SetRenderingGroupId;
  44442. }
  44443. }
  44444. declare module "babylonjs/Debug/boneAxesViewer" {
  44445. import { Nullable } from "babylonjs/types";
  44446. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44447. import { Vector3 } from "babylonjs/Maths/math.vector";
  44448. import { Mesh } from "babylonjs/Meshes/mesh";
  44449. import { Bone } from "babylonjs/Bones/bone";
  44450. import { Scene } from "babylonjs/scene";
  44451. /**
  44452. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44453. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44454. */
  44455. export class BoneAxesViewer extends AxesViewer {
  44456. /**
  44457. * Gets or sets the target mesh where to display the axes viewer
  44458. */
  44459. mesh: Nullable<Mesh>;
  44460. /**
  44461. * Gets or sets the target bone where to display the axes viewer
  44462. */
  44463. bone: Nullable<Bone>;
  44464. /** Gets current position */
  44465. pos: Vector3;
  44466. /** Gets direction of X axis */
  44467. xaxis: Vector3;
  44468. /** Gets direction of Y axis */
  44469. yaxis: Vector3;
  44470. /** Gets direction of Z axis */
  44471. zaxis: Vector3;
  44472. /**
  44473. * Creates a new BoneAxesViewer
  44474. * @param scene defines the hosting scene
  44475. * @param bone defines the target bone
  44476. * @param mesh defines the target mesh
  44477. * @param scaleLines defines a scaling factor for line length (1 by default)
  44478. */
  44479. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44480. /**
  44481. * Force the viewer to update
  44482. */
  44483. update(): void;
  44484. /** Releases resources */
  44485. dispose(): void;
  44486. }
  44487. }
  44488. declare module "babylonjs/Debug/debugLayer" {
  44489. import { Scene } from "babylonjs/scene";
  44490. /**
  44491. * Interface used to define scene explorer extensibility option
  44492. */
  44493. export interface IExplorerExtensibilityOption {
  44494. /**
  44495. * Define the option label
  44496. */
  44497. label: string;
  44498. /**
  44499. * Defines the action to execute on click
  44500. */
  44501. action: (entity: any) => void;
  44502. }
  44503. /**
  44504. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44505. */
  44506. export interface IExplorerExtensibilityGroup {
  44507. /**
  44508. * Defines a predicate to test if a given type mut be extended
  44509. */
  44510. predicate: (entity: any) => boolean;
  44511. /**
  44512. * Gets the list of options added to a type
  44513. */
  44514. entries: IExplorerExtensibilityOption[];
  44515. }
  44516. /**
  44517. * Interface used to define the options to use to create the Inspector
  44518. */
  44519. export interface IInspectorOptions {
  44520. /**
  44521. * Display in overlay mode (default: false)
  44522. */
  44523. overlay?: boolean;
  44524. /**
  44525. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44526. */
  44527. globalRoot?: HTMLElement;
  44528. /**
  44529. * Display the Scene explorer
  44530. */
  44531. showExplorer?: boolean;
  44532. /**
  44533. * Display the property inspector
  44534. */
  44535. showInspector?: boolean;
  44536. /**
  44537. * Display in embed mode (both panes on the right)
  44538. */
  44539. embedMode?: boolean;
  44540. /**
  44541. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44542. */
  44543. handleResize?: boolean;
  44544. /**
  44545. * Allow the panes to popup (default: true)
  44546. */
  44547. enablePopup?: boolean;
  44548. /**
  44549. * Allow the panes to be closed by users (default: true)
  44550. */
  44551. enableClose?: boolean;
  44552. /**
  44553. * Optional list of extensibility entries
  44554. */
  44555. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44556. /**
  44557. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44558. */
  44559. inspectorURL?: string;
  44560. }
  44561. module "babylonjs/scene" {
  44562. interface Scene {
  44563. /**
  44564. * @hidden
  44565. * Backing field
  44566. */
  44567. _debugLayer: DebugLayer;
  44568. /**
  44569. * Gets the debug layer (aka Inspector) associated with the scene
  44570. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44571. */
  44572. debugLayer: DebugLayer;
  44573. }
  44574. }
  44575. /**
  44576. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44577. * what is happening in your scene
  44578. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44579. */
  44580. export class DebugLayer {
  44581. /**
  44582. * Define the url to get the inspector script from.
  44583. * By default it uses the babylonjs CDN.
  44584. * @ignoreNaming
  44585. */
  44586. static InspectorURL: string;
  44587. private _scene;
  44588. private BJSINSPECTOR;
  44589. private _onPropertyChangedObservable?;
  44590. /**
  44591. * Observable triggered when a property is changed through the inspector.
  44592. */
  44593. readonly onPropertyChangedObservable: any;
  44594. /**
  44595. * Instantiates a new debug layer.
  44596. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44597. * what is happening in your scene
  44598. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44599. * @param scene Defines the scene to inspect
  44600. */
  44601. constructor(scene: Scene);
  44602. /** Creates the inspector window. */
  44603. private _createInspector;
  44604. /**
  44605. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44606. * @param entity defines the entity to select
  44607. * @param lineContainerTitle defines the specific block to highlight
  44608. */
  44609. select(entity: any, lineContainerTitle?: string): void;
  44610. /** Get the inspector from bundle or global */
  44611. private _getGlobalInspector;
  44612. /**
  44613. * Get if the inspector is visible or not.
  44614. * @returns true if visible otherwise, false
  44615. */
  44616. isVisible(): boolean;
  44617. /**
  44618. * Hide the inspector and close its window.
  44619. */
  44620. hide(): void;
  44621. /**
  44622. * Launch the debugLayer.
  44623. * @param config Define the configuration of the inspector
  44624. * @return a promise fulfilled when the debug layer is visible
  44625. */
  44626. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44627. }
  44628. }
  44629. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44630. import { Nullable } from "babylonjs/types";
  44631. import { Scene } from "babylonjs/scene";
  44632. import { Vector4 } from "babylonjs/Maths/math.vector";
  44633. import { Color4 } from "babylonjs/Maths/math.color";
  44634. import { Mesh } from "babylonjs/Meshes/mesh";
  44635. /**
  44636. * Class containing static functions to help procedurally build meshes
  44637. */
  44638. export class BoxBuilder {
  44639. /**
  44640. * Creates a box mesh
  44641. * * The parameter `size` sets the size (float) of each box side (default 1)
  44642. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44643. * * 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)
  44644. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44648. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44649. * @param name defines the name of the mesh
  44650. * @param options defines the options used to create the mesh
  44651. * @param scene defines the hosting scene
  44652. * @returns the box mesh
  44653. */
  44654. static CreateBox(name: string, options: {
  44655. size?: number;
  44656. width?: number;
  44657. height?: number;
  44658. depth?: number;
  44659. faceUV?: Vector4[];
  44660. faceColors?: Color4[];
  44661. sideOrientation?: number;
  44662. frontUVs?: Vector4;
  44663. backUVs?: Vector4;
  44664. wrap?: boolean;
  44665. topBaseAt?: number;
  44666. bottomBaseAt?: number;
  44667. updatable?: boolean;
  44668. }, scene?: Nullable<Scene>): Mesh;
  44669. }
  44670. }
  44671. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44672. import { Vector4 } from "babylonjs/Maths/math.vector";
  44673. import { Mesh } from "babylonjs/Meshes/mesh";
  44674. /**
  44675. * Class containing static functions to help procedurally build meshes
  44676. */
  44677. export class SphereBuilder {
  44678. /**
  44679. * Creates a sphere mesh
  44680. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44681. * * 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`)
  44682. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44683. * * 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
  44684. * * 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)
  44685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44688. * @param name defines the name of the mesh
  44689. * @param options defines the options used to create the mesh
  44690. * @param scene defines the hosting scene
  44691. * @returns the sphere mesh
  44692. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44693. */
  44694. static CreateSphere(name: string, options: {
  44695. segments?: number;
  44696. diameter?: number;
  44697. diameterX?: number;
  44698. diameterY?: number;
  44699. diameterZ?: number;
  44700. arc?: number;
  44701. slice?: number;
  44702. sideOrientation?: number;
  44703. frontUVs?: Vector4;
  44704. backUVs?: Vector4;
  44705. updatable?: boolean;
  44706. }, scene: any): Mesh;
  44707. }
  44708. }
  44709. declare module "babylonjs/Debug/physicsViewer" {
  44710. import { Nullable } from "babylonjs/types";
  44711. import { Scene } from "babylonjs/scene";
  44712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44713. import { Mesh } from "babylonjs/Meshes/mesh";
  44714. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44715. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44716. /**
  44717. * Used to show the physics impostor around the specific mesh
  44718. */
  44719. export class PhysicsViewer {
  44720. /** @hidden */
  44721. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44722. /** @hidden */
  44723. protected _meshes: Array<Nullable<AbstractMesh>>;
  44724. /** @hidden */
  44725. protected _scene: Nullable<Scene>;
  44726. /** @hidden */
  44727. protected _numMeshes: number;
  44728. /** @hidden */
  44729. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44730. private _renderFunction;
  44731. private _utilityLayer;
  44732. private _debugBoxMesh;
  44733. private _debugSphereMesh;
  44734. private _debugCylinderMesh;
  44735. private _debugMaterial;
  44736. private _debugMeshMeshes;
  44737. /**
  44738. * Creates a new PhysicsViewer
  44739. * @param scene defines the hosting scene
  44740. */
  44741. constructor(scene: Scene);
  44742. /** @hidden */
  44743. protected _updateDebugMeshes(): void;
  44744. /**
  44745. * Renders a specified physic impostor
  44746. * @param impostor defines the impostor to render
  44747. * @param targetMesh defines the mesh represented by the impostor
  44748. * @returns the new debug mesh used to render the impostor
  44749. */
  44750. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44751. /**
  44752. * Hides a specified physic impostor
  44753. * @param impostor defines the impostor to hide
  44754. */
  44755. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44756. private _getDebugMaterial;
  44757. private _getDebugBoxMesh;
  44758. private _getDebugSphereMesh;
  44759. private _getDebugCylinderMesh;
  44760. private _getDebugMeshMesh;
  44761. private _getDebugMesh;
  44762. /** Releases all resources */
  44763. dispose(): void;
  44764. }
  44765. }
  44766. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44767. import { Vector3 } from "babylonjs/Maths/math.vector";
  44768. import { Color4 } from "babylonjs/Maths/math.color";
  44769. import { Nullable } from "babylonjs/types";
  44770. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44771. import { Scene } from "babylonjs/scene";
  44772. /**
  44773. * Class containing static functions to help procedurally build meshes
  44774. */
  44775. export class LinesBuilder {
  44776. /**
  44777. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44778. * * 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
  44779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44780. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44781. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44782. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44784. * * 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
  44785. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44788. * @param name defines the name of the new line system
  44789. * @param options defines the options used to create the line system
  44790. * @param scene defines the hosting scene
  44791. * @returns a new line system mesh
  44792. */
  44793. static CreateLineSystem(name: string, options: {
  44794. lines: Vector3[][];
  44795. updatable?: boolean;
  44796. instance?: Nullable<LinesMesh>;
  44797. colors?: Nullable<Color4[][]>;
  44798. useVertexAlpha?: boolean;
  44799. }, scene: Nullable<Scene>): LinesMesh;
  44800. /**
  44801. * Creates a line mesh
  44802. * 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
  44803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44804. * * The parameter `points` is an array successive Vector3
  44805. * * 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
  44806. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44808. * * When updating an instance, remember that only point positions can change, not the number of points
  44809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44811. * @param name defines the name of the new line system
  44812. * @param options defines the options used to create the line system
  44813. * @param scene defines the hosting scene
  44814. * @returns a new line mesh
  44815. */
  44816. static CreateLines(name: string, options: {
  44817. points: Vector3[];
  44818. updatable?: boolean;
  44819. instance?: Nullable<LinesMesh>;
  44820. colors?: Color4[];
  44821. useVertexAlpha?: boolean;
  44822. }, scene?: Nullable<Scene>): LinesMesh;
  44823. /**
  44824. * Creates a dashed line mesh
  44825. * * 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
  44826. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44827. * * The parameter `points` is an array successive Vector3
  44828. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44829. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44830. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44831. * * 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
  44832. * * When updating an instance, remember that only point positions can change, not the number of points
  44833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44834. * @param name defines the name of the mesh
  44835. * @param options defines the options used to create the mesh
  44836. * @param scene defines the hosting scene
  44837. * @returns the dashed line mesh
  44838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44839. */
  44840. static CreateDashedLines(name: string, options: {
  44841. points: Vector3[];
  44842. dashSize?: number;
  44843. gapSize?: number;
  44844. dashNb?: number;
  44845. updatable?: boolean;
  44846. instance?: LinesMesh;
  44847. }, scene?: Nullable<Scene>): LinesMesh;
  44848. }
  44849. }
  44850. declare module "babylonjs/Debug/rayHelper" {
  44851. import { Nullable } from "babylonjs/types";
  44852. import { Ray } from "babylonjs/Culling/ray";
  44853. import { Vector3 } from "babylonjs/Maths/math.vector";
  44854. import { Color3 } from "babylonjs/Maths/math.color";
  44855. import { Scene } from "babylonjs/scene";
  44856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44857. import "babylonjs/Meshes/Builders/linesBuilder";
  44858. /**
  44859. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44860. * in order to better appreciate the issue one might have.
  44861. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44862. */
  44863. export class RayHelper {
  44864. /**
  44865. * Defines the ray we are currently tryin to visualize.
  44866. */
  44867. ray: Nullable<Ray>;
  44868. private _renderPoints;
  44869. private _renderLine;
  44870. private _renderFunction;
  44871. private _scene;
  44872. private _updateToMeshFunction;
  44873. private _attachedToMesh;
  44874. private _meshSpaceDirection;
  44875. private _meshSpaceOrigin;
  44876. /**
  44877. * Helper function to create a colored helper in a scene in one line.
  44878. * @param ray Defines the ray we are currently tryin to visualize
  44879. * @param scene Defines the scene the ray is used in
  44880. * @param color Defines the color we want to see the ray in
  44881. * @returns The newly created ray helper.
  44882. */
  44883. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44884. /**
  44885. * Instantiate a new ray helper.
  44886. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44887. * in order to better appreciate the issue one might have.
  44888. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44889. * @param ray Defines the ray we are currently tryin to visualize
  44890. */
  44891. constructor(ray: Ray);
  44892. /**
  44893. * Shows the ray we are willing to debug.
  44894. * @param scene Defines the scene the ray needs to be rendered in
  44895. * @param color Defines the color the ray needs to be rendered in
  44896. */
  44897. show(scene: Scene, color?: Color3): void;
  44898. /**
  44899. * Hides the ray we are debugging.
  44900. */
  44901. hide(): void;
  44902. private _render;
  44903. /**
  44904. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44905. * @param mesh Defines the mesh we want the helper attached to
  44906. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44907. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44908. * @param length Defines the length of the ray
  44909. */
  44910. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44911. /**
  44912. * Detach the ray helper from the mesh it has previously been attached to.
  44913. */
  44914. detachFromMesh(): void;
  44915. private _updateToMesh;
  44916. /**
  44917. * Dispose the helper and release its associated resources.
  44918. */
  44919. dispose(): void;
  44920. }
  44921. }
  44922. declare module "babylonjs/Debug/skeletonViewer" {
  44923. import { Color3 } from "babylonjs/Maths/math.color";
  44924. import { Scene } from "babylonjs/scene";
  44925. import { Nullable } from "babylonjs/types";
  44926. import { Skeleton } from "babylonjs/Bones/skeleton";
  44927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44928. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44929. /**
  44930. * Class used to render a debug view of a given skeleton
  44931. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44932. */
  44933. export class SkeletonViewer {
  44934. /** defines the skeleton to render */
  44935. skeleton: Skeleton;
  44936. /** defines the mesh attached to the skeleton */
  44937. mesh: AbstractMesh;
  44938. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44939. autoUpdateBonesMatrices: boolean;
  44940. /** defines the rendering group id to use with the viewer */
  44941. renderingGroupId: number;
  44942. /** Gets or sets the color used to render the skeleton */
  44943. color: Color3;
  44944. private _scene;
  44945. private _debugLines;
  44946. private _debugMesh;
  44947. private _isEnabled;
  44948. private _renderFunction;
  44949. private _utilityLayer;
  44950. /**
  44951. * Returns the mesh used to render the bones
  44952. */
  44953. readonly debugMesh: Nullable<LinesMesh>;
  44954. /**
  44955. * Creates a new SkeletonViewer
  44956. * @param skeleton defines the skeleton to render
  44957. * @param mesh defines the mesh attached to the skeleton
  44958. * @param scene defines the hosting scene
  44959. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44960. * @param renderingGroupId defines the rendering group id to use with the viewer
  44961. */
  44962. constructor(
  44963. /** defines the skeleton to render */
  44964. skeleton: Skeleton,
  44965. /** defines the mesh attached to the skeleton */
  44966. mesh: AbstractMesh, scene: Scene,
  44967. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44968. autoUpdateBonesMatrices?: boolean,
  44969. /** defines the rendering group id to use with the viewer */
  44970. renderingGroupId?: number);
  44971. /** Gets or sets a boolean indicating if the viewer is enabled */
  44972. isEnabled: boolean;
  44973. private _getBonePosition;
  44974. private _getLinesForBonesWithLength;
  44975. private _getLinesForBonesNoLength;
  44976. /** Update the viewer to sync with current skeleton state */
  44977. update(): void;
  44978. /** Release associated resources */
  44979. dispose(): void;
  44980. }
  44981. }
  44982. declare module "babylonjs/Debug/index" {
  44983. export * from "babylonjs/Debug/axesViewer";
  44984. export * from "babylonjs/Debug/boneAxesViewer";
  44985. export * from "babylonjs/Debug/debugLayer";
  44986. export * from "babylonjs/Debug/physicsViewer";
  44987. export * from "babylonjs/Debug/rayHelper";
  44988. export * from "babylonjs/Debug/skeletonViewer";
  44989. }
  44990. declare module "babylonjs/Engines/nullEngine" {
  44991. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44992. import { Scene } from "babylonjs/scene";
  44993. import { Engine } from "babylonjs/Engines/engine";
  44994. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44995. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44997. import { Effect } from "babylonjs/Materials/effect";
  44998. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44999. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45000. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45001. /**
  45002. * Options to create the null engine
  45003. */
  45004. export class NullEngineOptions {
  45005. /**
  45006. * Render width (Default: 512)
  45007. */
  45008. renderWidth: number;
  45009. /**
  45010. * Render height (Default: 256)
  45011. */
  45012. renderHeight: number;
  45013. /**
  45014. * Texture size (Default: 512)
  45015. */
  45016. textureSize: number;
  45017. /**
  45018. * If delta time between frames should be constant
  45019. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45020. */
  45021. deterministicLockstep: boolean;
  45022. /**
  45023. * Maximum about of steps between frames (Default: 4)
  45024. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45025. */
  45026. lockstepMaxSteps: number;
  45027. }
  45028. /**
  45029. * The null engine class provides support for headless version of babylon.js.
  45030. * This can be used in server side scenario or for testing purposes
  45031. */
  45032. export class NullEngine extends Engine {
  45033. private _options;
  45034. /**
  45035. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45036. */
  45037. isDeterministicLockStep(): boolean;
  45038. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45039. getLockstepMaxSteps(): number;
  45040. /**
  45041. * Sets hardware scaling, used to save performance if needed
  45042. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45043. */
  45044. getHardwareScalingLevel(): number;
  45045. constructor(options?: NullEngineOptions);
  45046. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45047. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45048. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45049. getRenderWidth(useScreen?: boolean): number;
  45050. getRenderHeight(useScreen?: boolean): number;
  45051. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45052. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45054. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45055. bindSamplers(effect: Effect): void;
  45056. enableEffect(effect: Effect): void;
  45057. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45058. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45059. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45060. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45061. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45062. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45063. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45064. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45065. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45066. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45067. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45068. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45069. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45070. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45071. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45072. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45073. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45074. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45075. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45076. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45077. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45078. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45079. bindBuffers(vertexBuffers: {
  45080. [key: string]: VertexBuffer;
  45081. }, indexBuffer: DataBuffer, effect: Effect): void;
  45082. wipeCaches(bruteForce?: boolean): void;
  45083. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45085. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45086. /** @hidden */
  45087. _createTexture(): WebGLTexture;
  45088. /** @hidden */
  45089. _releaseTexture(texture: InternalTexture): void;
  45090. 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;
  45091. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45092. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45093. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45094. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45095. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45096. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45097. areAllEffectsReady(): boolean;
  45098. /**
  45099. * @hidden
  45100. * Get the current error code of the webGL context
  45101. * @returns the error code
  45102. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45103. */
  45104. getError(): number;
  45105. /** @hidden */
  45106. _getUnpackAlignement(): number;
  45107. /** @hidden */
  45108. _unpackFlipY(value: boolean): void;
  45109. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45110. /**
  45111. * Updates a dynamic vertex buffer.
  45112. * @param vertexBuffer the vertex buffer to update
  45113. * @param data the data used to update the vertex buffer
  45114. * @param byteOffset the byte offset of the data (optional)
  45115. * @param byteLength the byte length of the data (optional)
  45116. */
  45117. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45118. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45119. /** @hidden */
  45120. _bindTexture(channel: number, texture: InternalTexture): void;
  45121. /** @hidden */
  45122. _releaseBuffer(buffer: DataBuffer): boolean;
  45123. releaseEffects(): void;
  45124. displayLoadingUI(): void;
  45125. hideLoadingUI(): void;
  45126. /** @hidden */
  45127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45128. /** @hidden */
  45129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45130. /** @hidden */
  45131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45132. /** @hidden */
  45133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45134. }
  45135. }
  45136. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45137. import { Nullable, int } from "babylonjs/types";
  45138. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45139. /** @hidden */
  45140. export class _OcclusionDataStorage {
  45141. /** @hidden */
  45142. occlusionInternalRetryCounter: number;
  45143. /** @hidden */
  45144. isOcclusionQueryInProgress: boolean;
  45145. /** @hidden */
  45146. isOccluded: boolean;
  45147. /** @hidden */
  45148. occlusionRetryCount: number;
  45149. /** @hidden */
  45150. occlusionType: number;
  45151. /** @hidden */
  45152. occlusionQueryAlgorithmType: number;
  45153. }
  45154. module "babylonjs/Engines/engine" {
  45155. interface Engine {
  45156. /**
  45157. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45158. * @return the new query
  45159. */
  45160. createQuery(): WebGLQuery;
  45161. /**
  45162. * Delete and release a webGL query
  45163. * @param query defines the query to delete
  45164. * @return the current engine
  45165. */
  45166. deleteQuery(query: WebGLQuery): Engine;
  45167. /**
  45168. * Check if a given query has resolved and got its value
  45169. * @param query defines the query to check
  45170. * @returns true if the query got its value
  45171. */
  45172. isQueryResultAvailable(query: WebGLQuery): boolean;
  45173. /**
  45174. * Gets the value of a given query
  45175. * @param query defines the query to check
  45176. * @returns the value of the query
  45177. */
  45178. getQueryResult(query: WebGLQuery): number;
  45179. /**
  45180. * Initiates an occlusion query
  45181. * @param algorithmType defines the algorithm to use
  45182. * @param query defines the query to use
  45183. * @returns the current engine
  45184. * @see http://doc.babylonjs.com/features/occlusionquery
  45185. */
  45186. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45187. /**
  45188. * Ends an occlusion query
  45189. * @see http://doc.babylonjs.com/features/occlusionquery
  45190. * @param algorithmType defines the algorithm to use
  45191. * @returns the current engine
  45192. */
  45193. endOcclusionQuery(algorithmType: number): Engine;
  45194. /**
  45195. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45196. * Please note that only one query can be issued at a time
  45197. * @returns a time token used to track the time span
  45198. */
  45199. startTimeQuery(): Nullable<_TimeToken>;
  45200. /**
  45201. * Ends a time query
  45202. * @param token defines the token used to measure the time span
  45203. * @returns the time spent (in ns)
  45204. */
  45205. endTimeQuery(token: _TimeToken): int;
  45206. /** @hidden */
  45207. _currentNonTimestampToken: Nullable<_TimeToken>;
  45208. /** @hidden */
  45209. _createTimeQuery(): WebGLQuery;
  45210. /** @hidden */
  45211. _deleteTimeQuery(query: WebGLQuery): void;
  45212. /** @hidden */
  45213. _getGlAlgorithmType(algorithmType: number): number;
  45214. /** @hidden */
  45215. _getTimeQueryResult(query: WebGLQuery): any;
  45216. /** @hidden */
  45217. _getTimeQueryAvailability(query: WebGLQuery): any;
  45218. }
  45219. }
  45220. module "babylonjs/Meshes/abstractMesh" {
  45221. interface AbstractMesh {
  45222. /**
  45223. * Backing filed
  45224. * @hidden
  45225. */
  45226. __occlusionDataStorage: _OcclusionDataStorage;
  45227. /**
  45228. * Access property
  45229. * @hidden
  45230. */
  45231. _occlusionDataStorage: _OcclusionDataStorage;
  45232. /**
  45233. * 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.
  45234. * The default value is -1 which means don't break the query and wait till the result
  45235. * @see http://doc.babylonjs.com/features/occlusionquery
  45236. */
  45237. occlusionRetryCount: number;
  45238. /**
  45239. * 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:
  45240. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45241. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45242. * * 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.
  45243. * @see http://doc.babylonjs.com/features/occlusionquery
  45244. */
  45245. occlusionType: number;
  45246. /**
  45247. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45248. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45249. * * 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.
  45250. * @see http://doc.babylonjs.com/features/occlusionquery
  45251. */
  45252. occlusionQueryAlgorithmType: number;
  45253. /**
  45254. * 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
  45255. * @see http://doc.babylonjs.com/features/occlusionquery
  45256. */
  45257. isOccluded: boolean;
  45258. /**
  45259. * Flag to check the progress status of the query
  45260. * @see http://doc.babylonjs.com/features/occlusionquery
  45261. */
  45262. isOcclusionQueryInProgress: boolean;
  45263. }
  45264. }
  45265. }
  45266. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45267. import { Nullable } from "babylonjs/types";
  45268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45269. /** @hidden */
  45270. export var _forceTransformFeedbackToBundle: boolean;
  45271. module "babylonjs/Engines/engine" {
  45272. interface Engine {
  45273. /**
  45274. * Creates a webGL transform feedback object
  45275. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45276. * @returns the webGL transform feedback object
  45277. */
  45278. createTransformFeedback(): WebGLTransformFeedback;
  45279. /**
  45280. * Delete a webGL transform feedback object
  45281. * @param value defines the webGL transform feedback object to delete
  45282. */
  45283. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45284. /**
  45285. * Bind a webGL transform feedback object to the webgl context
  45286. * @param value defines the webGL transform feedback object to bind
  45287. */
  45288. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45289. /**
  45290. * Begins a transform feedback operation
  45291. * @param usePoints defines if points or triangles must be used
  45292. */
  45293. beginTransformFeedback(usePoints: boolean): void;
  45294. /**
  45295. * Ends a transform feedback operation
  45296. */
  45297. endTransformFeedback(): void;
  45298. /**
  45299. * Specify the varyings to use with transform feedback
  45300. * @param program defines the associated webGL program
  45301. * @param value defines the list of strings representing the varying names
  45302. */
  45303. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45304. /**
  45305. * Bind a webGL buffer for a transform feedback operation
  45306. * @param value defines the webGL buffer to bind
  45307. */
  45308. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45309. }
  45310. }
  45311. }
  45312. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45313. import { Scene } from "babylonjs/scene";
  45314. import { Engine } from "babylonjs/Engines/engine";
  45315. import { Texture } from "babylonjs/Materials/Textures/texture";
  45316. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45317. import "babylonjs/Engines/Extensions/engine.multiRender";
  45318. /**
  45319. * Creation options of the multi render target texture.
  45320. */
  45321. export interface IMultiRenderTargetOptions {
  45322. /**
  45323. * Define if the texture needs to create mip maps after render.
  45324. */
  45325. generateMipMaps?: boolean;
  45326. /**
  45327. * Define the types of all the draw buffers we want to create
  45328. */
  45329. types?: number[];
  45330. /**
  45331. * Define the sampling modes of all the draw buffers we want to create
  45332. */
  45333. samplingModes?: number[];
  45334. /**
  45335. * Define if a depth buffer is required
  45336. */
  45337. generateDepthBuffer?: boolean;
  45338. /**
  45339. * Define if a stencil buffer is required
  45340. */
  45341. generateStencilBuffer?: boolean;
  45342. /**
  45343. * Define if a depth texture is required instead of a depth buffer
  45344. */
  45345. generateDepthTexture?: boolean;
  45346. /**
  45347. * Define the number of desired draw buffers
  45348. */
  45349. textureCount?: number;
  45350. /**
  45351. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45352. */
  45353. doNotChangeAspectRatio?: boolean;
  45354. /**
  45355. * Define the default type of the buffers we are creating
  45356. */
  45357. defaultType?: number;
  45358. }
  45359. /**
  45360. * A multi render target, like a render target provides the ability to render to a texture.
  45361. * Unlike the render target, it can render to several draw buffers in one draw.
  45362. * This is specially interesting in deferred rendering or for any effects requiring more than
  45363. * just one color from a single pass.
  45364. */
  45365. export class MultiRenderTarget extends RenderTargetTexture {
  45366. private _internalTextures;
  45367. private _textures;
  45368. private _multiRenderTargetOptions;
  45369. /**
  45370. * Get if draw buffers are currently supported by the used hardware and browser.
  45371. */
  45372. readonly isSupported: boolean;
  45373. /**
  45374. * Get the list of textures generated by the multi render target.
  45375. */
  45376. readonly textures: Texture[];
  45377. /**
  45378. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45379. */
  45380. readonly depthTexture: Texture;
  45381. /**
  45382. * Set the wrapping mode on U of all the textures we are rendering to.
  45383. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45384. */
  45385. wrapU: number;
  45386. /**
  45387. * Set the wrapping mode on V of all the textures we are rendering to.
  45388. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45389. */
  45390. wrapV: number;
  45391. /**
  45392. * Instantiate a new multi render target texture.
  45393. * A multi render target, like a render target provides the ability to render to a texture.
  45394. * Unlike the render target, it can render to several draw buffers in one draw.
  45395. * This is specially interesting in deferred rendering or for any effects requiring more than
  45396. * just one color from a single pass.
  45397. * @param name Define the name of the texture
  45398. * @param size Define the size of the buffers to render to
  45399. * @param count Define the number of target we are rendering into
  45400. * @param scene Define the scene the texture belongs to
  45401. * @param options Define the options used to create the multi render target
  45402. */
  45403. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45404. /** @hidden */
  45405. _rebuild(): void;
  45406. private _createInternalTextures;
  45407. private _createTextures;
  45408. /**
  45409. * Define the number of samples used if MSAA is enabled.
  45410. */
  45411. samples: number;
  45412. /**
  45413. * Resize all the textures in the multi render target.
  45414. * Be carrefull as it will recreate all the data in the new texture.
  45415. * @param size Define the new size
  45416. */
  45417. resize(size: any): void;
  45418. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45419. /**
  45420. * Dispose the render targets and their associated resources
  45421. */
  45422. dispose(): void;
  45423. /**
  45424. * Release all the underlying texture used as draw buffers.
  45425. */
  45426. releaseInternalTextures(): void;
  45427. }
  45428. }
  45429. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45431. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45432. import { Nullable } from "babylonjs/types";
  45433. module "babylonjs/Engines/engine" {
  45434. interface Engine {
  45435. /**
  45436. * Unbind a list of render target textures from the webGL context
  45437. * This is used only when drawBuffer extension or webGL2 are active
  45438. * @param textures defines the render target textures to unbind
  45439. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45440. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45441. */
  45442. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45443. /**
  45444. * Create a multi render target texture
  45445. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45446. * @param size defines the size of the texture
  45447. * @param options defines the creation options
  45448. * @returns the cube texture as an InternalTexture
  45449. */
  45450. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45451. /**
  45452. * Update the sample count for a given multiple render target texture
  45453. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45454. * @param textures defines the textures to update
  45455. * @param samples defines the sample count to set
  45456. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45457. */
  45458. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45459. }
  45460. }
  45461. }
  45462. declare module "babylonjs/Engines/Extensions/index" {
  45463. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45464. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45465. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45466. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45467. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45468. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45469. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45470. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45471. }
  45472. declare module "babylonjs/Engines/index" {
  45473. export * from "babylonjs/Engines/constants";
  45474. export * from "babylonjs/Engines/engine";
  45475. export * from "babylonjs/Engines/engineStore";
  45476. export * from "babylonjs/Engines/nullEngine";
  45477. export * from "babylonjs/Engines/Extensions/index";
  45478. export * from "babylonjs/Engines/IPipelineContext";
  45479. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45480. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45481. }
  45482. declare module "babylonjs/Events/clipboardEvents" {
  45483. /**
  45484. * Gather the list of clipboard event types as constants.
  45485. */
  45486. export class ClipboardEventTypes {
  45487. /**
  45488. * The clipboard event is fired when a copy command is active (pressed).
  45489. */
  45490. static readonly COPY: number;
  45491. /**
  45492. * The clipboard event is fired when a cut command is active (pressed).
  45493. */
  45494. static readonly CUT: number;
  45495. /**
  45496. * The clipboard event is fired when a paste command is active (pressed).
  45497. */
  45498. static readonly PASTE: number;
  45499. }
  45500. /**
  45501. * This class is used to store clipboard related info for the onClipboardObservable event.
  45502. */
  45503. export class ClipboardInfo {
  45504. /**
  45505. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45506. */
  45507. type: number;
  45508. /**
  45509. * Defines the related dom event
  45510. */
  45511. event: ClipboardEvent;
  45512. /**
  45513. *Creates an instance of ClipboardInfo.
  45514. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45515. * @param event Defines the related dom event
  45516. */
  45517. constructor(
  45518. /**
  45519. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45520. */
  45521. type: number,
  45522. /**
  45523. * Defines the related dom event
  45524. */
  45525. event: ClipboardEvent);
  45526. /**
  45527. * Get the clipboard event's type from the keycode.
  45528. * @param keyCode Defines the keyCode for the current keyboard event.
  45529. * @return {number}
  45530. */
  45531. static GetTypeFromCharacter(keyCode: number): number;
  45532. }
  45533. }
  45534. declare module "babylonjs/Events/index" {
  45535. export * from "babylonjs/Events/keyboardEvents";
  45536. export * from "babylonjs/Events/pointerEvents";
  45537. export * from "babylonjs/Events/clipboardEvents";
  45538. }
  45539. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45540. import { Scene } from "babylonjs/scene";
  45541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45542. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45543. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45544. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45545. /**
  45546. * Google Daydream controller
  45547. */
  45548. export class DaydreamController extends WebVRController {
  45549. /**
  45550. * Base Url for the controller model.
  45551. */
  45552. static MODEL_BASE_URL: string;
  45553. /**
  45554. * File name for the controller model.
  45555. */
  45556. static MODEL_FILENAME: string;
  45557. /**
  45558. * Gamepad Id prefix used to identify Daydream Controller.
  45559. */
  45560. static readonly GAMEPAD_ID_PREFIX: string;
  45561. /**
  45562. * Creates a new DaydreamController from a gamepad
  45563. * @param vrGamepad the gamepad that the controller should be created from
  45564. */
  45565. constructor(vrGamepad: any);
  45566. /**
  45567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45568. * @param scene scene in which to add meshes
  45569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45570. */
  45571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45572. /**
  45573. * Called once for each button that changed state since the last frame
  45574. * @param buttonIdx Which button index changed
  45575. * @param state New state of the button
  45576. * @param changes Which properties on the state changed since last frame
  45577. */
  45578. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45579. }
  45580. }
  45581. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45582. import { Scene } from "babylonjs/scene";
  45583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45584. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45585. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45586. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45587. /**
  45588. * Gear VR Controller
  45589. */
  45590. export class GearVRController extends WebVRController {
  45591. /**
  45592. * Base Url for the controller model.
  45593. */
  45594. static MODEL_BASE_URL: string;
  45595. /**
  45596. * File name for the controller model.
  45597. */
  45598. static MODEL_FILENAME: string;
  45599. /**
  45600. * Gamepad Id prefix used to identify this controller.
  45601. */
  45602. static readonly GAMEPAD_ID_PREFIX: string;
  45603. private readonly _buttonIndexToObservableNameMap;
  45604. /**
  45605. * Creates a new GearVRController from a gamepad
  45606. * @param vrGamepad the gamepad that the controller should be created from
  45607. */
  45608. constructor(vrGamepad: any);
  45609. /**
  45610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45611. * @param scene scene in which to add meshes
  45612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45613. */
  45614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45615. /**
  45616. * Called once for each button that changed state since the last frame
  45617. * @param buttonIdx Which button index changed
  45618. * @param state New state of the button
  45619. * @param changes Which properties on the state changed since last frame
  45620. */
  45621. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45622. }
  45623. }
  45624. declare module "babylonjs/Gamepads/Controllers/index" {
  45625. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45626. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45627. export * from "babylonjs/Gamepads/Controllers/genericController";
  45628. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45629. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45630. export * from "babylonjs/Gamepads/Controllers/viveController";
  45631. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45632. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45633. }
  45634. declare module "babylonjs/Gamepads/index" {
  45635. export * from "babylonjs/Gamepads/Controllers/index";
  45636. export * from "babylonjs/Gamepads/gamepad";
  45637. export * from "babylonjs/Gamepads/gamepadManager";
  45638. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45639. export * from "babylonjs/Gamepads/xboxGamepad";
  45640. export * from "babylonjs/Gamepads/dualShockGamepad";
  45641. }
  45642. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45643. import { Scene } from "babylonjs/scene";
  45644. import { Vector4 } from "babylonjs/Maths/math.vector";
  45645. import { Color4 } from "babylonjs/Maths/math.color";
  45646. import { Mesh } from "babylonjs/Meshes/mesh";
  45647. import { Nullable } from "babylonjs/types";
  45648. /**
  45649. * Class containing static functions to help procedurally build meshes
  45650. */
  45651. export class PolyhedronBuilder {
  45652. /**
  45653. * Creates a polyhedron mesh
  45654. * * 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
  45655. * * The parameter `size` (positive float, default 1) sets the polygon size
  45656. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45657. * * 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`
  45658. * * 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
  45659. * * 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)`)
  45660. * * 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
  45661. * * 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
  45662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45665. * @param name defines the name of the mesh
  45666. * @param options defines the options used to create the mesh
  45667. * @param scene defines the hosting scene
  45668. * @returns the polyhedron mesh
  45669. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45670. */
  45671. static CreatePolyhedron(name: string, options: {
  45672. type?: number;
  45673. size?: number;
  45674. sizeX?: number;
  45675. sizeY?: number;
  45676. sizeZ?: number;
  45677. custom?: any;
  45678. faceUV?: Vector4[];
  45679. faceColors?: Color4[];
  45680. flat?: boolean;
  45681. updatable?: boolean;
  45682. sideOrientation?: number;
  45683. frontUVs?: Vector4;
  45684. backUVs?: Vector4;
  45685. }, scene?: Nullable<Scene>): Mesh;
  45686. }
  45687. }
  45688. declare module "babylonjs/Gizmos/scaleGizmo" {
  45689. import { Observable } from "babylonjs/Misc/observable";
  45690. import { Nullable } from "babylonjs/types";
  45691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45692. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45693. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45695. /**
  45696. * Gizmo that enables scaling a mesh along 3 axis
  45697. */
  45698. export class ScaleGizmo extends Gizmo {
  45699. /**
  45700. * Internal gizmo used for interactions on the x axis
  45701. */
  45702. xGizmo: AxisScaleGizmo;
  45703. /**
  45704. * Internal gizmo used for interactions on the y axis
  45705. */
  45706. yGizmo: AxisScaleGizmo;
  45707. /**
  45708. * Internal gizmo used for interactions on the z axis
  45709. */
  45710. zGizmo: AxisScaleGizmo;
  45711. /**
  45712. * Internal gizmo used to scale all axis equally
  45713. */
  45714. uniformScaleGizmo: AxisScaleGizmo;
  45715. private _meshAttached;
  45716. private _updateGizmoRotationToMatchAttachedMesh;
  45717. private _snapDistance;
  45718. private _scaleRatio;
  45719. private _uniformScalingMesh;
  45720. private _octahedron;
  45721. /** Fires an event when any of it's sub gizmos are dragged */
  45722. onDragStartObservable: Observable<unknown>;
  45723. /** Fires an event when any of it's sub gizmos are released from dragging */
  45724. onDragEndObservable: Observable<unknown>;
  45725. attachedMesh: Nullable<AbstractMesh>;
  45726. /**
  45727. * Creates a ScaleGizmo
  45728. * @param gizmoLayer The utility layer the gizmo will be added to
  45729. */
  45730. constructor(gizmoLayer?: UtilityLayerRenderer);
  45731. updateGizmoRotationToMatchAttachedMesh: boolean;
  45732. /**
  45733. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45734. */
  45735. snapDistance: number;
  45736. /**
  45737. * Ratio for the scale of the gizmo (Default: 1)
  45738. */
  45739. scaleRatio: number;
  45740. /**
  45741. * Disposes of the gizmo
  45742. */
  45743. dispose(): void;
  45744. }
  45745. }
  45746. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45747. import { Observable } from "babylonjs/Misc/observable";
  45748. import { Nullable } from "babylonjs/types";
  45749. import { Vector3 } from "babylonjs/Maths/math.vector";
  45750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45751. import { Mesh } from "babylonjs/Meshes/mesh";
  45752. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45753. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45754. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45755. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45756. import { Color3 } from "babylonjs/Maths/math.color";
  45757. /**
  45758. * Single axis scale gizmo
  45759. */
  45760. export class AxisScaleGizmo extends Gizmo {
  45761. /**
  45762. * Drag behavior responsible for the gizmos dragging interactions
  45763. */
  45764. dragBehavior: PointerDragBehavior;
  45765. private _pointerObserver;
  45766. /**
  45767. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45768. */
  45769. snapDistance: number;
  45770. /**
  45771. * Event that fires each time the gizmo snaps to a new location.
  45772. * * snapDistance is the the change in distance
  45773. */
  45774. onSnapObservable: Observable<{
  45775. snapDistance: number;
  45776. }>;
  45777. /**
  45778. * If the scaling operation should be done on all axis (default: false)
  45779. */
  45780. uniformScaling: boolean;
  45781. private _isEnabled;
  45782. private _parent;
  45783. private _arrow;
  45784. private _coloredMaterial;
  45785. private _hoverMaterial;
  45786. /**
  45787. * Creates an AxisScaleGizmo
  45788. * @param gizmoLayer The utility layer the gizmo will be added to
  45789. * @param dragAxis The axis which the gizmo will be able to scale on
  45790. * @param color The color of the gizmo
  45791. */
  45792. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45793. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45794. /**
  45795. * If the gizmo is enabled
  45796. */
  45797. isEnabled: boolean;
  45798. /**
  45799. * Disposes of the gizmo
  45800. */
  45801. dispose(): void;
  45802. /**
  45803. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45804. * @param mesh The mesh to replace the default mesh of the gizmo
  45805. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45806. */
  45807. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45808. }
  45809. }
  45810. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45811. import { Observable } from "babylonjs/Misc/observable";
  45812. import { Nullable } from "babylonjs/types";
  45813. import { Vector3 } from "babylonjs/Maths/math.vector";
  45814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45815. import { Mesh } from "babylonjs/Meshes/mesh";
  45816. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45818. import { Color3 } from "babylonjs/Maths/math.color";
  45819. import "babylonjs/Meshes/Builders/boxBuilder";
  45820. /**
  45821. * Bounding box gizmo
  45822. */
  45823. export class BoundingBoxGizmo extends Gizmo {
  45824. private _lineBoundingBox;
  45825. private _rotateSpheresParent;
  45826. private _scaleBoxesParent;
  45827. private _boundingDimensions;
  45828. private _renderObserver;
  45829. private _pointerObserver;
  45830. private _scaleDragSpeed;
  45831. private _tmpQuaternion;
  45832. private _tmpVector;
  45833. private _tmpRotationMatrix;
  45834. /**
  45835. * 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)
  45836. */
  45837. ignoreChildren: boolean;
  45838. /**
  45839. * 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)
  45840. */
  45841. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45842. /**
  45843. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45844. */
  45845. rotationSphereSize: number;
  45846. /**
  45847. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45848. */
  45849. scaleBoxSize: number;
  45850. /**
  45851. * 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)
  45852. */
  45853. fixedDragMeshScreenSize: boolean;
  45854. /**
  45855. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45856. */
  45857. fixedDragMeshScreenSizeDistanceFactor: number;
  45858. /**
  45859. * Fired when a rotation sphere or scale box is dragged
  45860. */
  45861. onDragStartObservable: Observable<{}>;
  45862. /**
  45863. * Fired when a scale box is dragged
  45864. */
  45865. onScaleBoxDragObservable: Observable<{}>;
  45866. /**
  45867. * Fired when a scale box drag is ended
  45868. */
  45869. onScaleBoxDragEndObservable: Observable<{}>;
  45870. /**
  45871. * Fired when a rotation sphere is dragged
  45872. */
  45873. onRotationSphereDragObservable: Observable<{}>;
  45874. /**
  45875. * Fired when a rotation sphere drag is ended
  45876. */
  45877. onRotationSphereDragEndObservable: Observable<{}>;
  45878. /**
  45879. * 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)
  45880. */
  45881. scalePivot: Nullable<Vector3>;
  45882. /**
  45883. * Mesh used as a pivot to rotate the attached mesh
  45884. */
  45885. private _anchorMesh;
  45886. private _existingMeshScale;
  45887. private _dragMesh;
  45888. private pointerDragBehavior;
  45889. private coloredMaterial;
  45890. private hoverColoredMaterial;
  45891. /**
  45892. * Sets the color of the bounding box gizmo
  45893. * @param color the color to set
  45894. */
  45895. setColor(color: Color3): void;
  45896. /**
  45897. * Creates an BoundingBoxGizmo
  45898. * @param gizmoLayer The utility layer the gizmo will be added to
  45899. * @param color The color of the gizmo
  45900. */
  45901. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45902. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45903. private _selectNode;
  45904. /**
  45905. * Updates the bounding box information for the Gizmo
  45906. */
  45907. updateBoundingBox(): void;
  45908. private _updateRotationSpheres;
  45909. private _updateScaleBoxes;
  45910. /**
  45911. * Enables rotation on the specified axis and disables rotation on the others
  45912. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45913. */
  45914. setEnabledRotationAxis(axis: string): void;
  45915. /**
  45916. * Enables/disables scaling
  45917. * @param enable if scaling should be enabled
  45918. */
  45919. setEnabledScaling(enable: boolean): void;
  45920. private _updateDummy;
  45921. /**
  45922. * Enables a pointer drag behavior on the bounding box of the gizmo
  45923. */
  45924. enableDragBehavior(): void;
  45925. /**
  45926. * Disposes of the gizmo
  45927. */
  45928. dispose(): void;
  45929. /**
  45930. * 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)
  45931. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45932. * @returns the bounding box mesh with the passed in mesh as a child
  45933. */
  45934. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45935. /**
  45936. * CustomMeshes are not supported by this gizmo
  45937. * @param mesh The mesh to replace the default mesh of the gizmo
  45938. */
  45939. setCustomMesh(mesh: Mesh): void;
  45940. }
  45941. }
  45942. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45943. import { Observable } from "babylonjs/Misc/observable";
  45944. import { Nullable } from "babylonjs/types";
  45945. import { Vector3 } from "babylonjs/Maths/math.vector";
  45946. import { Color3 } from "babylonjs/Maths/math.color";
  45947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45948. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45949. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45950. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45951. import "babylonjs/Meshes/Builders/linesBuilder";
  45952. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45953. /**
  45954. * Single plane rotation gizmo
  45955. */
  45956. export class PlaneRotationGizmo extends Gizmo {
  45957. /**
  45958. * Drag behavior responsible for the gizmos dragging interactions
  45959. */
  45960. dragBehavior: PointerDragBehavior;
  45961. private _pointerObserver;
  45962. /**
  45963. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45964. */
  45965. snapDistance: number;
  45966. /**
  45967. * Event that fires each time the gizmo snaps to a new location.
  45968. * * snapDistance is the the change in distance
  45969. */
  45970. onSnapObservable: Observable<{
  45971. snapDistance: number;
  45972. }>;
  45973. private _isEnabled;
  45974. private _parent;
  45975. /**
  45976. * Creates a PlaneRotationGizmo
  45977. * @param gizmoLayer The utility layer the gizmo will be added to
  45978. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45979. * @param color The color of the gizmo
  45980. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45981. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45982. */
  45983. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45984. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45985. /**
  45986. * If the gizmo is enabled
  45987. */
  45988. isEnabled: boolean;
  45989. /**
  45990. * Disposes of the gizmo
  45991. */
  45992. dispose(): void;
  45993. }
  45994. }
  45995. declare module "babylonjs/Gizmos/rotationGizmo" {
  45996. import { Observable } from "babylonjs/Misc/observable";
  45997. import { Nullable } from "babylonjs/types";
  45998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45999. import { Mesh } from "babylonjs/Meshes/mesh";
  46000. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46001. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46002. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46003. /**
  46004. * Gizmo that enables rotating a mesh along 3 axis
  46005. */
  46006. export class RotationGizmo extends Gizmo {
  46007. /**
  46008. * Internal gizmo used for interactions on the x axis
  46009. */
  46010. xGizmo: PlaneRotationGizmo;
  46011. /**
  46012. * Internal gizmo used for interactions on the y axis
  46013. */
  46014. yGizmo: PlaneRotationGizmo;
  46015. /**
  46016. * Internal gizmo used for interactions on the z axis
  46017. */
  46018. zGizmo: PlaneRotationGizmo;
  46019. /** Fires an event when any of it's sub gizmos are dragged */
  46020. onDragStartObservable: Observable<unknown>;
  46021. /** Fires an event when any of it's sub gizmos are released from dragging */
  46022. onDragEndObservable: Observable<unknown>;
  46023. private _meshAttached;
  46024. attachedMesh: Nullable<AbstractMesh>;
  46025. /**
  46026. * Creates a RotationGizmo
  46027. * @param gizmoLayer The utility layer the gizmo will be added to
  46028. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46029. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46030. */
  46031. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46032. updateGizmoRotationToMatchAttachedMesh: boolean;
  46033. /**
  46034. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46035. */
  46036. snapDistance: number;
  46037. /**
  46038. * Ratio for the scale of the gizmo (Default: 1)
  46039. */
  46040. scaleRatio: number;
  46041. /**
  46042. * Disposes of the gizmo
  46043. */
  46044. dispose(): void;
  46045. /**
  46046. * CustomMeshes are not supported by this gizmo
  46047. * @param mesh The mesh to replace the default mesh of the gizmo
  46048. */
  46049. setCustomMesh(mesh: Mesh): void;
  46050. }
  46051. }
  46052. declare module "babylonjs/Gizmos/gizmoManager" {
  46053. import { Observable } from "babylonjs/Misc/observable";
  46054. import { Nullable } from "babylonjs/types";
  46055. import { Scene, IDisposable } from "babylonjs/scene";
  46056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46057. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46058. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46059. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46060. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46061. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46062. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46063. /**
  46064. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46065. */
  46066. export class GizmoManager implements IDisposable {
  46067. private scene;
  46068. /**
  46069. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46070. */
  46071. gizmos: {
  46072. positionGizmo: Nullable<PositionGizmo>;
  46073. rotationGizmo: Nullable<RotationGizmo>;
  46074. scaleGizmo: Nullable<ScaleGizmo>;
  46075. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46076. };
  46077. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46078. clearGizmoOnEmptyPointerEvent: boolean;
  46079. /** Fires an event when the manager is attached to a mesh */
  46080. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46081. private _gizmosEnabled;
  46082. private _pointerObserver;
  46083. private _attachedMesh;
  46084. private _boundingBoxColor;
  46085. private _defaultUtilityLayer;
  46086. private _defaultKeepDepthUtilityLayer;
  46087. /**
  46088. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46089. */
  46090. boundingBoxDragBehavior: SixDofDragBehavior;
  46091. /**
  46092. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46093. */
  46094. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46095. /**
  46096. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46097. */
  46098. usePointerToAttachGizmos: boolean;
  46099. /**
  46100. * Utility layer that the bounding box gizmo belongs to
  46101. */
  46102. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46103. /**
  46104. * Utility layer that all gizmos besides bounding box belong to
  46105. */
  46106. readonly utilityLayer: UtilityLayerRenderer;
  46107. /**
  46108. * Instatiates a gizmo manager
  46109. * @param scene the scene to overlay the gizmos on top of
  46110. */
  46111. constructor(scene: Scene);
  46112. /**
  46113. * Attaches a set of gizmos to the specified mesh
  46114. * @param mesh The mesh the gizmo's should be attached to
  46115. */
  46116. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46117. /**
  46118. * If the position gizmo is enabled
  46119. */
  46120. positionGizmoEnabled: boolean;
  46121. /**
  46122. * If the rotation gizmo is enabled
  46123. */
  46124. rotationGizmoEnabled: boolean;
  46125. /**
  46126. * If the scale gizmo is enabled
  46127. */
  46128. scaleGizmoEnabled: boolean;
  46129. /**
  46130. * If the boundingBox gizmo is enabled
  46131. */
  46132. boundingBoxGizmoEnabled: boolean;
  46133. /**
  46134. * Disposes of the gizmo manager
  46135. */
  46136. dispose(): void;
  46137. }
  46138. }
  46139. declare module "babylonjs/Lights/directionalLight" {
  46140. import { Camera } from "babylonjs/Cameras/camera";
  46141. import { Scene } from "babylonjs/scene";
  46142. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46144. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46145. import { Effect } from "babylonjs/Materials/effect";
  46146. /**
  46147. * A directional light is defined by a direction (what a surprise!).
  46148. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46149. * 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.
  46150. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46151. */
  46152. export class DirectionalLight extends ShadowLight {
  46153. private _shadowFrustumSize;
  46154. /**
  46155. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46156. */
  46157. /**
  46158. * Specifies a fix frustum size for the shadow generation.
  46159. */
  46160. shadowFrustumSize: number;
  46161. private _shadowOrthoScale;
  46162. /**
  46163. * Gets the shadow projection scale against the optimal computed one.
  46164. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46165. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46166. */
  46167. /**
  46168. * Sets the shadow projection scale against the optimal computed one.
  46169. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46170. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46171. */
  46172. shadowOrthoScale: number;
  46173. /**
  46174. * Automatically compute the projection matrix to best fit (including all the casters)
  46175. * on each frame.
  46176. */
  46177. autoUpdateExtends: boolean;
  46178. private _orthoLeft;
  46179. private _orthoRight;
  46180. private _orthoTop;
  46181. private _orthoBottom;
  46182. /**
  46183. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46184. * The directional light is emitted from everywhere in the given direction.
  46185. * It can cast shadows.
  46186. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46187. * @param name The friendly name of the light
  46188. * @param direction The direction of the light
  46189. * @param scene The scene the light belongs to
  46190. */
  46191. constructor(name: string, direction: Vector3, scene: Scene);
  46192. /**
  46193. * Returns the string "DirectionalLight".
  46194. * @return The class name
  46195. */
  46196. getClassName(): string;
  46197. /**
  46198. * Returns the integer 1.
  46199. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46200. */
  46201. getTypeID(): number;
  46202. /**
  46203. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46204. * Returns the DirectionalLight Shadow projection matrix.
  46205. */
  46206. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46207. /**
  46208. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46209. * Returns the DirectionalLight Shadow projection matrix.
  46210. */
  46211. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46212. /**
  46213. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46214. * Returns the DirectionalLight Shadow projection matrix.
  46215. */
  46216. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46217. protected _buildUniformLayout(): void;
  46218. /**
  46219. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46220. * @param effect The effect to update
  46221. * @param lightIndex The index of the light in the effect to update
  46222. * @returns The directional light
  46223. */
  46224. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46225. /**
  46226. * Gets the minZ used for shadow according to both the scene and the light.
  46227. *
  46228. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46229. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46230. * @param activeCamera The camera we are returning the min for
  46231. * @returns the depth min z
  46232. */
  46233. getDepthMinZ(activeCamera: Camera): number;
  46234. /**
  46235. * Gets the maxZ used for shadow according to both the scene and the light.
  46236. *
  46237. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46238. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46239. * @param activeCamera The camera we are returning the max for
  46240. * @returns the depth max z
  46241. */
  46242. getDepthMaxZ(activeCamera: Camera): number;
  46243. /**
  46244. * Prepares the list of defines specific to the light type.
  46245. * @param defines the list of defines
  46246. * @param lightIndex defines the index of the light for the effect
  46247. */
  46248. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46249. }
  46250. }
  46251. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46252. import { Mesh } from "babylonjs/Meshes/mesh";
  46253. /**
  46254. * Class containing static functions to help procedurally build meshes
  46255. */
  46256. export class HemisphereBuilder {
  46257. /**
  46258. * Creates a hemisphere mesh
  46259. * @param name defines the name of the mesh
  46260. * @param options defines the options used to create the mesh
  46261. * @param scene defines the hosting scene
  46262. * @returns the hemisphere mesh
  46263. */
  46264. static CreateHemisphere(name: string, options: {
  46265. segments?: number;
  46266. diameter?: number;
  46267. sideOrientation?: number;
  46268. }, scene: any): Mesh;
  46269. }
  46270. }
  46271. declare module "babylonjs/Lights/spotLight" {
  46272. import { Nullable } from "babylonjs/types";
  46273. import { Scene } from "babylonjs/scene";
  46274. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46276. import { Effect } from "babylonjs/Materials/effect";
  46277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46278. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46279. /**
  46280. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46281. * These values define a cone of light starting from the position, emitting toward the direction.
  46282. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46283. * and the exponent defines the speed of the decay of the light with distance (reach).
  46284. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46285. */
  46286. export class SpotLight extends ShadowLight {
  46287. private _angle;
  46288. private _innerAngle;
  46289. private _cosHalfAngle;
  46290. private _lightAngleScale;
  46291. private _lightAngleOffset;
  46292. /**
  46293. * Gets the cone angle of the spot light in Radians.
  46294. */
  46295. /**
  46296. * Sets the cone angle of the spot light in Radians.
  46297. */
  46298. angle: number;
  46299. /**
  46300. * Only used in gltf falloff mode, this defines the angle where
  46301. * the directional falloff will start before cutting at angle which could be seen
  46302. * as outer angle.
  46303. */
  46304. /**
  46305. * Only used in gltf falloff mode, this defines the angle where
  46306. * the directional falloff will start before cutting at angle which could be seen
  46307. * as outer angle.
  46308. */
  46309. innerAngle: number;
  46310. private _shadowAngleScale;
  46311. /**
  46312. * Allows scaling the angle of the light for shadow generation only.
  46313. */
  46314. /**
  46315. * Allows scaling the angle of the light for shadow generation only.
  46316. */
  46317. shadowAngleScale: number;
  46318. /**
  46319. * The light decay speed with the distance from the emission spot.
  46320. */
  46321. exponent: number;
  46322. private _projectionTextureMatrix;
  46323. /**
  46324. * Allows reading the projecton texture
  46325. */
  46326. readonly projectionTextureMatrix: Matrix;
  46327. protected _projectionTextureLightNear: number;
  46328. /**
  46329. * Gets the near clip of the Spotlight for texture projection.
  46330. */
  46331. /**
  46332. * Sets the near clip of the Spotlight for texture projection.
  46333. */
  46334. projectionTextureLightNear: number;
  46335. protected _projectionTextureLightFar: number;
  46336. /**
  46337. * Gets the far clip of the Spotlight for texture projection.
  46338. */
  46339. /**
  46340. * Sets the far clip of the Spotlight for texture projection.
  46341. */
  46342. projectionTextureLightFar: number;
  46343. protected _projectionTextureUpDirection: Vector3;
  46344. /**
  46345. * Gets the Up vector of the Spotlight for texture projection.
  46346. */
  46347. /**
  46348. * Sets the Up vector of the Spotlight for texture projection.
  46349. */
  46350. projectionTextureUpDirection: Vector3;
  46351. private _projectionTexture;
  46352. /**
  46353. * Gets the projection texture of the light.
  46354. */
  46355. /**
  46356. * Sets the projection texture of the light.
  46357. */
  46358. projectionTexture: Nullable<BaseTexture>;
  46359. private _projectionTextureViewLightDirty;
  46360. private _projectionTextureProjectionLightDirty;
  46361. private _projectionTextureDirty;
  46362. private _projectionTextureViewTargetVector;
  46363. private _projectionTextureViewLightMatrix;
  46364. private _projectionTextureProjectionLightMatrix;
  46365. private _projectionTextureScalingMatrix;
  46366. /**
  46367. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46368. * It can cast shadows.
  46369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46370. * @param name The light friendly name
  46371. * @param position The position of the spot light in the scene
  46372. * @param direction The direction of the light in the scene
  46373. * @param angle The cone angle of the light in Radians
  46374. * @param exponent The light decay speed with the distance from the emission spot
  46375. * @param scene The scene the lights belongs to
  46376. */
  46377. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46378. /**
  46379. * Returns the string "SpotLight".
  46380. * @returns the class name
  46381. */
  46382. getClassName(): string;
  46383. /**
  46384. * Returns the integer 2.
  46385. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46386. */
  46387. getTypeID(): number;
  46388. /**
  46389. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46390. */
  46391. protected _setDirection(value: Vector3): void;
  46392. /**
  46393. * Overrides the position setter to recompute the projection texture view light Matrix.
  46394. */
  46395. protected _setPosition(value: Vector3): void;
  46396. /**
  46397. * 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.
  46398. * Returns the SpotLight.
  46399. */
  46400. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46401. protected _computeProjectionTextureViewLightMatrix(): void;
  46402. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46403. /**
  46404. * Main function for light texture projection matrix computing.
  46405. */
  46406. protected _computeProjectionTextureMatrix(): void;
  46407. protected _buildUniformLayout(): void;
  46408. private _computeAngleValues;
  46409. /**
  46410. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46411. * @param effect The effect to update
  46412. * @param lightIndex The index of the light in the effect to update
  46413. * @returns The spot light
  46414. */
  46415. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46416. /**
  46417. * Disposes the light and the associated resources.
  46418. */
  46419. dispose(): void;
  46420. /**
  46421. * Prepares the list of defines specific to the light type.
  46422. * @param defines the list of defines
  46423. * @param lightIndex defines the index of the light for the effect
  46424. */
  46425. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46426. }
  46427. }
  46428. declare module "babylonjs/Gizmos/lightGizmo" {
  46429. import { Nullable } from "babylonjs/types";
  46430. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46431. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46432. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46433. import { Light } from "babylonjs/Lights/light";
  46434. /**
  46435. * Gizmo that enables viewing a light
  46436. */
  46437. export class LightGizmo extends Gizmo {
  46438. private _lightMesh;
  46439. private _material;
  46440. private cachedPosition;
  46441. private cachedForward;
  46442. /**
  46443. * Creates a LightGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. */
  46446. constructor(gizmoLayer?: UtilityLayerRenderer);
  46447. private _light;
  46448. /**
  46449. * The light that the gizmo is attached to
  46450. */
  46451. light: Nullable<Light>;
  46452. /**
  46453. * Gets the material used to render the light gizmo
  46454. */
  46455. readonly material: StandardMaterial;
  46456. /**
  46457. * @hidden
  46458. * Updates the gizmo to match the attached mesh's position/rotation
  46459. */
  46460. protected _update(): void;
  46461. private static _Scale;
  46462. /**
  46463. * Creates the lines for a light mesh
  46464. */
  46465. private static _createLightLines;
  46466. /**
  46467. * Disposes of the light gizmo
  46468. */
  46469. dispose(): void;
  46470. private static _CreateHemisphericLightMesh;
  46471. private static _CreatePointLightMesh;
  46472. private static _CreateSpotLightMesh;
  46473. private static _CreateDirectionalLightMesh;
  46474. }
  46475. }
  46476. declare module "babylonjs/Gizmos/index" {
  46477. export * from "babylonjs/Gizmos/axisDragGizmo";
  46478. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46479. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46480. export * from "babylonjs/Gizmos/gizmo";
  46481. export * from "babylonjs/Gizmos/gizmoManager";
  46482. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46483. export * from "babylonjs/Gizmos/positionGizmo";
  46484. export * from "babylonjs/Gizmos/rotationGizmo";
  46485. export * from "babylonjs/Gizmos/scaleGizmo";
  46486. export * from "babylonjs/Gizmos/lightGizmo";
  46487. export * from "babylonjs/Gizmos/planeDragGizmo";
  46488. }
  46489. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46490. /** @hidden */
  46491. export var backgroundFragmentDeclaration: {
  46492. name: string;
  46493. shader: string;
  46494. };
  46495. }
  46496. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46497. /** @hidden */
  46498. export var backgroundUboDeclaration: {
  46499. name: string;
  46500. shader: string;
  46501. };
  46502. }
  46503. declare module "babylonjs/Shaders/background.fragment" {
  46504. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46505. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46506. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46507. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46508. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46509. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46511. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46512. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46513. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46514. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46515. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46516. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46517. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46518. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46519. /** @hidden */
  46520. export var backgroundPixelShader: {
  46521. name: string;
  46522. shader: string;
  46523. };
  46524. }
  46525. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46526. /** @hidden */
  46527. export var backgroundVertexDeclaration: {
  46528. name: string;
  46529. shader: string;
  46530. };
  46531. }
  46532. declare module "babylonjs/Shaders/background.vertex" {
  46533. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46534. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46535. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46536. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46537. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46538. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46540. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46541. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46542. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46543. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46544. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46545. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46546. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46547. /** @hidden */
  46548. export var backgroundVertexShader: {
  46549. name: string;
  46550. shader: string;
  46551. };
  46552. }
  46553. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46554. import { Nullable, int, float } from "babylonjs/types";
  46555. import { Scene } from "babylonjs/scene";
  46556. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46559. import { Mesh } from "babylonjs/Meshes/mesh";
  46560. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46561. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46562. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46564. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46565. import { Color3 } from "babylonjs/Maths/math.color";
  46566. import "babylonjs/Shaders/background.fragment";
  46567. import "babylonjs/Shaders/background.vertex";
  46568. /**
  46569. * Background material used to create an efficient environement around your scene.
  46570. */
  46571. export class BackgroundMaterial extends PushMaterial {
  46572. /**
  46573. * Standard reflectance value at parallel view angle.
  46574. */
  46575. static StandardReflectance0: number;
  46576. /**
  46577. * Standard reflectance value at grazing angle.
  46578. */
  46579. static StandardReflectance90: number;
  46580. protected _primaryColor: Color3;
  46581. /**
  46582. * Key light Color (multiply against the environement texture)
  46583. */
  46584. primaryColor: Color3;
  46585. protected __perceptualColor: Nullable<Color3>;
  46586. /**
  46587. * Experimental Internal Use Only.
  46588. *
  46589. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46590. * This acts as a helper to set the primary color to a more "human friendly" value.
  46591. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46592. * output color as close as possible from the chosen value.
  46593. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46594. * part of lighting setup.)
  46595. */
  46596. _perceptualColor: Nullable<Color3>;
  46597. protected _primaryColorShadowLevel: float;
  46598. /**
  46599. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46600. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46601. */
  46602. primaryColorShadowLevel: float;
  46603. protected _primaryColorHighlightLevel: float;
  46604. /**
  46605. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46606. * The primary color is used at the level chosen to define what the white area would look.
  46607. */
  46608. primaryColorHighlightLevel: float;
  46609. protected _reflectionTexture: Nullable<BaseTexture>;
  46610. /**
  46611. * Reflection Texture used in the material.
  46612. * Should be author in a specific way for the best result (refer to the documentation).
  46613. */
  46614. reflectionTexture: Nullable<BaseTexture>;
  46615. protected _reflectionBlur: float;
  46616. /**
  46617. * Reflection Texture level of blur.
  46618. *
  46619. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46620. * texture twice.
  46621. */
  46622. reflectionBlur: float;
  46623. protected _diffuseTexture: Nullable<BaseTexture>;
  46624. /**
  46625. * Diffuse Texture used in the material.
  46626. * Should be author in a specific way for the best result (refer to the documentation).
  46627. */
  46628. diffuseTexture: Nullable<BaseTexture>;
  46629. protected _shadowLights: Nullable<IShadowLight[]>;
  46630. /**
  46631. * Specify the list of lights casting shadow on the material.
  46632. * All scene shadow lights will be included if null.
  46633. */
  46634. shadowLights: Nullable<IShadowLight[]>;
  46635. protected _shadowLevel: float;
  46636. /**
  46637. * Helps adjusting the shadow to a softer level if required.
  46638. * 0 means black shadows and 1 means no shadows.
  46639. */
  46640. shadowLevel: float;
  46641. protected _sceneCenter: Vector3;
  46642. /**
  46643. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46644. * It is usually zero but might be interesting to modify according to your setup.
  46645. */
  46646. sceneCenter: Vector3;
  46647. protected _opacityFresnel: boolean;
  46648. /**
  46649. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46650. * This helps ensuring a nice transition when the camera goes under the ground.
  46651. */
  46652. opacityFresnel: boolean;
  46653. protected _reflectionFresnel: boolean;
  46654. /**
  46655. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46656. * This helps adding a mirror texture on the ground.
  46657. */
  46658. reflectionFresnel: boolean;
  46659. protected _reflectionFalloffDistance: number;
  46660. /**
  46661. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46662. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46663. */
  46664. reflectionFalloffDistance: number;
  46665. protected _reflectionAmount: number;
  46666. /**
  46667. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46668. */
  46669. reflectionAmount: number;
  46670. protected _reflectionReflectance0: number;
  46671. /**
  46672. * This specifies the weight of the reflection at grazing angle.
  46673. */
  46674. reflectionReflectance0: number;
  46675. protected _reflectionReflectance90: number;
  46676. /**
  46677. * This specifies the weight of the reflection at a perpendicular point of view.
  46678. */
  46679. reflectionReflectance90: number;
  46680. /**
  46681. * Sets the reflection reflectance fresnel values according to the default standard
  46682. * empirically know to work well :-)
  46683. */
  46684. reflectionStandardFresnelWeight: number;
  46685. protected _useRGBColor: boolean;
  46686. /**
  46687. * Helps to directly use the maps channels instead of their level.
  46688. */
  46689. useRGBColor: boolean;
  46690. protected _enableNoise: boolean;
  46691. /**
  46692. * This helps reducing the banding effect that could occur on the background.
  46693. */
  46694. enableNoise: boolean;
  46695. /**
  46696. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46697. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46698. * Recommended to be keep at 1.0 except for special cases.
  46699. */
  46700. fovMultiplier: number;
  46701. private _fovMultiplier;
  46702. /**
  46703. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46704. */
  46705. useEquirectangularFOV: boolean;
  46706. private _maxSimultaneousLights;
  46707. /**
  46708. * Number of Simultaneous lights allowed on the material.
  46709. */
  46710. maxSimultaneousLights: int;
  46711. /**
  46712. * Default configuration related to image processing available in the Background Material.
  46713. */
  46714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46715. /**
  46716. * Keep track of the image processing observer to allow dispose and replace.
  46717. */
  46718. private _imageProcessingObserver;
  46719. /**
  46720. * Attaches a new image processing configuration to the PBR Material.
  46721. * @param configuration (if null the scene configuration will be use)
  46722. */
  46723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46724. /**
  46725. * Gets the image processing configuration used either in this material.
  46726. */
  46727. /**
  46728. * Sets the Default image processing configuration used either in the this material.
  46729. *
  46730. * If sets to null, the scene one is in use.
  46731. */
  46732. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46733. /**
  46734. * Gets wether the color curves effect is enabled.
  46735. */
  46736. /**
  46737. * Sets wether the color curves effect is enabled.
  46738. */
  46739. cameraColorCurvesEnabled: boolean;
  46740. /**
  46741. * Gets wether the color grading effect is enabled.
  46742. */
  46743. /**
  46744. * Gets wether the color grading effect is enabled.
  46745. */
  46746. cameraColorGradingEnabled: boolean;
  46747. /**
  46748. * Gets wether tonemapping is enabled or not.
  46749. */
  46750. /**
  46751. * Sets wether tonemapping is enabled or not
  46752. */
  46753. cameraToneMappingEnabled: boolean;
  46754. /**
  46755. * The camera exposure used on this material.
  46756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46757. * This corresponds to a photographic exposure.
  46758. */
  46759. /**
  46760. * The camera exposure used on this material.
  46761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46762. * This corresponds to a photographic exposure.
  46763. */
  46764. cameraExposure: float;
  46765. /**
  46766. * Gets The camera contrast used on this material.
  46767. */
  46768. /**
  46769. * Sets The camera contrast used on this material.
  46770. */
  46771. cameraContrast: float;
  46772. /**
  46773. * Gets the Color Grading 2D Lookup Texture.
  46774. */
  46775. /**
  46776. * Sets the Color Grading 2D Lookup Texture.
  46777. */
  46778. cameraColorGradingTexture: Nullable<BaseTexture>;
  46779. /**
  46780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46782. * 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;
  46783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46784. */
  46785. /**
  46786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46788. * 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;
  46789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46790. */
  46791. cameraColorCurves: Nullable<ColorCurves>;
  46792. /**
  46793. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46794. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46795. */
  46796. switchToBGR: boolean;
  46797. private _renderTargets;
  46798. private _reflectionControls;
  46799. private _white;
  46800. private _primaryShadowColor;
  46801. private _primaryHighlightColor;
  46802. /**
  46803. * Instantiates a Background Material in the given scene
  46804. * @param name The friendly name of the material
  46805. * @param scene The scene to add the material to
  46806. */
  46807. constructor(name: string, scene: Scene);
  46808. /**
  46809. * Gets a boolean indicating that current material needs to register RTT
  46810. */
  46811. readonly hasRenderTargetTextures: boolean;
  46812. /**
  46813. * The entire material has been created in order to prevent overdraw.
  46814. * @returns false
  46815. */
  46816. needAlphaTesting(): boolean;
  46817. /**
  46818. * The entire material has been created in order to prevent overdraw.
  46819. * @returns true if blending is enable
  46820. */
  46821. needAlphaBlending(): boolean;
  46822. /**
  46823. * Checks wether the material is ready to be rendered for a given mesh.
  46824. * @param mesh The mesh to render
  46825. * @param subMesh The submesh to check against
  46826. * @param useInstances Specify wether or not the material is used with instances
  46827. * @returns true if all the dependencies are ready (Textures, Effects...)
  46828. */
  46829. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46830. /**
  46831. * Compute the primary color according to the chosen perceptual color.
  46832. */
  46833. private _computePrimaryColorFromPerceptualColor;
  46834. /**
  46835. * Compute the highlights and shadow colors according to their chosen levels.
  46836. */
  46837. private _computePrimaryColors;
  46838. /**
  46839. * Build the uniform buffer used in the material.
  46840. */
  46841. buildUniformLayout(): void;
  46842. /**
  46843. * Unbind the material.
  46844. */
  46845. unbind(): void;
  46846. /**
  46847. * Bind only the world matrix to the material.
  46848. * @param world The world matrix to bind.
  46849. */
  46850. bindOnlyWorldMatrix(world: Matrix): void;
  46851. /**
  46852. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46853. * @param world The world matrix to bind.
  46854. * @param subMesh The submesh to bind for.
  46855. */
  46856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46857. /**
  46858. * Dispose the material.
  46859. * @param forceDisposeEffect Force disposal of the associated effect.
  46860. * @param forceDisposeTextures Force disposal of the associated textures.
  46861. */
  46862. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46863. /**
  46864. * Clones the material.
  46865. * @param name The cloned name.
  46866. * @returns The cloned material.
  46867. */
  46868. clone(name: string): BackgroundMaterial;
  46869. /**
  46870. * Serializes the current material to its JSON representation.
  46871. * @returns The JSON representation.
  46872. */
  46873. serialize(): any;
  46874. /**
  46875. * Gets the class name of the material
  46876. * @returns "BackgroundMaterial"
  46877. */
  46878. getClassName(): string;
  46879. /**
  46880. * Parse a JSON input to create back a background material.
  46881. * @param source The JSON data to parse
  46882. * @param scene The scene to create the parsed material in
  46883. * @param rootUrl The root url of the assets the material depends upon
  46884. * @returns the instantiated BackgroundMaterial.
  46885. */
  46886. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46887. }
  46888. }
  46889. declare module "babylonjs/Helpers/environmentHelper" {
  46890. import { Observable } from "babylonjs/Misc/observable";
  46891. import { Nullable } from "babylonjs/types";
  46892. import { Scene } from "babylonjs/scene";
  46893. import { Vector3 } from "babylonjs/Maths/math.vector";
  46894. import { Color3 } from "babylonjs/Maths/math.color";
  46895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46896. import { Mesh } from "babylonjs/Meshes/mesh";
  46897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46898. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46899. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46900. import "babylonjs/Meshes/Builders/planeBuilder";
  46901. import "babylonjs/Meshes/Builders/boxBuilder";
  46902. /**
  46903. * Represents the different options available during the creation of
  46904. * a Environment helper.
  46905. *
  46906. * This can control the default ground, skybox and image processing setup of your scene.
  46907. */
  46908. export interface IEnvironmentHelperOptions {
  46909. /**
  46910. * Specifies wether or not to create a ground.
  46911. * True by default.
  46912. */
  46913. createGround: boolean;
  46914. /**
  46915. * Specifies the ground size.
  46916. * 15 by default.
  46917. */
  46918. groundSize: number;
  46919. /**
  46920. * The texture used on the ground for the main color.
  46921. * Comes from the BabylonJS CDN by default.
  46922. *
  46923. * Remarks: Can be either a texture or a url.
  46924. */
  46925. groundTexture: string | BaseTexture;
  46926. /**
  46927. * The color mixed in the ground texture by default.
  46928. * BabylonJS clearColor by default.
  46929. */
  46930. groundColor: Color3;
  46931. /**
  46932. * Specifies the ground opacity.
  46933. * 1 by default.
  46934. */
  46935. groundOpacity: number;
  46936. /**
  46937. * Enables the ground to receive shadows.
  46938. * True by default.
  46939. */
  46940. enableGroundShadow: boolean;
  46941. /**
  46942. * Helps preventing the shadow to be fully black on the ground.
  46943. * 0.5 by default.
  46944. */
  46945. groundShadowLevel: number;
  46946. /**
  46947. * Creates a mirror texture attach to the ground.
  46948. * false by default.
  46949. */
  46950. enableGroundMirror: boolean;
  46951. /**
  46952. * Specifies the ground mirror size ratio.
  46953. * 0.3 by default as the default kernel is 64.
  46954. */
  46955. groundMirrorSizeRatio: number;
  46956. /**
  46957. * Specifies the ground mirror blur kernel size.
  46958. * 64 by default.
  46959. */
  46960. groundMirrorBlurKernel: number;
  46961. /**
  46962. * Specifies the ground mirror visibility amount.
  46963. * 1 by default
  46964. */
  46965. groundMirrorAmount: number;
  46966. /**
  46967. * Specifies the ground mirror reflectance weight.
  46968. * This uses the standard weight of the background material to setup the fresnel effect
  46969. * of the mirror.
  46970. * 1 by default.
  46971. */
  46972. groundMirrorFresnelWeight: number;
  46973. /**
  46974. * Specifies the ground mirror Falloff distance.
  46975. * This can helps reducing the size of the reflection.
  46976. * 0 by Default.
  46977. */
  46978. groundMirrorFallOffDistance: number;
  46979. /**
  46980. * Specifies the ground mirror texture type.
  46981. * Unsigned Int by Default.
  46982. */
  46983. groundMirrorTextureType: number;
  46984. /**
  46985. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46986. * the shown objects.
  46987. */
  46988. groundYBias: number;
  46989. /**
  46990. * Specifies wether or not to create a skybox.
  46991. * True by default.
  46992. */
  46993. createSkybox: boolean;
  46994. /**
  46995. * Specifies the skybox size.
  46996. * 20 by default.
  46997. */
  46998. skyboxSize: number;
  46999. /**
  47000. * The texture used on the skybox for the main color.
  47001. * Comes from the BabylonJS CDN by default.
  47002. *
  47003. * Remarks: Can be either a texture or a url.
  47004. */
  47005. skyboxTexture: string | BaseTexture;
  47006. /**
  47007. * The color mixed in the skybox texture by default.
  47008. * BabylonJS clearColor by default.
  47009. */
  47010. skyboxColor: Color3;
  47011. /**
  47012. * The background rotation around the Y axis of the scene.
  47013. * This helps aligning the key lights of your scene with the background.
  47014. * 0 by default.
  47015. */
  47016. backgroundYRotation: number;
  47017. /**
  47018. * Compute automatically the size of the elements to best fit with the scene.
  47019. */
  47020. sizeAuto: boolean;
  47021. /**
  47022. * Default position of the rootMesh if autoSize is not true.
  47023. */
  47024. rootPosition: Vector3;
  47025. /**
  47026. * Sets up the image processing in the scene.
  47027. * true by default.
  47028. */
  47029. setupImageProcessing: boolean;
  47030. /**
  47031. * The texture used as your environment texture in the scene.
  47032. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47033. *
  47034. * Remarks: Can be either a texture or a url.
  47035. */
  47036. environmentTexture: string | BaseTexture;
  47037. /**
  47038. * The value of the exposure to apply to the scene.
  47039. * 0.6 by default if setupImageProcessing is true.
  47040. */
  47041. cameraExposure: number;
  47042. /**
  47043. * The value of the contrast to apply to the scene.
  47044. * 1.6 by default if setupImageProcessing is true.
  47045. */
  47046. cameraContrast: number;
  47047. /**
  47048. * Specifies wether or not tonemapping should be enabled in the scene.
  47049. * true by default if setupImageProcessing is true.
  47050. */
  47051. toneMappingEnabled: boolean;
  47052. }
  47053. /**
  47054. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47055. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47056. * It also helps with the default setup of your imageProcessing configuration.
  47057. */
  47058. export class EnvironmentHelper {
  47059. /**
  47060. * Default ground texture URL.
  47061. */
  47062. private static _groundTextureCDNUrl;
  47063. /**
  47064. * Default skybox texture URL.
  47065. */
  47066. private static _skyboxTextureCDNUrl;
  47067. /**
  47068. * Default environment texture URL.
  47069. */
  47070. private static _environmentTextureCDNUrl;
  47071. /**
  47072. * Creates the default options for the helper.
  47073. */
  47074. private static _getDefaultOptions;
  47075. private _rootMesh;
  47076. /**
  47077. * Gets the root mesh created by the helper.
  47078. */
  47079. readonly rootMesh: Mesh;
  47080. private _skybox;
  47081. /**
  47082. * Gets the skybox created by the helper.
  47083. */
  47084. readonly skybox: Nullable<Mesh>;
  47085. private _skyboxTexture;
  47086. /**
  47087. * Gets the skybox texture created by the helper.
  47088. */
  47089. readonly skyboxTexture: Nullable<BaseTexture>;
  47090. private _skyboxMaterial;
  47091. /**
  47092. * Gets the skybox material created by the helper.
  47093. */
  47094. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47095. private _ground;
  47096. /**
  47097. * Gets the ground mesh created by the helper.
  47098. */
  47099. readonly ground: Nullable<Mesh>;
  47100. private _groundTexture;
  47101. /**
  47102. * Gets the ground texture created by the helper.
  47103. */
  47104. readonly groundTexture: Nullable<BaseTexture>;
  47105. private _groundMirror;
  47106. /**
  47107. * Gets the ground mirror created by the helper.
  47108. */
  47109. readonly groundMirror: Nullable<MirrorTexture>;
  47110. /**
  47111. * Gets the ground mirror render list to helps pushing the meshes
  47112. * you wish in the ground reflection.
  47113. */
  47114. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47115. private _groundMaterial;
  47116. /**
  47117. * Gets the ground material created by the helper.
  47118. */
  47119. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47120. /**
  47121. * Stores the creation options.
  47122. */
  47123. private readonly _scene;
  47124. private _options;
  47125. /**
  47126. * This observable will be notified with any error during the creation of the environment,
  47127. * mainly texture creation errors.
  47128. */
  47129. onErrorObservable: Observable<{
  47130. message?: string;
  47131. exception?: any;
  47132. }>;
  47133. /**
  47134. * constructor
  47135. * @param options Defines the options we want to customize the helper
  47136. * @param scene The scene to add the material to
  47137. */
  47138. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47139. /**
  47140. * Updates the background according to the new options
  47141. * @param options
  47142. */
  47143. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47144. /**
  47145. * Sets the primary color of all the available elements.
  47146. * @param color the main color to affect to the ground and the background
  47147. */
  47148. setMainColor(color: Color3): void;
  47149. /**
  47150. * Setup the image processing according to the specified options.
  47151. */
  47152. private _setupImageProcessing;
  47153. /**
  47154. * Setup the environment texture according to the specified options.
  47155. */
  47156. private _setupEnvironmentTexture;
  47157. /**
  47158. * Setup the background according to the specified options.
  47159. */
  47160. private _setupBackground;
  47161. /**
  47162. * Get the scene sizes according to the setup.
  47163. */
  47164. private _getSceneSize;
  47165. /**
  47166. * Setup the ground according to the specified options.
  47167. */
  47168. private _setupGround;
  47169. /**
  47170. * Setup the ground material according to the specified options.
  47171. */
  47172. private _setupGroundMaterial;
  47173. /**
  47174. * Setup the ground diffuse texture according to the specified options.
  47175. */
  47176. private _setupGroundDiffuseTexture;
  47177. /**
  47178. * Setup the ground mirror texture according to the specified options.
  47179. */
  47180. private _setupGroundMirrorTexture;
  47181. /**
  47182. * Setup the ground to receive the mirror texture.
  47183. */
  47184. private _setupMirrorInGroundMaterial;
  47185. /**
  47186. * Setup the skybox according to the specified options.
  47187. */
  47188. private _setupSkybox;
  47189. /**
  47190. * Setup the skybox material according to the specified options.
  47191. */
  47192. private _setupSkyboxMaterial;
  47193. /**
  47194. * Setup the skybox reflection texture according to the specified options.
  47195. */
  47196. private _setupSkyboxReflectionTexture;
  47197. private _errorHandler;
  47198. /**
  47199. * Dispose all the elements created by the Helper.
  47200. */
  47201. dispose(): void;
  47202. }
  47203. }
  47204. declare module "babylonjs/Helpers/photoDome" {
  47205. import { Observable } from "babylonjs/Misc/observable";
  47206. import { Nullable } from "babylonjs/types";
  47207. import { Scene } from "babylonjs/scene";
  47208. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47209. import { Mesh } from "babylonjs/Meshes/mesh";
  47210. import { Texture } from "babylonjs/Materials/Textures/texture";
  47211. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47212. import "babylonjs/Meshes/Builders/sphereBuilder";
  47213. /**
  47214. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47215. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47216. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47217. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47218. */
  47219. export class PhotoDome extends TransformNode {
  47220. /**
  47221. * Define the image as a Monoscopic panoramic 360 image.
  47222. */
  47223. static readonly MODE_MONOSCOPIC: number;
  47224. /**
  47225. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47226. */
  47227. static readonly MODE_TOPBOTTOM: number;
  47228. /**
  47229. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47230. */
  47231. static readonly MODE_SIDEBYSIDE: number;
  47232. private _useDirectMapping;
  47233. /**
  47234. * The texture being displayed on the sphere
  47235. */
  47236. protected _photoTexture: Texture;
  47237. /**
  47238. * Gets or sets the texture being displayed on the sphere
  47239. */
  47240. photoTexture: Texture;
  47241. /**
  47242. * Observable raised when an error occured while loading the 360 image
  47243. */
  47244. onLoadErrorObservable: Observable<string>;
  47245. /**
  47246. * The skybox material
  47247. */
  47248. protected _material: BackgroundMaterial;
  47249. /**
  47250. * The surface used for the skybox
  47251. */
  47252. protected _mesh: Mesh;
  47253. /**
  47254. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47255. * Also see the options.resolution property.
  47256. */
  47257. fovMultiplier: number;
  47258. private _imageMode;
  47259. /**
  47260. * Gets or set the current video mode for the video. It can be:
  47261. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47262. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47263. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47264. */
  47265. imageMode: number;
  47266. /**
  47267. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47268. * @param name Element's name, child elements will append suffixes for their own names.
  47269. * @param urlsOfPhoto defines the url of the photo to display
  47270. * @param options defines an object containing optional or exposed sub element properties
  47271. * @param onError defines a callback called when an error occured while loading the texture
  47272. */
  47273. constructor(name: string, urlOfPhoto: string, options: {
  47274. resolution?: number;
  47275. size?: number;
  47276. useDirectMapping?: boolean;
  47277. faceForward?: boolean;
  47278. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47279. private _onBeforeCameraRenderObserver;
  47280. private _changeImageMode;
  47281. /**
  47282. * Releases resources associated with this node.
  47283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47285. */
  47286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47287. }
  47288. }
  47289. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47290. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47291. /** @hidden */
  47292. export var rgbdDecodePixelShader: {
  47293. name: string;
  47294. shader: string;
  47295. };
  47296. }
  47297. declare module "babylonjs/Misc/brdfTextureTools" {
  47298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47299. import { Scene } from "babylonjs/scene";
  47300. import "babylonjs/Shaders/rgbdDecode.fragment";
  47301. /**
  47302. * Class used to host texture specific utilities
  47303. */
  47304. export class BRDFTextureTools {
  47305. /**
  47306. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47307. * @param texture the texture to expand.
  47308. */
  47309. private static _ExpandDefaultBRDFTexture;
  47310. /**
  47311. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47312. * @param scene defines the hosting scene
  47313. * @returns the environment BRDF texture
  47314. */
  47315. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47316. private static _environmentBRDFBase64Texture;
  47317. }
  47318. }
  47319. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47320. import { Nullable } from "babylonjs/types";
  47321. import { Color3 } from "babylonjs/Maths/math.color";
  47322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47323. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47324. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47325. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47326. import { Engine } from "babylonjs/Engines/engine";
  47327. import { Scene } from "babylonjs/scene";
  47328. /**
  47329. * @hidden
  47330. */
  47331. export interface IMaterialClearCoatDefines {
  47332. CLEARCOAT: boolean;
  47333. CLEARCOAT_DEFAULTIOR: boolean;
  47334. CLEARCOAT_TEXTURE: boolean;
  47335. CLEARCOAT_TEXTUREDIRECTUV: number;
  47336. CLEARCOAT_BUMP: boolean;
  47337. CLEARCOAT_BUMPDIRECTUV: number;
  47338. CLEARCOAT_TINT: boolean;
  47339. CLEARCOAT_TINT_TEXTURE: boolean;
  47340. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47341. /** @hidden */
  47342. _areTexturesDirty: boolean;
  47343. }
  47344. /**
  47345. * Define the code related to the clear coat parameters of the pbr material.
  47346. */
  47347. export class PBRClearCoatConfiguration {
  47348. /**
  47349. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47350. * The default fits with a polyurethane material.
  47351. */
  47352. private static readonly _DefaultIndexOfRefraction;
  47353. private _isEnabled;
  47354. /**
  47355. * Defines if the clear coat is enabled in the material.
  47356. */
  47357. isEnabled: boolean;
  47358. /**
  47359. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47360. */
  47361. intensity: number;
  47362. /**
  47363. * Defines the clear coat layer roughness.
  47364. */
  47365. roughness: number;
  47366. private _indexOfRefraction;
  47367. /**
  47368. * Defines the index of refraction of the clear coat.
  47369. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47370. * The default fits with a polyurethane material.
  47371. * Changing the default value is more performance intensive.
  47372. */
  47373. indexOfRefraction: number;
  47374. private _texture;
  47375. /**
  47376. * Stores the clear coat values in a texture.
  47377. */
  47378. texture: Nullable<BaseTexture>;
  47379. private _bumpTexture;
  47380. /**
  47381. * Define the clear coat specific bump texture.
  47382. */
  47383. bumpTexture: Nullable<BaseTexture>;
  47384. private _isTintEnabled;
  47385. /**
  47386. * Defines if the clear coat tint is enabled in the material.
  47387. */
  47388. isTintEnabled: boolean;
  47389. /**
  47390. * Defines the clear coat tint of the material.
  47391. * This is only use if tint is enabled
  47392. */
  47393. tintColor: Color3;
  47394. /**
  47395. * Defines the distance at which the tint color should be found in the
  47396. * clear coat media.
  47397. * This is only use if tint is enabled
  47398. */
  47399. tintColorAtDistance: number;
  47400. /**
  47401. * Defines the clear coat layer thickness.
  47402. * This is only use if tint is enabled
  47403. */
  47404. tintThickness: number;
  47405. private _tintTexture;
  47406. /**
  47407. * Stores the clear tint values in a texture.
  47408. * rgb is tint
  47409. * a is a thickness factor
  47410. */
  47411. tintTexture: Nullable<BaseTexture>;
  47412. /** @hidden */
  47413. private _internalMarkAllSubMeshesAsTexturesDirty;
  47414. /** @hidden */
  47415. _markAllSubMeshesAsTexturesDirty(): void;
  47416. /**
  47417. * Instantiate a new istance of clear coat configuration.
  47418. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47419. */
  47420. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47421. /**
  47422. * Gets wehter the submesh is ready to be used or not.
  47423. * @param defines the list of "defines" to update.
  47424. * @param scene defines the scene the material belongs to.
  47425. * @param engine defines the engine the material belongs to.
  47426. * @param disableBumpMap defines wether the material disables bump or not.
  47427. * @returns - boolean indicating that the submesh is ready or not.
  47428. */
  47429. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47430. /**
  47431. * Checks to see if a texture is used in the material.
  47432. * @param defines the list of "defines" to update.
  47433. * @param scene defines the scene to the material belongs to.
  47434. */
  47435. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47436. /**
  47437. * Binds the material data.
  47438. * @param uniformBuffer defines the Uniform buffer to fill in.
  47439. * @param scene defines the scene the material belongs to.
  47440. * @param engine defines the engine the material belongs to.
  47441. * @param disableBumpMap defines wether the material disables bump or not.
  47442. * @param isFrozen defines wether the material is frozen or not.
  47443. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47444. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47445. */
  47446. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47447. /**
  47448. * Checks to see if a texture is used in the material.
  47449. * @param texture - Base texture to use.
  47450. * @returns - Boolean specifying if a texture is used in the material.
  47451. */
  47452. hasTexture(texture: BaseTexture): boolean;
  47453. /**
  47454. * Returns an array of the actively used textures.
  47455. * @param activeTextures Array of BaseTextures
  47456. */
  47457. getActiveTextures(activeTextures: BaseTexture[]): void;
  47458. /**
  47459. * Returns the animatable textures.
  47460. * @param animatables Array of animatable textures.
  47461. */
  47462. getAnimatables(animatables: IAnimatable[]): void;
  47463. /**
  47464. * Disposes the resources of the material.
  47465. * @param forceDisposeTextures - Forces the disposal of all textures.
  47466. */
  47467. dispose(forceDisposeTextures?: boolean): void;
  47468. /**
  47469. * Get the current class name of the texture useful for serialization or dynamic coding.
  47470. * @returns "PBRClearCoatConfiguration"
  47471. */
  47472. getClassName(): string;
  47473. /**
  47474. * Add fallbacks to the effect fallbacks list.
  47475. * @param defines defines the Base texture to use.
  47476. * @param fallbacks defines the current fallback list.
  47477. * @param currentRank defines the current fallback rank.
  47478. * @returns the new fallback rank.
  47479. */
  47480. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47481. /**
  47482. * Add the required uniforms to the current list.
  47483. * @param uniforms defines the current uniform list.
  47484. */
  47485. static AddUniforms(uniforms: string[]): void;
  47486. /**
  47487. * Add the required samplers to the current list.
  47488. * @param samplers defines the current sampler list.
  47489. */
  47490. static AddSamplers(samplers: string[]): void;
  47491. /**
  47492. * Add the required uniforms to the current buffer.
  47493. * @param uniformBuffer defines the current uniform buffer.
  47494. */
  47495. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47496. /**
  47497. * Makes a duplicate of the current configuration into another one.
  47498. * @param clearCoatConfiguration define the config where to copy the info
  47499. */
  47500. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47501. /**
  47502. * Serializes this clear coat configuration.
  47503. * @returns - An object with the serialized config.
  47504. */
  47505. serialize(): any;
  47506. /**
  47507. * Parses a anisotropy Configuration from a serialized object.
  47508. * @param source - Serialized object.
  47509. * @param scene Defines the scene we are parsing for
  47510. * @param rootUrl Defines the rootUrl to load from
  47511. */
  47512. parse(source: any, scene: Scene, rootUrl: string): void;
  47513. }
  47514. }
  47515. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47516. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47519. import { Vector2 } from "babylonjs/Maths/math.vector";
  47520. import { Scene } from "babylonjs/scene";
  47521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47522. import { Nullable } from "babylonjs/types";
  47523. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47524. /**
  47525. * @hidden
  47526. */
  47527. export interface IMaterialAnisotropicDefines {
  47528. ANISOTROPIC: boolean;
  47529. ANISOTROPIC_TEXTURE: boolean;
  47530. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47531. MAINUV1: boolean;
  47532. _areTexturesDirty: boolean;
  47533. _needUVs: boolean;
  47534. }
  47535. /**
  47536. * Define the code related to the anisotropic parameters of the pbr material.
  47537. */
  47538. export class PBRAnisotropicConfiguration {
  47539. private _isEnabled;
  47540. /**
  47541. * Defines if the anisotropy is enabled in the material.
  47542. */
  47543. isEnabled: boolean;
  47544. /**
  47545. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47546. */
  47547. intensity: number;
  47548. /**
  47549. * Defines if the effect is along the tangents, bitangents or in between.
  47550. * By default, the effect is "strectching" the highlights along the tangents.
  47551. */
  47552. direction: Vector2;
  47553. private _texture;
  47554. /**
  47555. * Stores the anisotropy values in a texture.
  47556. * rg is direction (like normal from -1 to 1)
  47557. * b is a intensity
  47558. */
  47559. texture: Nullable<BaseTexture>;
  47560. /** @hidden */
  47561. private _internalMarkAllSubMeshesAsTexturesDirty;
  47562. /** @hidden */
  47563. _markAllSubMeshesAsTexturesDirty(): void;
  47564. /**
  47565. * Instantiate a new istance of anisotropy configuration.
  47566. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47567. */
  47568. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47569. /**
  47570. * Specifies that the submesh is ready to be used.
  47571. * @param defines the list of "defines" to update.
  47572. * @param scene defines the scene the material belongs to.
  47573. * @returns - boolean indicating that the submesh is ready or not.
  47574. */
  47575. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47576. /**
  47577. * Checks to see if a texture is used in the material.
  47578. * @param defines the list of "defines" to update.
  47579. * @param mesh the mesh we are preparing the defines for.
  47580. * @param scene defines the scene the material belongs to.
  47581. */
  47582. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47583. /**
  47584. * Binds the material data.
  47585. * @param uniformBuffer defines the Uniform buffer to fill in.
  47586. * @param scene defines the scene the material belongs to.
  47587. * @param isFrozen defines wether the material is frozen or not.
  47588. */
  47589. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47590. /**
  47591. * Checks to see if a texture is used in the material.
  47592. * @param texture - Base texture to use.
  47593. * @returns - Boolean specifying if a texture is used in the material.
  47594. */
  47595. hasTexture(texture: BaseTexture): boolean;
  47596. /**
  47597. * Returns an array of the actively used textures.
  47598. * @param activeTextures Array of BaseTextures
  47599. */
  47600. getActiveTextures(activeTextures: BaseTexture[]): void;
  47601. /**
  47602. * Returns the animatable textures.
  47603. * @param animatables Array of animatable textures.
  47604. */
  47605. getAnimatables(animatables: IAnimatable[]): void;
  47606. /**
  47607. * Disposes the resources of the material.
  47608. * @param forceDisposeTextures - Forces the disposal of all textures.
  47609. */
  47610. dispose(forceDisposeTextures?: boolean): void;
  47611. /**
  47612. * Get the current class name of the texture useful for serialization or dynamic coding.
  47613. * @returns "PBRAnisotropicConfiguration"
  47614. */
  47615. getClassName(): string;
  47616. /**
  47617. * Add fallbacks to the effect fallbacks list.
  47618. * @param defines defines the Base texture to use.
  47619. * @param fallbacks defines the current fallback list.
  47620. * @param currentRank defines the current fallback rank.
  47621. * @returns the new fallback rank.
  47622. */
  47623. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47624. /**
  47625. * Add the required uniforms to the current list.
  47626. * @param uniforms defines the current uniform list.
  47627. */
  47628. static AddUniforms(uniforms: string[]): void;
  47629. /**
  47630. * Add the required uniforms to the current buffer.
  47631. * @param uniformBuffer defines the current uniform buffer.
  47632. */
  47633. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47634. /**
  47635. * Add the required samplers to the current list.
  47636. * @param samplers defines the current sampler list.
  47637. */
  47638. static AddSamplers(samplers: string[]): void;
  47639. /**
  47640. * Makes a duplicate of the current configuration into another one.
  47641. * @param anisotropicConfiguration define the config where to copy the info
  47642. */
  47643. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47644. /**
  47645. * Serializes this anisotropy configuration.
  47646. * @returns - An object with the serialized config.
  47647. */
  47648. serialize(): any;
  47649. /**
  47650. * Parses a anisotropy Configuration from a serialized object.
  47651. * @param source - Serialized object.
  47652. * @param scene Defines the scene we are parsing for
  47653. * @param rootUrl Defines the rootUrl to load from
  47654. */
  47655. parse(source: any, scene: Scene, rootUrl: string): void;
  47656. }
  47657. }
  47658. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47659. import { Scene } from "babylonjs/scene";
  47660. /**
  47661. * @hidden
  47662. */
  47663. export interface IMaterialBRDFDefines {
  47664. BRDF_V_HEIGHT_CORRELATED: boolean;
  47665. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47666. SPHERICAL_HARMONICS: boolean;
  47667. /** @hidden */
  47668. _areMiscDirty: boolean;
  47669. }
  47670. /**
  47671. * Define the code related to the BRDF parameters of the pbr material.
  47672. */
  47673. export class PBRBRDFConfiguration {
  47674. /**
  47675. * Default value used for the energy conservation.
  47676. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47677. */
  47678. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47679. /**
  47680. * Default value used for the Smith Visibility Height Correlated mode.
  47681. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47682. */
  47683. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47684. /**
  47685. * Default value used for the IBL diffuse part.
  47686. * This can help switching back to the polynomials mode globally which is a tiny bit
  47687. * less GPU intensive at the drawback of a lower quality.
  47688. */
  47689. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47690. private _useEnergyConservation;
  47691. /**
  47692. * Defines if the material uses energy conservation.
  47693. */
  47694. useEnergyConservation: boolean;
  47695. private _useSmithVisibilityHeightCorrelated;
  47696. /**
  47697. * LEGACY Mode set to false
  47698. * Defines if the material uses height smith correlated visibility term.
  47699. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47700. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47701. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47702. * Not relying on height correlated will also disable energy conservation.
  47703. */
  47704. useSmithVisibilityHeightCorrelated: boolean;
  47705. private _useSphericalHarmonics;
  47706. /**
  47707. * LEGACY Mode set to false
  47708. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47709. * diffuse part of the IBL.
  47710. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47711. * to the ground truth.
  47712. */
  47713. useSphericalHarmonics: boolean;
  47714. /** @hidden */
  47715. private _internalMarkAllSubMeshesAsMiscDirty;
  47716. /** @hidden */
  47717. _markAllSubMeshesAsMiscDirty(): void;
  47718. /**
  47719. * Instantiate a new istance of clear coat configuration.
  47720. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47721. */
  47722. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47723. /**
  47724. * Checks to see if a texture is used in the material.
  47725. * @param defines the list of "defines" to update.
  47726. */
  47727. prepareDefines(defines: IMaterialBRDFDefines): void;
  47728. /**
  47729. * Get the current class name of the texture useful for serialization or dynamic coding.
  47730. * @returns "PBRClearCoatConfiguration"
  47731. */
  47732. getClassName(): string;
  47733. /**
  47734. * Makes a duplicate of the current configuration into another one.
  47735. * @param brdfConfiguration define the config where to copy the info
  47736. */
  47737. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47738. /**
  47739. * Serializes this BRDF configuration.
  47740. * @returns - An object with the serialized config.
  47741. */
  47742. serialize(): any;
  47743. /**
  47744. * Parses a anisotropy Configuration from a serialized object.
  47745. * @param source - Serialized object.
  47746. * @param scene Defines the scene we are parsing for
  47747. * @param rootUrl Defines the rootUrl to load from
  47748. */
  47749. parse(source: any, scene: Scene, rootUrl: string): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47753. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47754. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47755. import { Color3 } from "babylonjs/Maths/math.color";
  47756. import { Scene } from "babylonjs/scene";
  47757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47758. import { Nullable } from "babylonjs/types";
  47759. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47760. /**
  47761. * @hidden
  47762. */
  47763. export interface IMaterialSheenDefines {
  47764. SHEEN: boolean;
  47765. SHEEN_TEXTURE: boolean;
  47766. SHEEN_TEXTUREDIRECTUV: number;
  47767. SHEEN_LINKWITHALBEDO: boolean;
  47768. /** @hidden */
  47769. _areTexturesDirty: boolean;
  47770. }
  47771. /**
  47772. * Define the code related to the Sheen parameters of the pbr material.
  47773. */
  47774. export class PBRSheenConfiguration {
  47775. private _isEnabled;
  47776. /**
  47777. * Defines if the material uses sheen.
  47778. */
  47779. isEnabled: boolean;
  47780. private _linkSheenWithAlbedo;
  47781. /**
  47782. * Defines if the sheen is linked to the sheen color.
  47783. */
  47784. linkSheenWithAlbedo: boolean;
  47785. /**
  47786. * Defines the sheen intensity.
  47787. */
  47788. intensity: number;
  47789. /**
  47790. * Defines the sheen color.
  47791. */
  47792. color: Color3;
  47793. private _texture;
  47794. /**
  47795. * Stores the sheen tint values in a texture.
  47796. * rgb is tint
  47797. * a is a intensity
  47798. */
  47799. texture: Nullable<BaseTexture>;
  47800. /** @hidden */
  47801. private _internalMarkAllSubMeshesAsTexturesDirty;
  47802. /** @hidden */
  47803. _markAllSubMeshesAsTexturesDirty(): void;
  47804. /**
  47805. * Instantiate a new istance of clear coat configuration.
  47806. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47807. */
  47808. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47809. /**
  47810. * Specifies that the submesh is ready to be used.
  47811. * @param defines the list of "defines" to update.
  47812. * @param scene defines the scene the material belongs to.
  47813. * @returns - boolean indicating that the submesh is ready or not.
  47814. */
  47815. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47816. /**
  47817. * Checks to see if a texture is used in the material.
  47818. * @param defines the list of "defines" to update.
  47819. * @param scene defines the scene the material belongs to.
  47820. */
  47821. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47822. /**
  47823. * Binds the material data.
  47824. * @param uniformBuffer defines the Uniform buffer to fill in.
  47825. * @param scene defines the scene the material belongs to.
  47826. * @param isFrozen defines wether the material is frozen or not.
  47827. */
  47828. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47829. /**
  47830. * Checks to see if a texture is used in the material.
  47831. * @param texture - Base texture to use.
  47832. * @returns - Boolean specifying if a texture is used in the material.
  47833. */
  47834. hasTexture(texture: BaseTexture): boolean;
  47835. /**
  47836. * Returns an array of the actively used textures.
  47837. * @param activeTextures Array of BaseTextures
  47838. */
  47839. getActiveTextures(activeTextures: BaseTexture[]): void;
  47840. /**
  47841. * Returns the animatable textures.
  47842. * @param animatables Array of animatable textures.
  47843. */
  47844. getAnimatables(animatables: IAnimatable[]): void;
  47845. /**
  47846. * Disposes the resources of the material.
  47847. * @param forceDisposeTextures - Forces the disposal of all textures.
  47848. */
  47849. dispose(forceDisposeTextures?: boolean): void;
  47850. /**
  47851. * Get the current class name of the texture useful for serialization or dynamic coding.
  47852. * @returns "PBRSheenConfiguration"
  47853. */
  47854. getClassName(): string;
  47855. /**
  47856. * Add fallbacks to the effect fallbacks list.
  47857. * @param defines defines the Base texture to use.
  47858. * @param fallbacks defines the current fallback list.
  47859. * @param currentRank defines the current fallback rank.
  47860. * @returns the new fallback rank.
  47861. */
  47862. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47863. /**
  47864. * Add the required uniforms to the current list.
  47865. * @param uniforms defines the current uniform list.
  47866. */
  47867. static AddUniforms(uniforms: string[]): void;
  47868. /**
  47869. * Add the required uniforms to the current buffer.
  47870. * @param uniformBuffer defines the current uniform buffer.
  47871. */
  47872. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47873. /**
  47874. * Add the required samplers to the current list.
  47875. * @param samplers defines the current sampler list.
  47876. */
  47877. static AddSamplers(samplers: string[]): void;
  47878. /**
  47879. * Makes a duplicate of the current configuration into another one.
  47880. * @param sheenConfiguration define the config where to copy the info
  47881. */
  47882. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47883. /**
  47884. * Serializes this BRDF configuration.
  47885. * @returns - An object with the serialized config.
  47886. */
  47887. serialize(): any;
  47888. /**
  47889. * Parses a anisotropy Configuration from a serialized object.
  47890. * @param source - Serialized object.
  47891. * @param scene Defines the scene we are parsing for
  47892. * @param rootUrl Defines the rootUrl to load from
  47893. */
  47894. parse(source: any, scene: Scene, rootUrl: string): void;
  47895. }
  47896. }
  47897. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47898. import { Nullable } from "babylonjs/types";
  47899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47900. import { Color3 } from "babylonjs/Maths/math.color";
  47901. import { SmartArray } from "babylonjs/Misc/smartArray";
  47902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47903. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47904. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47905. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47906. import { Engine } from "babylonjs/Engines/engine";
  47907. import { Scene } from "babylonjs/scene";
  47908. /**
  47909. * @hidden
  47910. */
  47911. export interface IMaterialSubSurfaceDefines {
  47912. SUBSURFACE: boolean;
  47913. SS_REFRACTION: boolean;
  47914. SS_TRANSLUCENCY: boolean;
  47915. SS_SCATERRING: boolean;
  47916. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47917. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47918. SS_REFRACTIONMAP_3D: boolean;
  47919. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47920. SS_LODINREFRACTIONALPHA: boolean;
  47921. SS_GAMMAREFRACTION: boolean;
  47922. SS_RGBDREFRACTION: boolean;
  47923. SS_LINEARSPECULARREFRACTION: boolean;
  47924. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47925. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47926. /** @hidden */
  47927. _areTexturesDirty: boolean;
  47928. }
  47929. /**
  47930. * Define the code related to the sub surface parameters of the pbr material.
  47931. */
  47932. export class PBRSubSurfaceConfiguration {
  47933. private _isRefractionEnabled;
  47934. /**
  47935. * Defines if the refraction is enabled in the material.
  47936. */
  47937. isRefractionEnabled: boolean;
  47938. private _isTranslucencyEnabled;
  47939. /**
  47940. * Defines if the translucency is enabled in the material.
  47941. */
  47942. isTranslucencyEnabled: boolean;
  47943. private _isScatteringEnabled;
  47944. /**
  47945. * Defines the refraction intensity of the material.
  47946. * The refraction when enabled replaces the Diffuse part of the material.
  47947. * The intensity helps transitionning between diffuse and refraction.
  47948. */
  47949. refractionIntensity: number;
  47950. /**
  47951. * Defines the translucency intensity of the material.
  47952. * When translucency has been enabled, this defines how much of the "translucency"
  47953. * is addded to the diffuse part of the material.
  47954. */
  47955. translucencyIntensity: number;
  47956. /**
  47957. * Defines the scattering intensity of the material.
  47958. * When scattering has been enabled, this defines how much of the "scattered light"
  47959. * is addded to the diffuse part of the material.
  47960. */
  47961. scatteringIntensity: number;
  47962. private _thicknessTexture;
  47963. /**
  47964. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47965. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47966. * 0 would mean minimumThickness
  47967. * 1 would mean maximumThickness
  47968. * The other channels might be use as a mask to vary the different effects intensity.
  47969. */
  47970. thicknessTexture: Nullable<BaseTexture>;
  47971. private _refractionTexture;
  47972. /**
  47973. * Defines the texture to use for refraction.
  47974. */
  47975. refractionTexture: Nullable<BaseTexture>;
  47976. private _indexOfRefraction;
  47977. /**
  47978. * Defines the index of refraction used in the material.
  47979. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47980. */
  47981. indexOfRefraction: number;
  47982. private _invertRefractionY;
  47983. /**
  47984. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47985. */
  47986. invertRefractionY: boolean;
  47987. private _linkRefractionWithTransparency;
  47988. /**
  47989. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47990. * Materials half opaque for instance using refraction could benefit from this control.
  47991. */
  47992. linkRefractionWithTransparency: boolean;
  47993. /**
  47994. * Defines the minimum thickness stored in the thickness map.
  47995. * If no thickness map is defined, this value will be used to simulate thickness.
  47996. */
  47997. minimumThickness: number;
  47998. /**
  47999. * Defines the maximum thickness stored in the thickness map.
  48000. */
  48001. maximumThickness: number;
  48002. /**
  48003. * Defines the volume tint of the material.
  48004. * This is used for both translucency and scattering.
  48005. */
  48006. tintColor: Color3;
  48007. /**
  48008. * Defines the distance at which the tint color should be found in the media.
  48009. * This is used for refraction only.
  48010. */
  48011. tintColorAtDistance: number;
  48012. /**
  48013. * Defines how far each channel transmit through the media.
  48014. * It is defined as a color to simplify it selection.
  48015. */
  48016. diffusionDistance: Color3;
  48017. private _useMaskFromThicknessTexture;
  48018. /**
  48019. * Stores the intensity of the different subsurface effects in the thickness texture.
  48020. * * the green channel is the translucency intensity.
  48021. * * the blue channel is the scattering intensity.
  48022. * * the alpha channel is the refraction intensity.
  48023. */
  48024. useMaskFromThicknessTexture: boolean;
  48025. /** @hidden */
  48026. private _internalMarkAllSubMeshesAsTexturesDirty;
  48027. /** @hidden */
  48028. _markAllSubMeshesAsTexturesDirty(): void;
  48029. /**
  48030. * Instantiate a new istance of sub surface configuration.
  48031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48032. */
  48033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48034. /**
  48035. * Gets wehter the submesh is ready to be used or not.
  48036. * @param defines the list of "defines" to update.
  48037. * @param scene defines the scene the material belongs to.
  48038. * @returns - boolean indicating that the submesh is ready or not.
  48039. */
  48040. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48041. /**
  48042. * Checks to see if a texture is used in the material.
  48043. * @param defines the list of "defines" to update.
  48044. * @param scene defines the scene to the material belongs to.
  48045. */
  48046. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48047. /**
  48048. * Binds the material data.
  48049. * @param uniformBuffer defines the Uniform buffer to fill in.
  48050. * @param scene defines the scene the material belongs to.
  48051. * @param engine defines the engine the material belongs to.
  48052. * @param isFrozen defines wether the material is frozen or not.
  48053. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48054. */
  48055. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48056. /**
  48057. * Unbinds the material from the mesh.
  48058. * @param activeEffect defines the effect that should be unbound from.
  48059. * @returns true if unbound, otherwise false
  48060. */
  48061. unbind(activeEffect: Effect): boolean;
  48062. /**
  48063. * Returns the texture used for refraction or null if none is used.
  48064. * @param scene defines the scene the material belongs to.
  48065. * @returns - Refraction texture if present. If no refraction texture and refraction
  48066. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48067. */
  48068. private _getRefractionTexture;
  48069. /**
  48070. * Returns true if alpha blending should be disabled.
  48071. */
  48072. readonly disableAlphaBlending: boolean;
  48073. /**
  48074. * Fills the list of render target textures.
  48075. * @param renderTargets the list of render targets to update
  48076. */
  48077. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48078. /**
  48079. * Checks to see if a texture is used in the material.
  48080. * @param texture - Base texture to use.
  48081. * @returns - Boolean specifying if a texture is used in the material.
  48082. */
  48083. hasTexture(texture: BaseTexture): boolean;
  48084. /**
  48085. * Gets a boolean indicating that current material needs to register RTT
  48086. * @returns true if this uses a render target otherwise false.
  48087. */
  48088. hasRenderTargetTextures(): boolean;
  48089. /**
  48090. * Returns an array of the actively used textures.
  48091. * @param activeTextures Array of BaseTextures
  48092. */
  48093. getActiveTextures(activeTextures: BaseTexture[]): void;
  48094. /**
  48095. * Returns the animatable textures.
  48096. * @param animatables Array of animatable textures.
  48097. */
  48098. getAnimatables(animatables: IAnimatable[]): void;
  48099. /**
  48100. * Disposes the resources of the material.
  48101. * @param forceDisposeTextures - Forces the disposal of all textures.
  48102. */
  48103. dispose(forceDisposeTextures?: boolean): void;
  48104. /**
  48105. * Get the current class name of the texture useful for serialization or dynamic coding.
  48106. * @returns "PBRSubSurfaceConfiguration"
  48107. */
  48108. getClassName(): string;
  48109. /**
  48110. * Add fallbacks to the effect fallbacks list.
  48111. * @param defines defines the Base texture to use.
  48112. * @param fallbacks defines the current fallback list.
  48113. * @param currentRank defines the current fallback rank.
  48114. * @returns the new fallback rank.
  48115. */
  48116. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48117. /**
  48118. * Add the required uniforms to the current list.
  48119. * @param uniforms defines the current uniform list.
  48120. */
  48121. static AddUniforms(uniforms: string[]): void;
  48122. /**
  48123. * Add the required samplers to the current list.
  48124. * @param samplers defines the current sampler list.
  48125. */
  48126. static AddSamplers(samplers: string[]): void;
  48127. /**
  48128. * Add the required uniforms to the current buffer.
  48129. * @param uniformBuffer defines the current uniform buffer.
  48130. */
  48131. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48132. /**
  48133. * Makes a duplicate of the current configuration into another one.
  48134. * @param configuration define the config where to copy the info
  48135. */
  48136. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48137. /**
  48138. * Serializes this Sub Surface configuration.
  48139. * @returns - An object with the serialized config.
  48140. */
  48141. serialize(): any;
  48142. /**
  48143. * Parses a anisotropy Configuration from a serialized object.
  48144. * @param source - Serialized object.
  48145. * @param scene Defines the scene we are parsing for
  48146. * @param rootUrl Defines the rootUrl to load from
  48147. */
  48148. parse(source: any, scene: Scene, rootUrl: string): void;
  48149. }
  48150. }
  48151. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48152. /** @hidden */
  48153. export var pbrFragmentDeclaration: {
  48154. name: string;
  48155. shader: string;
  48156. };
  48157. }
  48158. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48159. /** @hidden */
  48160. export var pbrUboDeclaration: {
  48161. name: string;
  48162. shader: string;
  48163. };
  48164. }
  48165. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48166. /** @hidden */
  48167. export var pbrFragmentExtraDeclaration: {
  48168. name: string;
  48169. shader: string;
  48170. };
  48171. }
  48172. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48173. /** @hidden */
  48174. export var pbrFragmentSamplersDeclaration: {
  48175. name: string;
  48176. shader: string;
  48177. };
  48178. }
  48179. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48180. /** @hidden */
  48181. export var pbrHelperFunctions: {
  48182. name: string;
  48183. shader: string;
  48184. };
  48185. }
  48186. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48187. /** @hidden */
  48188. export var harmonicsFunctions: {
  48189. name: string;
  48190. shader: string;
  48191. };
  48192. }
  48193. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48194. /** @hidden */
  48195. export var pbrDirectLightingSetupFunctions: {
  48196. name: string;
  48197. shader: string;
  48198. };
  48199. }
  48200. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48201. /** @hidden */
  48202. export var pbrDirectLightingFalloffFunctions: {
  48203. name: string;
  48204. shader: string;
  48205. };
  48206. }
  48207. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48208. /** @hidden */
  48209. export var pbrBRDFFunctions: {
  48210. name: string;
  48211. shader: string;
  48212. };
  48213. }
  48214. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48215. /** @hidden */
  48216. export var pbrDirectLightingFunctions: {
  48217. name: string;
  48218. shader: string;
  48219. };
  48220. }
  48221. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48222. /** @hidden */
  48223. export var pbrIBLFunctions: {
  48224. name: string;
  48225. shader: string;
  48226. };
  48227. }
  48228. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48229. /** @hidden */
  48230. export var pbrDebug: {
  48231. name: string;
  48232. shader: string;
  48233. };
  48234. }
  48235. declare module "babylonjs/Shaders/pbr.fragment" {
  48236. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48237. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48238. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48239. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48240. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48241. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48242. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48243. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48244. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48245. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48247. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48248. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48249. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48250. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48251. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48252. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48253. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48254. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48255. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48256. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48257. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48258. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48259. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48260. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48261. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48262. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48263. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48264. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48265. /** @hidden */
  48266. export var pbrPixelShader: {
  48267. name: string;
  48268. shader: string;
  48269. };
  48270. }
  48271. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48272. /** @hidden */
  48273. export var pbrVertexDeclaration: {
  48274. name: string;
  48275. shader: string;
  48276. };
  48277. }
  48278. declare module "babylonjs/Shaders/pbr.vertex" {
  48279. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48280. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48282. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48283. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48284. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48285. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48286. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48287. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48288. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48289. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48290. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48291. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48292. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48294. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48295. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48296. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48297. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48298. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48299. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48300. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48301. /** @hidden */
  48302. export var pbrVertexShader: {
  48303. name: string;
  48304. shader: string;
  48305. };
  48306. }
  48307. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48308. import { Nullable } from "babylonjs/types";
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Matrix } from "babylonjs/Maths/math.vector";
  48311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48313. import { Mesh } from "babylonjs/Meshes/mesh";
  48314. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48315. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48316. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48317. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48318. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48319. import { Color3 } from "babylonjs/Maths/math.color";
  48320. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48321. import { Material } from "babylonjs/Materials/material";
  48322. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48323. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48325. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48326. import "babylonjs/Shaders/pbr.fragment";
  48327. import "babylonjs/Shaders/pbr.vertex";
  48328. /**
  48329. * Manages the defines for the PBR Material.
  48330. * @hidden
  48331. */
  48332. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48333. PBR: boolean;
  48334. MAINUV1: boolean;
  48335. MAINUV2: boolean;
  48336. UV1: boolean;
  48337. UV2: boolean;
  48338. ALBEDO: boolean;
  48339. ALBEDODIRECTUV: number;
  48340. VERTEXCOLOR: boolean;
  48341. AMBIENT: boolean;
  48342. AMBIENTDIRECTUV: number;
  48343. AMBIENTINGRAYSCALE: boolean;
  48344. OPACITY: boolean;
  48345. VERTEXALPHA: boolean;
  48346. OPACITYDIRECTUV: number;
  48347. OPACITYRGB: boolean;
  48348. ALPHATEST: boolean;
  48349. DEPTHPREPASS: boolean;
  48350. ALPHABLEND: boolean;
  48351. ALPHAFROMALBEDO: boolean;
  48352. ALPHATESTVALUE: string;
  48353. SPECULAROVERALPHA: boolean;
  48354. RADIANCEOVERALPHA: boolean;
  48355. ALPHAFRESNEL: boolean;
  48356. LINEARALPHAFRESNEL: boolean;
  48357. PREMULTIPLYALPHA: boolean;
  48358. EMISSIVE: boolean;
  48359. EMISSIVEDIRECTUV: number;
  48360. REFLECTIVITY: boolean;
  48361. REFLECTIVITYDIRECTUV: number;
  48362. SPECULARTERM: boolean;
  48363. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48364. MICROSURFACEAUTOMATIC: boolean;
  48365. LODBASEDMICROSFURACE: boolean;
  48366. MICROSURFACEMAP: boolean;
  48367. MICROSURFACEMAPDIRECTUV: number;
  48368. METALLICWORKFLOW: boolean;
  48369. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48370. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48371. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48372. AOSTOREINMETALMAPRED: boolean;
  48373. ENVIRONMENTBRDF: boolean;
  48374. ENVIRONMENTBRDF_RGBD: boolean;
  48375. NORMAL: boolean;
  48376. TANGENT: boolean;
  48377. BUMP: boolean;
  48378. BUMPDIRECTUV: number;
  48379. OBJECTSPACE_NORMALMAP: boolean;
  48380. PARALLAX: boolean;
  48381. PARALLAXOCCLUSION: boolean;
  48382. NORMALXYSCALE: boolean;
  48383. LIGHTMAP: boolean;
  48384. LIGHTMAPDIRECTUV: number;
  48385. USELIGHTMAPASSHADOWMAP: boolean;
  48386. GAMMALIGHTMAP: boolean;
  48387. REFLECTION: boolean;
  48388. REFLECTIONMAP_3D: boolean;
  48389. REFLECTIONMAP_SPHERICAL: boolean;
  48390. REFLECTIONMAP_PLANAR: boolean;
  48391. REFLECTIONMAP_CUBIC: boolean;
  48392. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48393. REFLECTIONMAP_PROJECTION: boolean;
  48394. REFLECTIONMAP_SKYBOX: boolean;
  48395. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48396. REFLECTIONMAP_EXPLICIT: boolean;
  48397. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48398. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48399. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48400. INVERTCUBICMAP: boolean;
  48401. USESPHERICALFROMREFLECTIONMAP: boolean;
  48402. USEIRRADIANCEMAP: boolean;
  48403. SPHERICAL_HARMONICS: boolean;
  48404. USESPHERICALINVERTEX: boolean;
  48405. REFLECTIONMAP_OPPOSITEZ: boolean;
  48406. LODINREFLECTIONALPHA: boolean;
  48407. GAMMAREFLECTION: boolean;
  48408. RGBDREFLECTION: boolean;
  48409. LINEARSPECULARREFLECTION: boolean;
  48410. RADIANCEOCCLUSION: boolean;
  48411. HORIZONOCCLUSION: boolean;
  48412. INSTANCES: boolean;
  48413. NUM_BONE_INFLUENCERS: number;
  48414. BonesPerMesh: number;
  48415. BONETEXTURE: boolean;
  48416. NONUNIFORMSCALING: boolean;
  48417. MORPHTARGETS: boolean;
  48418. MORPHTARGETS_NORMAL: boolean;
  48419. MORPHTARGETS_TANGENT: boolean;
  48420. MORPHTARGETS_UV: boolean;
  48421. NUM_MORPH_INFLUENCERS: number;
  48422. IMAGEPROCESSING: boolean;
  48423. VIGNETTE: boolean;
  48424. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48425. VIGNETTEBLENDMODEOPAQUE: boolean;
  48426. TONEMAPPING: boolean;
  48427. TONEMAPPING_ACES: boolean;
  48428. CONTRAST: boolean;
  48429. COLORCURVES: boolean;
  48430. COLORGRADING: boolean;
  48431. COLORGRADING3D: boolean;
  48432. SAMPLER3DGREENDEPTH: boolean;
  48433. SAMPLER3DBGRMAP: boolean;
  48434. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48435. EXPOSURE: boolean;
  48436. MULTIVIEW: boolean;
  48437. USEPHYSICALLIGHTFALLOFF: boolean;
  48438. USEGLTFLIGHTFALLOFF: boolean;
  48439. TWOSIDEDLIGHTING: boolean;
  48440. SHADOWFLOAT: boolean;
  48441. CLIPPLANE: boolean;
  48442. CLIPPLANE2: boolean;
  48443. CLIPPLANE3: boolean;
  48444. CLIPPLANE4: boolean;
  48445. POINTSIZE: boolean;
  48446. FOG: boolean;
  48447. LOGARITHMICDEPTH: boolean;
  48448. FORCENORMALFORWARD: boolean;
  48449. SPECULARAA: boolean;
  48450. CLEARCOAT: boolean;
  48451. CLEARCOAT_DEFAULTIOR: boolean;
  48452. CLEARCOAT_TEXTURE: boolean;
  48453. CLEARCOAT_TEXTUREDIRECTUV: number;
  48454. CLEARCOAT_BUMP: boolean;
  48455. CLEARCOAT_BUMPDIRECTUV: number;
  48456. CLEARCOAT_TINT: boolean;
  48457. CLEARCOAT_TINT_TEXTURE: boolean;
  48458. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48459. ANISOTROPIC: boolean;
  48460. ANISOTROPIC_TEXTURE: boolean;
  48461. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48462. BRDF_V_HEIGHT_CORRELATED: boolean;
  48463. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48464. SHEEN: boolean;
  48465. SHEEN_TEXTURE: boolean;
  48466. SHEEN_TEXTUREDIRECTUV: number;
  48467. SHEEN_LINKWITHALBEDO: boolean;
  48468. SUBSURFACE: boolean;
  48469. SS_REFRACTION: boolean;
  48470. SS_TRANSLUCENCY: boolean;
  48471. SS_SCATERRING: boolean;
  48472. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48473. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48474. SS_REFRACTIONMAP_3D: boolean;
  48475. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48476. SS_LODINREFRACTIONALPHA: boolean;
  48477. SS_GAMMAREFRACTION: boolean;
  48478. SS_RGBDREFRACTION: boolean;
  48479. SS_LINEARSPECULARREFRACTION: boolean;
  48480. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48481. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48482. UNLIT: boolean;
  48483. DEBUGMODE: number;
  48484. /**
  48485. * Initializes the PBR Material defines.
  48486. */
  48487. constructor();
  48488. /**
  48489. * Resets the PBR Material defines.
  48490. */
  48491. reset(): void;
  48492. }
  48493. /**
  48494. * The Physically based material base class of BJS.
  48495. *
  48496. * This offers the main features of a standard PBR material.
  48497. * For more information, please refer to the documentation :
  48498. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48499. */
  48500. export abstract class PBRBaseMaterial extends PushMaterial {
  48501. /**
  48502. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48503. */
  48504. static readonly PBRMATERIAL_OPAQUE: number;
  48505. /**
  48506. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48507. */
  48508. static readonly PBRMATERIAL_ALPHATEST: number;
  48509. /**
  48510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48511. */
  48512. static readonly PBRMATERIAL_ALPHABLEND: number;
  48513. /**
  48514. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48515. * They are also discarded below the alpha cutoff threshold to improve performances.
  48516. */
  48517. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48518. /**
  48519. * Defines the default value of how much AO map is occluding the analytical lights
  48520. * (point spot...).
  48521. */
  48522. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48523. /**
  48524. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48525. */
  48526. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48527. /**
  48528. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48529. * to enhance interoperability with other engines.
  48530. */
  48531. static readonly LIGHTFALLOFF_GLTF: number;
  48532. /**
  48533. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48534. * to enhance interoperability with other materials.
  48535. */
  48536. static readonly LIGHTFALLOFF_STANDARD: number;
  48537. /**
  48538. * Intensity of the direct lights e.g. the four lights available in your scene.
  48539. * This impacts both the direct diffuse and specular highlights.
  48540. */
  48541. protected _directIntensity: number;
  48542. /**
  48543. * Intensity of the emissive part of the material.
  48544. * This helps controlling the emissive effect without modifying the emissive color.
  48545. */
  48546. protected _emissiveIntensity: number;
  48547. /**
  48548. * Intensity of the environment e.g. how much the environment will light the object
  48549. * either through harmonics for rough material or through the refelction for shiny ones.
  48550. */
  48551. protected _environmentIntensity: number;
  48552. /**
  48553. * This is a special control allowing the reduction of the specular highlights coming from the
  48554. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48555. */
  48556. protected _specularIntensity: number;
  48557. /**
  48558. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48559. */
  48560. private _lightingInfos;
  48561. /**
  48562. * Debug Control allowing disabling the bump map on this material.
  48563. */
  48564. protected _disableBumpMap: boolean;
  48565. /**
  48566. * AKA Diffuse Texture in standard nomenclature.
  48567. */
  48568. protected _albedoTexture: Nullable<BaseTexture>;
  48569. /**
  48570. * AKA Occlusion Texture in other nomenclature.
  48571. */
  48572. protected _ambientTexture: Nullable<BaseTexture>;
  48573. /**
  48574. * AKA Occlusion Texture Intensity in other nomenclature.
  48575. */
  48576. protected _ambientTextureStrength: number;
  48577. /**
  48578. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48579. * 1 means it completely occludes it
  48580. * 0 mean it has no impact
  48581. */
  48582. protected _ambientTextureImpactOnAnalyticalLights: number;
  48583. /**
  48584. * Stores the alpha values in a texture.
  48585. */
  48586. protected _opacityTexture: Nullable<BaseTexture>;
  48587. /**
  48588. * Stores the reflection values in a texture.
  48589. */
  48590. protected _reflectionTexture: Nullable<BaseTexture>;
  48591. /**
  48592. * Stores the emissive values in a texture.
  48593. */
  48594. protected _emissiveTexture: Nullable<BaseTexture>;
  48595. /**
  48596. * AKA Specular texture in other nomenclature.
  48597. */
  48598. protected _reflectivityTexture: Nullable<BaseTexture>;
  48599. /**
  48600. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48601. */
  48602. protected _metallicTexture: Nullable<BaseTexture>;
  48603. /**
  48604. * Specifies the metallic scalar of the metallic/roughness workflow.
  48605. * Can also be used to scale the metalness values of the metallic texture.
  48606. */
  48607. protected _metallic: Nullable<number>;
  48608. /**
  48609. * Specifies the roughness scalar of the metallic/roughness workflow.
  48610. * Can also be used to scale the roughness values of the metallic texture.
  48611. */
  48612. protected _roughness: Nullable<number>;
  48613. /**
  48614. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48615. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48616. */
  48617. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48618. /**
  48619. * Stores surface normal data used to displace a mesh in a texture.
  48620. */
  48621. protected _bumpTexture: Nullable<BaseTexture>;
  48622. /**
  48623. * Stores the pre-calculated light information of a mesh in a texture.
  48624. */
  48625. protected _lightmapTexture: Nullable<BaseTexture>;
  48626. /**
  48627. * The color of a material in ambient lighting.
  48628. */
  48629. protected _ambientColor: Color3;
  48630. /**
  48631. * AKA Diffuse Color in other nomenclature.
  48632. */
  48633. protected _albedoColor: Color3;
  48634. /**
  48635. * AKA Specular Color in other nomenclature.
  48636. */
  48637. protected _reflectivityColor: Color3;
  48638. /**
  48639. * The color applied when light is reflected from a material.
  48640. */
  48641. protected _reflectionColor: Color3;
  48642. /**
  48643. * The color applied when light is emitted from a material.
  48644. */
  48645. protected _emissiveColor: Color3;
  48646. /**
  48647. * AKA Glossiness in other nomenclature.
  48648. */
  48649. protected _microSurface: number;
  48650. /**
  48651. * Specifies that the material will use the light map as a show map.
  48652. */
  48653. protected _useLightmapAsShadowmap: boolean;
  48654. /**
  48655. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48656. * makes the reflect vector face the model (under horizon).
  48657. */
  48658. protected _useHorizonOcclusion: boolean;
  48659. /**
  48660. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48661. * too much the area relying on ambient texture to define their ambient occlusion.
  48662. */
  48663. protected _useRadianceOcclusion: boolean;
  48664. /**
  48665. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48666. */
  48667. protected _useAlphaFromAlbedoTexture: boolean;
  48668. /**
  48669. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48670. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48671. */
  48672. protected _useSpecularOverAlpha: boolean;
  48673. /**
  48674. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48675. */
  48676. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48677. /**
  48678. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48679. */
  48680. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48681. /**
  48682. * Specifies if the metallic texture contains the roughness information in its green channel.
  48683. */
  48684. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48685. /**
  48686. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48687. */
  48688. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48689. /**
  48690. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48691. */
  48692. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48693. /**
  48694. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48695. */
  48696. protected _useAmbientInGrayScale: boolean;
  48697. /**
  48698. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48699. * The material will try to infer what glossiness each pixel should be.
  48700. */
  48701. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48702. /**
  48703. * Defines the falloff type used in this material.
  48704. * It by default is Physical.
  48705. */
  48706. protected _lightFalloff: number;
  48707. /**
  48708. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48709. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48710. */
  48711. protected _useRadianceOverAlpha: boolean;
  48712. /**
  48713. * Allows using an object space normal map (instead of tangent space).
  48714. */
  48715. protected _useObjectSpaceNormalMap: boolean;
  48716. /**
  48717. * Allows using the bump map in parallax mode.
  48718. */
  48719. protected _useParallax: boolean;
  48720. /**
  48721. * Allows using the bump map in parallax occlusion mode.
  48722. */
  48723. protected _useParallaxOcclusion: boolean;
  48724. /**
  48725. * Controls the scale bias of the parallax mode.
  48726. */
  48727. protected _parallaxScaleBias: number;
  48728. /**
  48729. * If sets to true, disables all the lights affecting the material.
  48730. */
  48731. protected _disableLighting: boolean;
  48732. /**
  48733. * Number of Simultaneous lights allowed on the material.
  48734. */
  48735. protected _maxSimultaneousLights: number;
  48736. /**
  48737. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48738. */
  48739. protected _invertNormalMapX: boolean;
  48740. /**
  48741. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48742. */
  48743. protected _invertNormalMapY: boolean;
  48744. /**
  48745. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48746. */
  48747. protected _twoSidedLighting: boolean;
  48748. /**
  48749. * Defines the alpha limits in alpha test mode.
  48750. */
  48751. protected _alphaCutOff: number;
  48752. /**
  48753. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48754. */
  48755. protected _forceAlphaTest: boolean;
  48756. /**
  48757. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48758. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48759. */
  48760. protected _useAlphaFresnel: boolean;
  48761. /**
  48762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48763. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48764. */
  48765. protected _useLinearAlphaFresnel: boolean;
  48766. /**
  48767. * The transparency mode of the material.
  48768. */
  48769. protected _transparencyMode: Nullable<number>;
  48770. /**
  48771. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48772. * from cos thetav and roughness:
  48773. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48774. */
  48775. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48776. /**
  48777. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48778. */
  48779. protected _forceIrradianceInFragment: boolean;
  48780. /**
  48781. * Force normal to face away from face.
  48782. */
  48783. protected _forceNormalForward: boolean;
  48784. /**
  48785. * Enables specular anti aliasing in the PBR shader.
  48786. * It will both interacts on the Geometry for analytical and IBL lighting.
  48787. * It also prefilter the roughness map based on the bump values.
  48788. */
  48789. protected _enableSpecularAntiAliasing: boolean;
  48790. /**
  48791. * Default configuration related to image processing available in the PBR Material.
  48792. */
  48793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48794. /**
  48795. * Keep track of the image processing observer to allow dispose and replace.
  48796. */
  48797. private _imageProcessingObserver;
  48798. /**
  48799. * Attaches a new image processing configuration to the PBR Material.
  48800. * @param configuration
  48801. */
  48802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48803. /**
  48804. * Stores the available render targets.
  48805. */
  48806. private _renderTargets;
  48807. /**
  48808. * Sets the global ambient color for the material used in lighting calculations.
  48809. */
  48810. private _globalAmbientColor;
  48811. /**
  48812. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48813. */
  48814. private _useLogarithmicDepth;
  48815. /**
  48816. * If set to true, no lighting calculations will be applied.
  48817. */
  48818. private _unlit;
  48819. private _debugMode;
  48820. /**
  48821. * @hidden
  48822. * This is reserved for the inspector.
  48823. * Defines the material debug mode.
  48824. * It helps seeing only some components of the material while troubleshooting.
  48825. */
  48826. debugMode: number;
  48827. /**
  48828. * @hidden
  48829. * This is reserved for the inspector.
  48830. * Specify from where on screen the debug mode should start.
  48831. * The value goes from -1 (full screen) to 1 (not visible)
  48832. * It helps with side by side comparison against the final render
  48833. * This defaults to -1
  48834. */
  48835. private debugLimit;
  48836. /**
  48837. * @hidden
  48838. * This is reserved for the inspector.
  48839. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48840. * You can use the factor to better multiply the final value.
  48841. */
  48842. private debugFactor;
  48843. /**
  48844. * Defines the clear coat layer parameters for the material.
  48845. */
  48846. readonly clearCoat: PBRClearCoatConfiguration;
  48847. /**
  48848. * Defines the anisotropic parameters for the material.
  48849. */
  48850. readonly anisotropy: PBRAnisotropicConfiguration;
  48851. /**
  48852. * Defines the BRDF parameters for the material.
  48853. */
  48854. readonly brdf: PBRBRDFConfiguration;
  48855. /**
  48856. * Defines the Sheen parameters for the material.
  48857. */
  48858. readonly sheen: PBRSheenConfiguration;
  48859. /**
  48860. * Defines the SubSurface parameters for the material.
  48861. */
  48862. readonly subSurface: PBRSubSurfaceConfiguration;
  48863. /**
  48864. * Custom callback helping to override the default shader used in the material.
  48865. */
  48866. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48867. /**
  48868. * Instantiates a new PBRMaterial instance.
  48869. *
  48870. * @param name The material name
  48871. * @param scene The scene the material will be use in.
  48872. */
  48873. constructor(name: string, scene: Scene);
  48874. /**
  48875. * Gets a boolean indicating that current material needs to register RTT
  48876. */
  48877. readonly hasRenderTargetTextures: boolean;
  48878. /**
  48879. * Gets the name of the material class.
  48880. */
  48881. getClassName(): string;
  48882. /**
  48883. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48884. */
  48885. /**
  48886. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48887. */
  48888. useLogarithmicDepth: boolean;
  48889. /**
  48890. * Gets the current transparency mode.
  48891. */
  48892. /**
  48893. * Sets the transparency mode of the material.
  48894. *
  48895. * | Value | Type | Description |
  48896. * | ----- | ----------------------------------- | ----------- |
  48897. * | 0 | OPAQUE | |
  48898. * | 1 | ALPHATEST | |
  48899. * | 2 | ALPHABLEND | |
  48900. * | 3 | ALPHATESTANDBLEND | |
  48901. *
  48902. */
  48903. transparencyMode: Nullable<number>;
  48904. /**
  48905. * Returns true if alpha blending should be disabled.
  48906. */
  48907. private readonly _disableAlphaBlending;
  48908. /**
  48909. * Specifies whether or not this material should be rendered in alpha blend mode.
  48910. */
  48911. needAlphaBlending(): boolean;
  48912. /**
  48913. * Specifies if the mesh will require alpha blending.
  48914. * @param mesh - BJS mesh.
  48915. */
  48916. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48917. /**
  48918. * Specifies whether or not this material should be rendered in alpha test mode.
  48919. */
  48920. needAlphaTesting(): boolean;
  48921. /**
  48922. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48923. */
  48924. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48925. /**
  48926. * Gets the texture used for the alpha test.
  48927. */
  48928. getAlphaTestTexture(): Nullable<BaseTexture>;
  48929. /**
  48930. * Specifies that the submesh is ready to be used.
  48931. * @param mesh - BJS mesh.
  48932. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48933. * @param useInstances - Specifies that instances should be used.
  48934. * @returns - boolean indicating that the submesh is ready or not.
  48935. */
  48936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48937. /**
  48938. * Specifies if the material uses metallic roughness workflow.
  48939. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48940. */
  48941. isMetallicWorkflow(): boolean;
  48942. private _prepareEffect;
  48943. private _prepareDefines;
  48944. /**
  48945. * Force shader compilation
  48946. */
  48947. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48948. clipPlane: boolean;
  48949. }>): void;
  48950. /**
  48951. * Initializes the uniform buffer layout for the shader.
  48952. */
  48953. buildUniformLayout(): void;
  48954. /**
  48955. * Unbinds the material from the mesh
  48956. */
  48957. unbind(): void;
  48958. /**
  48959. * Binds the submesh data.
  48960. * @param world - The world matrix.
  48961. * @param mesh - The BJS mesh.
  48962. * @param subMesh - A submesh of the BJS mesh.
  48963. */
  48964. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48965. /**
  48966. * Returns the animatable textures.
  48967. * @returns - Array of animatable textures.
  48968. */
  48969. getAnimatables(): IAnimatable[];
  48970. /**
  48971. * Returns the texture used for reflections.
  48972. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48973. */
  48974. private _getReflectionTexture;
  48975. /**
  48976. * Returns an array of the actively used textures.
  48977. * @returns - Array of BaseTextures
  48978. */
  48979. getActiveTextures(): BaseTexture[];
  48980. /**
  48981. * Checks to see if a texture is used in the material.
  48982. * @param texture - Base texture to use.
  48983. * @returns - Boolean specifying if a texture is used in the material.
  48984. */
  48985. hasTexture(texture: BaseTexture): boolean;
  48986. /**
  48987. * Disposes the resources of the material.
  48988. * @param forceDisposeEffect - Forces the disposal of effects.
  48989. * @param forceDisposeTextures - Forces the disposal of all textures.
  48990. */
  48991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48992. }
  48993. }
  48994. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48995. import { Nullable } from "babylonjs/types";
  48996. import { Scene } from "babylonjs/scene";
  48997. import { Color3 } from "babylonjs/Maths/math.color";
  48998. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48999. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49001. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49002. /**
  49003. * The Physically based material of BJS.
  49004. *
  49005. * This offers the main features of a standard PBR material.
  49006. * For more information, please refer to the documentation :
  49007. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49008. */
  49009. export class PBRMaterial extends PBRBaseMaterial {
  49010. /**
  49011. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49012. */
  49013. static readonly PBRMATERIAL_OPAQUE: number;
  49014. /**
  49015. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49016. */
  49017. static readonly PBRMATERIAL_ALPHATEST: number;
  49018. /**
  49019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49020. */
  49021. static readonly PBRMATERIAL_ALPHABLEND: number;
  49022. /**
  49023. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49024. * They are also discarded below the alpha cutoff threshold to improve performances.
  49025. */
  49026. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49027. /**
  49028. * Defines the default value of how much AO map is occluding the analytical lights
  49029. * (point spot...).
  49030. */
  49031. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49032. /**
  49033. * Intensity of the direct lights e.g. the four lights available in your scene.
  49034. * This impacts both the direct diffuse and specular highlights.
  49035. */
  49036. directIntensity: number;
  49037. /**
  49038. * Intensity of the emissive part of the material.
  49039. * This helps controlling the emissive effect without modifying the emissive color.
  49040. */
  49041. emissiveIntensity: number;
  49042. /**
  49043. * Intensity of the environment e.g. how much the environment will light the object
  49044. * either through harmonics for rough material or through the refelction for shiny ones.
  49045. */
  49046. environmentIntensity: number;
  49047. /**
  49048. * This is a special control allowing the reduction of the specular highlights coming from the
  49049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49050. */
  49051. specularIntensity: number;
  49052. /**
  49053. * Debug Control allowing disabling the bump map on this material.
  49054. */
  49055. disableBumpMap: boolean;
  49056. /**
  49057. * AKA Diffuse Texture in standard nomenclature.
  49058. */
  49059. albedoTexture: BaseTexture;
  49060. /**
  49061. * AKA Occlusion Texture in other nomenclature.
  49062. */
  49063. ambientTexture: BaseTexture;
  49064. /**
  49065. * AKA Occlusion Texture Intensity in other nomenclature.
  49066. */
  49067. ambientTextureStrength: number;
  49068. /**
  49069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49070. * 1 means it completely occludes it
  49071. * 0 mean it has no impact
  49072. */
  49073. ambientTextureImpactOnAnalyticalLights: number;
  49074. /**
  49075. * Stores the alpha values in a texture.
  49076. */
  49077. opacityTexture: BaseTexture;
  49078. /**
  49079. * Stores the reflection values in a texture.
  49080. */
  49081. reflectionTexture: Nullable<BaseTexture>;
  49082. /**
  49083. * Stores the emissive values in a texture.
  49084. */
  49085. emissiveTexture: BaseTexture;
  49086. /**
  49087. * AKA Specular texture in other nomenclature.
  49088. */
  49089. reflectivityTexture: BaseTexture;
  49090. /**
  49091. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49092. */
  49093. metallicTexture: BaseTexture;
  49094. /**
  49095. * Specifies the metallic scalar of the metallic/roughness workflow.
  49096. * Can also be used to scale the metalness values of the metallic texture.
  49097. */
  49098. metallic: Nullable<number>;
  49099. /**
  49100. * Specifies the roughness scalar of the metallic/roughness workflow.
  49101. * Can also be used to scale the roughness values of the metallic texture.
  49102. */
  49103. roughness: Nullable<number>;
  49104. /**
  49105. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49106. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49107. */
  49108. microSurfaceTexture: BaseTexture;
  49109. /**
  49110. * Stores surface normal data used to displace a mesh in a texture.
  49111. */
  49112. bumpTexture: BaseTexture;
  49113. /**
  49114. * Stores the pre-calculated light information of a mesh in a texture.
  49115. */
  49116. lightmapTexture: BaseTexture;
  49117. /**
  49118. * Stores the refracted light information in a texture.
  49119. */
  49120. refractionTexture: Nullable<BaseTexture>;
  49121. /**
  49122. * The color of a material in ambient lighting.
  49123. */
  49124. ambientColor: Color3;
  49125. /**
  49126. * AKA Diffuse Color in other nomenclature.
  49127. */
  49128. albedoColor: Color3;
  49129. /**
  49130. * AKA Specular Color in other nomenclature.
  49131. */
  49132. reflectivityColor: Color3;
  49133. /**
  49134. * The color reflected from the material.
  49135. */
  49136. reflectionColor: Color3;
  49137. /**
  49138. * The color emitted from the material.
  49139. */
  49140. emissiveColor: Color3;
  49141. /**
  49142. * AKA Glossiness in other nomenclature.
  49143. */
  49144. microSurface: number;
  49145. /**
  49146. * source material index of refraction (IOR)' / 'destination material IOR.
  49147. */
  49148. indexOfRefraction: number;
  49149. /**
  49150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49151. */
  49152. invertRefractionY: boolean;
  49153. /**
  49154. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49155. * Materials half opaque for instance using refraction could benefit from this control.
  49156. */
  49157. linkRefractionWithTransparency: boolean;
  49158. /**
  49159. * If true, the light map contains occlusion information instead of lighting info.
  49160. */
  49161. useLightmapAsShadowmap: boolean;
  49162. /**
  49163. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49164. */
  49165. useAlphaFromAlbedoTexture: boolean;
  49166. /**
  49167. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49168. */
  49169. forceAlphaTest: boolean;
  49170. /**
  49171. * Defines the alpha limits in alpha test mode.
  49172. */
  49173. alphaCutOff: number;
  49174. /**
  49175. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49176. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49177. */
  49178. useSpecularOverAlpha: boolean;
  49179. /**
  49180. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49181. */
  49182. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49183. /**
  49184. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49185. */
  49186. useRoughnessFromMetallicTextureAlpha: boolean;
  49187. /**
  49188. * Specifies if the metallic texture contains the roughness information in its green channel.
  49189. */
  49190. useRoughnessFromMetallicTextureGreen: boolean;
  49191. /**
  49192. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49193. */
  49194. useMetallnessFromMetallicTextureBlue: boolean;
  49195. /**
  49196. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49197. */
  49198. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49199. /**
  49200. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49201. */
  49202. useAmbientInGrayScale: boolean;
  49203. /**
  49204. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49205. * The material will try to infer what glossiness each pixel should be.
  49206. */
  49207. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49208. /**
  49209. * BJS is using an harcoded light falloff based on a manually sets up range.
  49210. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49211. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49212. */
  49213. /**
  49214. * BJS is using an harcoded light falloff based on a manually sets up range.
  49215. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49216. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49217. */
  49218. usePhysicalLightFalloff: boolean;
  49219. /**
  49220. * In order to support the falloff compatibility with gltf, a special mode has been added
  49221. * to reproduce the gltf light falloff.
  49222. */
  49223. /**
  49224. * In order to support the falloff compatibility with gltf, a special mode has been added
  49225. * to reproduce the gltf light falloff.
  49226. */
  49227. useGLTFLightFalloff: boolean;
  49228. /**
  49229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49231. */
  49232. useRadianceOverAlpha: boolean;
  49233. /**
  49234. * Allows using an object space normal map (instead of tangent space).
  49235. */
  49236. useObjectSpaceNormalMap: boolean;
  49237. /**
  49238. * Allows using the bump map in parallax mode.
  49239. */
  49240. useParallax: boolean;
  49241. /**
  49242. * Allows using the bump map in parallax occlusion mode.
  49243. */
  49244. useParallaxOcclusion: boolean;
  49245. /**
  49246. * Controls the scale bias of the parallax mode.
  49247. */
  49248. parallaxScaleBias: number;
  49249. /**
  49250. * If sets to true, disables all the lights affecting the material.
  49251. */
  49252. disableLighting: boolean;
  49253. /**
  49254. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49255. */
  49256. forceIrradianceInFragment: boolean;
  49257. /**
  49258. * Number of Simultaneous lights allowed on the material.
  49259. */
  49260. maxSimultaneousLights: number;
  49261. /**
  49262. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49263. */
  49264. invertNormalMapX: boolean;
  49265. /**
  49266. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49267. */
  49268. invertNormalMapY: boolean;
  49269. /**
  49270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49271. */
  49272. twoSidedLighting: boolean;
  49273. /**
  49274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49275. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49276. */
  49277. useAlphaFresnel: boolean;
  49278. /**
  49279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49280. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49281. */
  49282. useLinearAlphaFresnel: boolean;
  49283. /**
  49284. * Let user defines the brdf lookup texture used for IBL.
  49285. * A default 8bit version is embedded but you could point at :
  49286. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49287. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49288. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49289. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49290. */
  49291. environmentBRDFTexture: Nullable<BaseTexture>;
  49292. /**
  49293. * Force normal to face away from face.
  49294. */
  49295. forceNormalForward: boolean;
  49296. /**
  49297. * Enables specular anti aliasing in the PBR shader.
  49298. * It will both interacts on the Geometry for analytical and IBL lighting.
  49299. * It also prefilter the roughness map based on the bump values.
  49300. */
  49301. enableSpecularAntiAliasing: boolean;
  49302. /**
  49303. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49304. * makes the reflect vector face the model (under horizon).
  49305. */
  49306. useHorizonOcclusion: boolean;
  49307. /**
  49308. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49309. * too much the area relying on ambient texture to define their ambient occlusion.
  49310. */
  49311. useRadianceOcclusion: boolean;
  49312. /**
  49313. * If set to true, no lighting calculations will be applied.
  49314. */
  49315. unlit: boolean;
  49316. /**
  49317. * Gets the image processing configuration used either in this material.
  49318. */
  49319. /**
  49320. * Sets the Default image processing configuration used either in the this material.
  49321. *
  49322. * If sets to null, the scene one is in use.
  49323. */
  49324. imageProcessingConfiguration: ImageProcessingConfiguration;
  49325. /**
  49326. * Gets wether the color curves effect is enabled.
  49327. */
  49328. /**
  49329. * Sets wether the color curves effect is enabled.
  49330. */
  49331. cameraColorCurvesEnabled: boolean;
  49332. /**
  49333. * Gets wether the color grading effect is enabled.
  49334. */
  49335. /**
  49336. * Gets wether the color grading effect is enabled.
  49337. */
  49338. cameraColorGradingEnabled: boolean;
  49339. /**
  49340. * Gets wether tonemapping is enabled or not.
  49341. */
  49342. /**
  49343. * Sets wether tonemapping is enabled or not
  49344. */
  49345. cameraToneMappingEnabled: boolean;
  49346. /**
  49347. * The camera exposure used on this material.
  49348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49349. * This corresponds to a photographic exposure.
  49350. */
  49351. /**
  49352. * The camera exposure used on this material.
  49353. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49354. * This corresponds to a photographic exposure.
  49355. */
  49356. cameraExposure: number;
  49357. /**
  49358. * Gets The camera contrast used on this material.
  49359. */
  49360. /**
  49361. * Sets The camera contrast used on this material.
  49362. */
  49363. cameraContrast: number;
  49364. /**
  49365. * Gets the Color Grading 2D Lookup Texture.
  49366. */
  49367. /**
  49368. * Sets the Color Grading 2D Lookup Texture.
  49369. */
  49370. cameraColorGradingTexture: Nullable<BaseTexture>;
  49371. /**
  49372. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49373. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49374. * 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;
  49375. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49376. */
  49377. /**
  49378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49380. * 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;
  49381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49382. */
  49383. cameraColorCurves: Nullable<ColorCurves>;
  49384. /**
  49385. * Instantiates a new PBRMaterial instance.
  49386. *
  49387. * @param name The material name
  49388. * @param scene The scene the material will be use in.
  49389. */
  49390. constructor(name: string, scene: Scene);
  49391. /**
  49392. * Returns the name of this material class.
  49393. */
  49394. getClassName(): string;
  49395. /**
  49396. * Makes a duplicate of the current material.
  49397. * @param name - name to use for the new material.
  49398. */
  49399. clone(name: string): PBRMaterial;
  49400. /**
  49401. * Serializes this PBR Material.
  49402. * @returns - An object with the serialized material.
  49403. */
  49404. serialize(): any;
  49405. /**
  49406. * Parses a PBR Material from a serialized object.
  49407. * @param source - Serialized object.
  49408. * @param scene - BJS scene instance.
  49409. * @param rootUrl - url for the scene object
  49410. * @returns - PBRMaterial
  49411. */
  49412. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49413. }
  49414. }
  49415. declare module "babylonjs/Misc/dds" {
  49416. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49417. import { Engine } from "babylonjs/Engines/engine";
  49418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49419. import { Nullable } from "babylonjs/types";
  49420. import { Scene } from "babylonjs/scene";
  49421. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49422. /**
  49423. * Direct draw surface info
  49424. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49425. */
  49426. export interface DDSInfo {
  49427. /**
  49428. * Width of the texture
  49429. */
  49430. width: number;
  49431. /**
  49432. * Width of the texture
  49433. */
  49434. height: number;
  49435. /**
  49436. * Number of Mipmaps for the texture
  49437. * @see https://en.wikipedia.org/wiki/Mipmap
  49438. */
  49439. mipmapCount: number;
  49440. /**
  49441. * If the textures format is a known fourCC format
  49442. * @see https://www.fourcc.org/
  49443. */
  49444. isFourCC: boolean;
  49445. /**
  49446. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49447. */
  49448. isRGB: boolean;
  49449. /**
  49450. * If the texture is a lumincance format
  49451. */
  49452. isLuminance: boolean;
  49453. /**
  49454. * If this is a cube texture
  49455. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49456. */
  49457. isCube: boolean;
  49458. /**
  49459. * If the texture is a compressed format eg. FOURCC_DXT1
  49460. */
  49461. isCompressed: boolean;
  49462. /**
  49463. * The dxgiFormat of the texture
  49464. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49465. */
  49466. dxgiFormat: number;
  49467. /**
  49468. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49469. */
  49470. textureType: number;
  49471. /**
  49472. * Sphericle polynomial created for the dds texture
  49473. */
  49474. sphericalPolynomial?: SphericalPolynomial;
  49475. }
  49476. /**
  49477. * Class used to provide DDS decompression tools
  49478. */
  49479. export class DDSTools {
  49480. /**
  49481. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49482. */
  49483. static StoreLODInAlphaChannel: boolean;
  49484. /**
  49485. * Gets DDS information from an array buffer
  49486. * @param arrayBuffer defines the array buffer to read data from
  49487. * @returns the DDS information
  49488. */
  49489. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49490. private static _FloatView;
  49491. private static _Int32View;
  49492. private static _ToHalfFloat;
  49493. private static _FromHalfFloat;
  49494. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49495. private static _GetHalfFloatRGBAArrayBuffer;
  49496. private static _GetFloatRGBAArrayBuffer;
  49497. private static _GetFloatAsUIntRGBAArrayBuffer;
  49498. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49499. private static _GetRGBAArrayBuffer;
  49500. private static _ExtractLongWordOrder;
  49501. private static _GetRGBArrayBuffer;
  49502. private static _GetLuminanceArrayBuffer;
  49503. /**
  49504. * Uploads DDS Levels to a Babylon Texture
  49505. * @hidden
  49506. */
  49507. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49508. }
  49509. module "babylonjs/Engines/engine" {
  49510. interface Engine {
  49511. /**
  49512. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49513. * @param rootUrl defines the url where the file to load is located
  49514. * @param scene defines the current scene
  49515. * @param lodScale defines scale to apply to the mip map selection
  49516. * @param lodOffset defines offset to apply to the mip map selection
  49517. * @param onLoad defines an optional callback raised when the texture is loaded
  49518. * @param onError defines an optional callback raised if there is an issue to load the texture
  49519. * @param format defines the format of the data
  49520. * @param forcedExtension defines the extension to use to pick the right loader
  49521. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49522. * @returns the cube texture as an InternalTexture
  49523. */
  49524. 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;
  49525. }
  49526. }
  49527. }
  49528. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49529. import { Nullable } from "babylonjs/types";
  49530. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49531. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49532. /**
  49533. * Implementation of the DDS Texture Loader.
  49534. * @hidden
  49535. */
  49536. export class _DDSTextureLoader implements IInternalTextureLoader {
  49537. /**
  49538. * Defines wether the loader supports cascade loading the different faces.
  49539. */
  49540. readonly supportCascades: boolean;
  49541. /**
  49542. * This returns if the loader support the current file information.
  49543. * @param extension defines the file extension of the file being loaded
  49544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49545. * @param fallback defines the fallback internal texture if any
  49546. * @param isBase64 defines whether the texture is encoded as a base64
  49547. * @param isBuffer defines whether the texture data are stored as a buffer
  49548. * @returns true if the loader can load the specified file
  49549. */
  49550. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49551. /**
  49552. * Transform the url before loading if required.
  49553. * @param rootUrl the url of the texture
  49554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49555. * @returns the transformed texture
  49556. */
  49557. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49558. /**
  49559. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49560. * @param rootUrl the url of the texture
  49561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49562. * @returns the fallback texture
  49563. */
  49564. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49565. /**
  49566. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49567. * @param data contains the texture data
  49568. * @param texture defines the BabylonJS internal texture
  49569. * @param createPolynomials will be true if polynomials have been requested
  49570. * @param onLoad defines the callback to trigger once the texture is ready
  49571. * @param onError defines the callback to trigger in case of error
  49572. */
  49573. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49574. /**
  49575. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49576. * @param data contains the texture data
  49577. * @param texture defines the BabylonJS internal texture
  49578. * @param callback defines the method to call once ready to upload
  49579. */
  49580. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49581. }
  49582. }
  49583. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49585. /** @hidden */
  49586. export var rgbdEncodePixelShader: {
  49587. name: string;
  49588. shader: string;
  49589. };
  49590. }
  49591. declare module "babylonjs/Misc/environmentTextureTools" {
  49592. import { Nullable } from "babylonjs/types";
  49593. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49595. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49596. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49597. import "babylonjs/Shaders/rgbdEncode.fragment";
  49598. import "babylonjs/Shaders/rgbdDecode.fragment";
  49599. /**
  49600. * Raw texture data and descriptor sufficient for WebGL texture upload
  49601. */
  49602. export interface EnvironmentTextureInfo {
  49603. /**
  49604. * Version of the environment map
  49605. */
  49606. version: number;
  49607. /**
  49608. * Width of image
  49609. */
  49610. width: number;
  49611. /**
  49612. * Irradiance information stored in the file.
  49613. */
  49614. irradiance: any;
  49615. /**
  49616. * Specular information stored in the file.
  49617. */
  49618. specular: any;
  49619. }
  49620. /**
  49621. * Sets of helpers addressing the serialization and deserialization of environment texture
  49622. * stored in a BabylonJS env file.
  49623. * Those files are usually stored as .env files.
  49624. */
  49625. export class EnvironmentTextureTools {
  49626. /**
  49627. * Magic number identifying the env file.
  49628. */
  49629. private static _MagicBytes;
  49630. /**
  49631. * Gets the environment info from an env file.
  49632. * @param data The array buffer containing the .env bytes.
  49633. * @returns the environment file info (the json header) if successfully parsed.
  49634. */
  49635. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49636. /**
  49637. * Creates an environment texture from a loaded cube texture.
  49638. * @param texture defines the cube texture to convert in env file
  49639. * @return a promise containing the environment data if succesfull.
  49640. */
  49641. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49642. /**
  49643. * Creates a JSON representation of the spherical data.
  49644. * @param texture defines the texture containing the polynomials
  49645. * @return the JSON representation of the spherical info
  49646. */
  49647. private static _CreateEnvTextureIrradiance;
  49648. /**
  49649. * Uploads the texture info contained in the env file to the GPU.
  49650. * @param texture defines the internal texture to upload to
  49651. * @param arrayBuffer defines the buffer cotaining the data to load
  49652. * @param info defines the texture info retrieved through the GetEnvInfo method
  49653. * @returns a promise
  49654. */
  49655. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49656. /**
  49657. * Uploads the levels of image data to the GPU.
  49658. * @param texture defines the internal texture to upload to
  49659. * @param imageData defines the array buffer views of image data [mipmap][face]
  49660. * @returns a promise
  49661. */
  49662. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49663. /**
  49664. * Uploads spherical polynomials information to the texture.
  49665. * @param texture defines the texture we are trying to upload the information to
  49666. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49667. */
  49668. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49669. /** @hidden */
  49670. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49671. }
  49672. }
  49673. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49674. import { Nullable } from "babylonjs/types";
  49675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49676. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49677. /**
  49678. * Implementation of the ENV Texture Loader.
  49679. * @hidden
  49680. */
  49681. export class _ENVTextureLoader implements IInternalTextureLoader {
  49682. /**
  49683. * Defines wether the loader supports cascade loading the different faces.
  49684. */
  49685. readonly supportCascades: boolean;
  49686. /**
  49687. * This returns if the loader support the current file information.
  49688. * @param extension defines the file extension of the file being loaded
  49689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49690. * @param fallback defines the fallback internal texture if any
  49691. * @param isBase64 defines whether the texture is encoded as a base64
  49692. * @param isBuffer defines whether the texture data are stored as a buffer
  49693. * @returns true if the loader can load the specified file
  49694. */
  49695. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49696. /**
  49697. * Transform the url before loading if required.
  49698. * @param rootUrl the url of the texture
  49699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49700. * @returns the transformed texture
  49701. */
  49702. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49703. /**
  49704. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49705. * @param rootUrl the url of the texture
  49706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49707. * @returns the fallback texture
  49708. */
  49709. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49710. /**
  49711. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49712. * @param data contains the texture data
  49713. * @param texture defines the BabylonJS internal texture
  49714. * @param createPolynomials will be true if polynomials have been requested
  49715. * @param onLoad defines the callback to trigger once the texture is ready
  49716. * @param onError defines the callback to trigger in case of error
  49717. */
  49718. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49719. /**
  49720. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49721. * @param data contains the texture data
  49722. * @param texture defines the BabylonJS internal texture
  49723. * @param callback defines the method to call once ready to upload
  49724. */
  49725. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49726. }
  49727. }
  49728. declare module "babylonjs/Misc/khronosTextureContainer" {
  49729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49730. /**
  49731. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49732. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49733. */
  49734. export class KhronosTextureContainer {
  49735. /** contents of the KTX container file */
  49736. arrayBuffer: any;
  49737. private static HEADER_LEN;
  49738. private static COMPRESSED_2D;
  49739. private static COMPRESSED_3D;
  49740. private static TEX_2D;
  49741. private static TEX_3D;
  49742. /**
  49743. * Gets the openGL type
  49744. */
  49745. glType: number;
  49746. /**
  49747. * Gets the openGL type size
  49748. */
  49749. glTypeSize: number;
  49750. /**
  49751. * Gets the openGL format
  49752. */
  49753. glFormat: number;
  49754. /**
  49755. * Gets the openGL internal format
  49756. */
  49757. glInternalFormat: number;
  49758. /**
  49759. * Gets the base internal format
  49760. */
  49761. glBaseInternalFormat: number;
  49762. /**
  49763. * Gets image width in pixel
  49764. */
  49765. pixelWidth: number;
  49766. /**
  49767. * Gets image height in pixel
  49768. */
  49769. pixelHeight: number;
  49770. /**
  49771. * Gets image depth in pixels
  49772. */
  49773. pixelDepth: number;
  49774. /**
  49775. * Gets the number of array elements
  49776. */
  49777. numberOfArrayElements: number;
  49778. /**
  49779. * Gets the number of faces
  49780. */
  49781. numberOfFaces: number;
  49782. /**
  49783. * Gets the number of mipmap levels
  49784. */
  49785. numberOfMipmapLevels: number;
  49786. /**
  49787. * Gets the bytes of key value data
  49788. */
  49789. bytesOfKeyValueData: number;
  49790. /**
  49791. * Gets the load type
  49792. */
  49793. loadType: number;
  49794. /**
  49795. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49796. */
  49797. isInvalid: boolean;
  49798. /**
  49799. * Creates a new KhronosTextureContainer
  49800. * @param arrayBuffer contents of the KTX container file
  49801. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49802. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49803. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49804. */
  49805. constructor(
  49806. /** contents of the KTX container file */
  49807. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49808. /**
  49809. * Uploads KTX content to a Babylon Texture.
  49810. * It is assumed that the texture has already been created & is currently bound
  49811. * @hidden
  49812. */
  49813. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49814. private _upload2DCompressedLevels;
  49815. }
  49816. }
  49817. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49818. import { Nullable } from "babylonjs/types";
  49819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49820. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49821. /**
  49822. * Implementation of the KTX Texture Loader.
  49823. * @hidden
  49824. */
  49825. export class _KTXTextureLoader implements IInternalTextureLoader {
  49826. /**
  49827. * Defines wether the loader supports cascade loading the different faces.
  49828. */
  49829. readonly supportCascades: boolean;
  49830. /**
  49831. * This returns if the loader support the current file information.
  49832. * @param extension defines the file extension of the file being loaded
  49833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49834. * @param fallback defines the fallback internal texture if any
  49835. * @param isBase64 defines whether the texture is encoded as a base64
  49836. * @param isBuffer defines whether the texture data are stored as a buffer
  49837. * @returns true if the loader can load the specified file
  49838. */
  49839. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49840. /**
  49841. * Transform the url before loading if required.
  49842. * @param rootUrl the url of the texture
  49843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49844. * @returns the transformed texture
  49845. */
  49846. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49847. /**
  49848. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49849. * @param rootUrl the url of the texture
  49850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49851. * @returns the fallback texture
  49852. */
  49853. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49854. /**
  49855. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49856. * @param data contains the texture data
  49857. * @param texture defines the BabylonJS internal texture
  49858. * @param createPolynomials will be true if polynomials have been requested
  49859. * @param onLoad defines the callback to trigger once the texture is ready
  49860. * @param onError defines the callback to trigger in case of error
  49861. */
  49862. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49863. /**
  49864. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49865. * @param data contains the texture data
  49866. * @param texture defines the BabylonJS internal texture
  49867. * @param callback defines the method to call once ready to upload
  49868. */
  49869. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49870. }
  49871. }
  49872. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49873. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49874. import { Scene } from "babylonjs/scene";
  49875. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49876. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49877. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49878. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49879. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49880. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49882. /**
  49883. * Options for the default xr helper
  49884. */
  49885. export class WebXRDefaultExperienceOptions {
  49886. /**
  49887. * Floor meshes that should be used for teleporting
  49888. */
  49889. floorMeshes: Array<AbstractMesh>;
  49890. }
  49891. /**
  49892. * Default experience which provides a similar setup to the previous webVRExperience
  49893. */
  49894. export class WebXRDefaultExperience {
  49895. /**
  49896. * Base experience
  49897. */
  49898. baseExperience: WebXRExperienceHelper;
  49899. /**
  49900. * Input experience extension
  49901. */
  49902. input: WebXRInput;
  49903. /**
  49904. * Loads the controller models
  49905. */
  49906. controllerModelLoader: WebXRControllerModelLoader;
  49907. /**
  49908. * Enables laser pointer and selection
  49909. */
  49910. pointerSelection: WebXRControllerPointerSelection;
  49911. /**
  49912. * Enables teleportation
  49913. */
  49914. teleportation: WebXRControllerTeleportation;
  49915. /**
  49916. * Enables ui for enetering/exiting xr
  49917. */
  49918. enterExitUI: WebXREnterExitUI;
  49919. /**
  49920. * Default output canvas xr should render to
  49921. */
  49922. outputCanvas: WebXRManagedOutputCanvas;
  49923. /**
  49924. * Creates the default xr experience
  49925. * @param scene scene
  49926. * @param options options for basic configuration
  49927. * @returns resulting WebXRDefaultExperience
  49928. */
  49929. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49930. private constructor();
  49931. /**
  49932. * DIsposes of the experience helper
  49933. */
  49934. dispose(): void;
  49935. }
  49936. }
  49937. declare module "babylonjs/Helpers/sceneHelpers" {
  49938. import { Nullable } from "babylonjs/types";
  49939. import { Mesh } from "babylonjs/Meshes/mesh";
  49940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49941. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49942. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49943. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49944. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49945. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49946. import "babylonjs/Meshes/Builders/boxBuilder";
  49947. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49948. /** @hidden */
  49949. export var _forceSceneHelpersToBundle: boolean;
  49950. module "babylonjs/scene" {
  49951. interface Scene {
  49952. /**
  49953. * Creates a default light for the scene.
  49954. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49955. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49956. */
  49957. createDefaultLight(replace?: boolean): void;
  49958. /**
  49959. * Creates a default camera for the scene.
  49960. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49961. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49962. * @param replace has default false, when true replaces the active camera in the scene
  49963. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49964. */
  49965. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49966. /**
  49967. * Creates a default camera and a default light.
  49968. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49969. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49970. * @param replace has the default false, when true replaces the active camera/light in the scene
  49971. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49972. */
  49973. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49974. /**
  49975. * Creates a new sky box
  49976. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49977. * @param environmentTexture defines the texture to use as environment texture
  49978. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49979. * @param scale defines the overall scale of the skybox
  49980. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49981. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49982. * @returns a new mesh holding the sky box
  49983. */
  49984. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49985. /**
  49986. * Creates a new environment
  49987. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49988. * @param options defines the options you can use to configure the environment
  49989. * @returns the new EnvironmentHelper
  49990. */
  49991. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49992. /**
  49993. * Creates a new VREXperienceHelper
  49994. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49995. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49996. * @returns a new VREXperienceHelper
  49997. */
  49998. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49999. /**
  50000. * Creates a new WebXRDefaultExperience
  50001. * @see http://doc.babylonjs.com/how_to/webxr
  50002. * @param options experience options
  50003. * @returns a promise for a new WebXRDefaultExperience
  50004. */
  50005. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50006. }
  50007. }
  50008. }
  50009. declare module "babylonjs/Maths/math.vertexFormat" {
  50010. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50011. /**
  50012. * Contains position and normal vectors for a vertex
  50013. */
  50014. export class PositionNormalVertex {
  50015. /** the position of the vertex (defaut: 0,0,0) */
  50016. position: Vector3;
  50017. /** the normal of the vertex (defaut: 0,1,0) */
  50018. normal: Vector3;
  50019. /**
  50020. * Creates a PositionNormalVertex
  50021. * @param position the position of the vertex (defaut: 0,0,0)
  50022. * @param normal the normal of the vertex (defaut: 0,1,0)
  50023. */
  50024. constructor(
  50025. /** the position of the vertex (defaut: 0,0,0) */
  50026. position?: Vector3,
  50027. /** the normal of the vertex (defaut: 0,1,0) */
  50028. normal?: Vector3);
  50029. /**
  50030. * Clones the PositionNormalVertex
  50031. * @returns the cloned PositionNormalVertex
  50032. */
  50033. clone(): PositionNormalVertex;
  50034. }
  50035. /**
  50036. * Contains position, normal and uv vectors for a vertex
  50037. */
  50038. export class PositionNormalTextureVertex {
  50039. /** the position of the vertex (defaut: 0,0,0) */
  50040. position: Vector3;
  50041. /** the normal of the vertex (defaut: 0,1,0) */
  50042. normal: Vector3;
  50043. /** the uv of the vertex (default: 0,0) */
  50044. uv: Vector2;
  50045. /**
  50046. * Creates a PositionNormalTextureVertex
  50047. * @param position the position of the vertex (defaut: 0,0,0)
  50048. * @param normal the normal of the vertex (defaut: 0,1,0)
  50049. * @param uv the uv of the vertex (default: 0,0)
  50050. */
  50051. constructor(
  50052. /** the position of the vertex (defaut: 0,0,0) */
  50053. position?: Vector3,
  50054. /** the normal of the vertex (defaut: 0,1,0) */
  50055. normal?: Vector3,
  50056. /** the uv of the vertex (default: 0,0) */
  50057. uv?: Vector2);
  50058. /**
  50059. * Clones the PositionNormalTextureVertex
  50060. * @returns the cloned PositionNormalTextureVertex
  50061. */
  50062. clone(): PositionNormalTextureVertex;
  50063. }
  50064. }
  50065. declare module "babylonjs/Maths/math" {
  50066. export * from "babylonjs/Maths/math.axis";
  50067. export * from "babylonjs/Maths/math.color";
  50068. export * from "babylonjs/Maths/math.constants";
  50069. export * from "babylonjs/Maths/math.frustum";
  50070. export * from "babylonjs/Maths/math.path";
  50071. export * from "babylonjs/Maths/math.plane";
  50072. export * from "babylonjs/Maths/math.size";
  50073. export * from "babylonjs/Maths/math.vector";
  50074. export * from "babylonjs/Maths/math.vertexFormat";
  50075. export * from "babylonjs/Maths/math.viewport";
  50076. }
  50077. declare module "babylonjs/Helpers/videoDome" {
  50078. import { Scene } from "babylonjs/scene";
  50079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50080. import { Mesh } from "babylonjs/Meshes/mesh";
  50081. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50082. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50083. import "babylonjs/Meshes/Builders/sphereBuilder";
  50084. /**
  50085. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50086. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50087. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50088. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50089. */
  50090. export class VideoDome extends TransformNode {
  50091. /**
  50092. * Define the video source as a Monoscopic panoramic 360 video.
  50093. */
  50094. static readonly MODE_MONOSCOPIC: number;
  50095. /**
  50096. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50097. */
  50098. static readonly MODE_TOPBOTTOM: number;
  50099. /**
  50100. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50101. */
  50102. static readonly MODE_SIDEBYSIDE: number;
  50103. private _halfDome;
  50104. private _useDirectMapping;
  50105. /**
  50106. * The video texture being displayed on the sphere
  50107. */
  50108. protected _videoTexture: VideoTexture;
  50109. /**
  50110. * Gets the video texture being displayed on the sphere
  50111. */
  50112. readonly videoTexture: VideoTexture;
  50113. /**
  50114. * The skybox material
  50115. */
  50116. protected _material: BackgroundMaterial;
  50117. /**
  50118. * The surface used for the skybox
  50119. */
  50120. protected _mesh: Mesh;
  50121. /**
  50122. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50123. */
  50124. private _halfDomeMask;
  50125. /**
  50126. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50127. * Also see the options.resolution property.
  50128. */
  50129. fovMultiplier: number;
  50130. private _videoMode;
  50131. /**
  50132. * Gets or set the current video mode for the video. It can be:
  50133. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50134. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50135. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50136. */
  50137. videoMode: number;
  50138. /**
  50139. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50140. *
  50141. */
  50142. /**
  50143. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50144. */
  50145. halfDome: boolean;
  50146. /**
  50147. * Oberserver used in Stereoscopic VR Mode.
  50148. */
  50149. private _onBeforeCameraRenderObserver;
  50150. /**
  50151. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50152. * @param name Element's name, child elements will append suffixes for their own names.
  50153. * @param urlsOrVideo defines the url(s) or the video element to use
  50154. * @param options An object containing optional or exposed sub element properties
  50155. */
  50156. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50157. resolution?: number;
  50158. clickToPlay?: boolean;
  50159. autoPlay?: boolean;
  50160. loop?: boolean;
  50161. size?: number;
  50162. poster?: string;
  50163. faceForward?: boolean;
  50164. useDirectMapping?: boolean;
  50165. halfDomeMode?: boolean;
  50166. }, scene: Scene);
  50167. private _changeVideoMode;
  50168. /**
  50169. * Releases resources associated with this node.
  50170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50172. */
  50173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50174. }
  50175. }
  50176. declare module "babylonjs/Helpers/index" {
  50177. export * from "babylonjs/Helpers/environmentHelper";
  50178. export * from "babylonjs/Helpers/photoDome";
  50179. export * from "babylonjs/Helpers/sceneHelpers";
  50180. export * from "babylonjs/Helpers/videoDome";
  50181. }
  50182. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50183. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50184. import { IDisposable } from "babylonjs/scene";
  50185. import { Engine } from "babylonjs/Engines/engine";
  50186. /**
  50187. * This class can be used to get instrumentation data from a Babylon engine
  50188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50189. */
  50190. export class EngineInstrumentation implements IDisposable {
  50191. /**
  50192. * Define the instrumented engine.
  50193. */
  50194. engine: Engine;
  50195. private _captureGPUFrameTime;
  50196. private _gpuFrameTimeToken;
  50197. private _gpuFrameTime;
  50198. private _captureShaderCompilationTime;
  50199. private _shaderCompilationTime;
  50200. private _onBeginFrameObserver;
  50201. private _onEndFrameObserver;
  50202. private _onBeforeShaderCompilationObserver;
  50203. private _onAfterShaderCompilationObserver;
  50204. /**
  50205. * Gets the perf counter used for GPU frame time
  50206. */
  50207. readonly gpuFrameTimeCounter: PerfCounter;
  50208. /**
  50209. * Gets the GPU frame time capture status
  50210. */
  50211. /**
  50212. * Enable or disable the GPU frame time capture
  50213. */
  50214. captureGPUFrameTime: boolean;
  50215. /**
  50216. * Gets the perf counter used for shader compilation time
  50217. */
  50218. readonly shaderCompilationTimeCounter: PerfCounter;
  50219. /**
  50220. * Gets the shader compilation time capture status
  50221. */
  50222. /**
  50223. * Enable or disable the shader compilation time capture
  50224. */
  50225. captureShaderCompilationTime: boolean;
  50226. /**
  50227. * Instantiates a new engine instrumentation.
  50228. * This class can be used to get instrumentation data from a Babylon engine
  50229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50230. * @param engine Defines the engine to instrument
  50231. */
  50232. constructor(
  50233. /**
  50234. * Define the instrumented engine.
  50235. */
  50236. engine: Engine);
  50237. /**
  50238. * Dispose and release associated resources.
  50239. */
  50240. dispose(): void;
  50241. }
  50242. }
  50243. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50244. import { Scene, IDisposable } from "babylonjs/scene";
  50245. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50246. /**
  50247. * This class can be used to get instrumentation data from a Babylon engine
  50248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50249. */
  50250. export class SceneInstrumentation implements IDisposable {
  50251. /**
  50252. * Defines the scene to instrument
  50253. */
  50254. scene: Scene;
  50255. private _captureActiveMeshesEvaluationTime;
  50256. private _activeMeshesEvaluationTime;
  50257. private _captureRenderTargetsRenderTime;
  50258. private _renderTargetsRenderTime;
  50259. private _captureFrameTime;
  50260. private _frameTime;
  50261. private _captureRenderTime;
  50262. private _renderTime;
  50263. private _captureInterFrameTime;
  50264. private _interFrameTime;
  50265. private _captureParticlesRenderTime;
  50266. private _particlesRenderTime;
  50267. private _captureSpritesRenderTime;
  50268. private _spritesRenderTime;
  50269. private _capturePhysicsTime;
  50270. private _physicsTime;
  50271. private _captureAnimationsTime;
  50272. private _animationsTime;
  50273. private _captureCameraRenderTime;
  50274. private _cameraRenderTime;
  50275. private _onBeforeActiveMeshesEvaluationObserver;
  50276. private _onAfterActiveMeshesEvaluationObserver;
  50277. private _onBeforeRenderTargetsRenderObserver;
  50278. private _onAfterRenderTargetsRenderObserver;
  50279. private _onAfterRenderObserver;
  50280. private _onBeforeDrawPhaseObserver;
  50281. private _onAfterDrawPhaseObserver;
  50282. private _onBeforeAnimationsObserver;
  50283. private _onBeforeParticlesRenderingObserver;
  50284. private _onAfterParticlesRenderingObserver;
  50285. private _onBeforeSpritesRenderingObserver;
  50286. private _onAfterSpritesRenderingObserver;
  50287. private _onBeforePhysicsObserver;
  50288. private _onAfterPhysicsObserver;
  50289. private _onAfterAnimationsObserver;
  50290. private _onBeforeCameraRenderObserver;
  50291. private _onAfterCameraRenderObserver;
  50292. /**
  50293. * Gets the perf counter used for active meshes evaluation time
  50294. */
  50295. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50296. /**
  50297. * Gets the active meshes evaluation time capture status
  50298. */
  50299. /**
  50300. * Enable or disable the active meshes evaluation time capture
  50301. */
  50302. captureActiveMeshesEvaluationTime: boolean;
  50303. /**
  50304. * Gets the perf counter used for render targets render time
  50305. */
  50306. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50307. /**
  50308. * Gets the render targets render time capture status
  50309. */
  50310. /**
  50311. * Enable or disable the render targets render time capture
  50312. */
  50313. captureRenderTargetsRenderTime: boolean;
  50314. /**
  50315. * Gets the perf counter used for particles render time
  50316. */
  50317. readonly particlesRenderTimeCounter: PerfCounter;
  50318. /**
  50319. * Gets the particles render time capture status
  50320. */
  50321. /**
  50322. * Enable or disable the particles render time capture
  50323. */
  50324. captureParticlesRenderTime: boolean;
  50325. /**
  50326. * Gets the perf counter used for sprites render time
  50327. */
  50328. readonly spritesRenderTimeCounter: PerfCounter;
  50329. /**
  50330. * Gets the sprites render time capture status
  50331. */
  50332. /**
  50333. * Enable or disable the sprites render time capture
  50334. */
  50335. captureSpritesRenderTime: boolean;
  50336. /**
  50337. * Gets the perf counter used for physics time
  50338. */
  50339. readonly physicsTimeCounter: PerfCounter;
  50340. /**
  50341. * Gets the physics time capture status
  50342. */
  50343. /**
  50344. * Enable or disable the physics time capture
  50345. */
  50346. capturePhysicsTime: boolean;
  50347. /**
  50348. * Gets the perf counter used for animations time
  50349. */
  50350. readonly animationsTimeCounter: PerfCounter;
  50351. /**
  50352. * Gets the animations time capture status
  50353. */
  50354. /**
  50355. * Enable or disable the animations time capture
  50356. */
  50357. captureAnimationsTime: boolean;
  50358. /**
  50359. * Gets the perf counter used for frame time capture
  50360. */
  50361. readonly frameTimeCounter: PerfCounter;
  50362. /**
  50363. * Gets the frame time capture status
  50364. */
  50365. /**
  50366. * Enable or disable the frame time capture
  50367. */
  50368. captureFrameTime: boolean;
  50369. /**
  50370. * Gets the perf counter used for inter-frames time capture
  50371. */
  50372. readonly interFrameTimeCounter: PerfCounter;
  50373. /**
  50374. * Gets the inter-frames time capture status
  50375. */
  50376. /**
  50377. * Enable or disable the inter-frames time capture
  50378. */
  50379. captureInterFrameTime: boolean;
  50380. /**
  50381. * Gets the perf counter used for render time capture
  50382. */
  50383. readonly renderTimeCounter: PerfCounter;
  50384. /**
  50385. * Gets the render time capture status
  50386. */
  50387. /**
  50388. * Enable or disable the render time capture
  50389. */
  50390. captureRenderTime: boolean;
  50391. /**
  50392. * Gets the perf counter used for camera render time capture
  50393. */
  50394. readonly cameraRenderTimeCounter: PerfCounter;
  50395. /**
  50396. * Gets the camera render time capture status
  50397. */
  50398. /**
  50399. * Enable or disable the camera render time capture
  50400. */
  50401. captureCameraRenderTime: boolean;
  50402. /**
  50403. * Gets the perf counter used for draw calls
  50404. */
  50405. readonly drawCallsCounter: PerfCounter;
  50406. /**
  50407. * Instantiates a new scene instrumentation.
  50408. * This class can be used to get instrumentation data from a Babylon engine
  50409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50410. * @param scene Defines the scene to instrument
  50411. */
  50412. constructor(
  50413. /**
  50414. * Defines the scene to instrument
  50415. */
  50416. scene: Scene);
  50417. /**
  50418. * Dispose and release associated resources.
  50419. */
  50420. dispose(): void;
  50421. }
  50422. }
  50423. declare module "babylonjs/Instrumentation/index" {
  50424. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50425. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50426. export * from "babylonjs/Instrumentation/timeToken";
  50427. }
  50428. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50429. /** @hidden */
  50430. export var glowMapGenerationPixelShader: {
  50431. name: string;
  50432. shader: string;
  50433. };
  50434. }
  50435. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50436. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50437. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50439. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50441. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50442. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50443. /** @hidden */
  50444. export var glowMapGenerationVertexShader: {
  50445. name: string;
  50446. shader: string;
  50447. };
  50448. }
  50449. declare module "babylonjs/Layers/effectLayer" {
  50450. import { Observable } from "babylonjs/Misc/observable";
  50451. import { Nullable } from "babylonjs/types";
  50452. import { Camera } from "babylonjs/Cameras/camera";
  50453. import { Scene } from "babylonjs/scene";
  50454. import { ISize } from "babylonjs/Maths/math.size";
  50455. import { Color4 } from "babylonjs/Maths/math.color";
  50456. import { Engine } from "babylonjs/Engines/engine";
  50457. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50459. import { Mesh } from "babylonjs/Meshes/mesh";
  50460. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50462. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50463. import { Effect } from "babylonjs/Materials/effect";
  50464. import { Material } from "babylonjs/Materials/material";
  50465. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50466. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50467. /**
  50468. * Effect layer options. This helps customizing the behaviour
  50469. * of the effect layer.
  50470. */
  50471. export interface IEffectLayerOptions {
  50472. /**
  50473. * Multiplication factor apply to the canvas size to compute the render target size
  50474. * used to generated the objects (the smaller the faster).
  50475. */
  50476. mainTextureRatio: number;
  50477. /**
  50478. * Enforces a fixed size texture to ensure effect stability across devices.
  50479. */
  50480. mainTextureFixedSize?: number;
  50481. /**
  50482. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50483. */
  50484. alphaBlendingMode: number;
  50485. /**
  50486. * The camera attached to the layer.
  50487. */
  50488. camera: Nullable<Camera>;
  50489. /**
  50490. * The rendering group to draw the layer in.
  50491. */
  50492. renderingGroupId: number;
  50493. }
  50494. /**
  50495. * The effect layer Helps adding post process effect blended with the main pass.
  50496. *
  50497. * This can be for instance use to generate glow or higlight effects on the scene.
  50498. *
  50499. * The effect layer class can not be used directly and is intented to inherited from to be
  50500. * customized per effects.
  50501. */
  50502. export abstract class EffectLayer {
  50503. private _vertexBuffers;
  50504. private _indexBuffer;
  50505. private _cachedDefines;
  50506. private _effectLayerMapGenerationEffect;
  50507. private _effectLayerOptions;
  50508. private _mergeEffect;
  50509. protected _scene: Scene;
  50510. protected _engine: Engine;
  50511. protected _maxSize: number;
  50512. protected _mainTextureDesiredSize: ISize;
  50513. protected _mainTexture: RenderTargetTexture;
  50514. protected _shouldRender: boolean;
  50515. protected _postProcesses: PostProcess[];
  50516. protected _textures: BaseTexture[];
  50517. protected _emissiveTextureAndColor: {
  50518. texture: Nullable<BaseTexture>;
  50519. color: Color4;
  50520. };
  50521. /**
  50522. * The name of the layer
  50523. */
  50524. name: string;
  50525. /**
  50526. * The clear color of the texture used to generate the glow map.
  50527. */
  50528. neutralColor: Color4;
  50529. /**
  50530. * Specifies wether the highlight layer is enabled or not.
  50531. */
  50532. isEnabled: boolean;
  50533. /**
  50534. * Gets the camera attached to the layer.
  50535. */
  50536. readonly camera: Nullable<Camera>;
  50537. /**
  50538. * Gets the rendering group id the layer should render in.
  50539. */
  50540. renderingGroupId: number;
  50541. /**
  50542. * An event triggered when the effect layer has been disposed.
  50543. */
  50544. onDisposeObservable: Observable<EffectLayer>;
  50545. /**
  50546. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50547. */
  50548. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50549. /**
  50550. * An event triggered when the generated texture is being merged in the scene.
  50551. */
  50552. onBeforeComposeObservable: Observable<EffectLayer>;
  50553. /**
  50554. * An event triggered when the generated texture has been merged in the scene.
  50555. */
  50556. onAfterComposeObservable: Observable<EffectLayer>;
  50557. /**
  50558. * An event triggered when the efffect layer changes its size.
  50559. */
  50560. onSizeChangedObservable: Observable<EffectLayer>;
  50561. /** @hidden */
  50562. static _SceneComponentInitialization: (scene: Scene) => void;
  50563. /**
  50564. * Instantiates a new effect Layer and references it in the scene.
  50565. * @param name The name of the layer
  50566. * @param scene The scene to use the layer in
  50567. */
  50568. constructor(
  50569. /** The Friendly of the effect in the scene */
  50570. name: string, scene: Scene);
  50571. /**
  50572. * Get the effect name of the layer.
  50573. * @return The effect name
  50574. */
  50575. abstract getEffectName(): string;
  50576. /**
  50577. * Checks for the readiness of the element composing the layer.
  50578. * @param subMesh the mesh to check for
  50579. * @param useInstances specify wether or not to use instances to render the mesh
  50580. * @return true if ready otherwise, false
  50581. */
  50582. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50583. /**
  50584. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50585. * @returns true if the effect requires stencil during the main canvas render pass.
  50586. */
  50587. abstract needStencil(): boolean;
  50588. /**
  50589. * Create the merge effect. This is the shader use to blit the information back
  50590. * to the main canvas at the end of the scene rendering.
  50591. * @returns The effect containing the shader used to merge the effect on the main canvas
  50592. */
  50593. protected abstract _createMergeEffect(): Effect;
  50594. /**
  50595. * Creates the render target textures and post processes used in the effect layer.
  50596. */
  50597. protected abstract _createTextureAndPostProcesses(): void;
  50598. /**
  50599. * Implementation specific of rendering the generating effect on the main canvas.
  50600. * @param effect The effect used to render through
  50601. */
  50602. protected abstract _internalRender(effect: Effect): void;
  50603. /**
  50604. * Sets the required values for both the emissive texture and and the main color.
  50605. */
  50606. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50607. /**
  50608. * Free any resources and references associated to a mesh.
  50609. * Internal use
  50610. * @param mesh The mesh to free.
  50611. */
  50612. abstract _disposeMesh(mesh: Mesh): void;
  50613. /**
  50614. * Serializes this layer (Glow or Highlight for example)
  50615. * @returns a serialized layer object
  50616. */
  50617. abstract serialize?(): any;
  50618. /**
  50619. * Initializes the effect layer with the required options.
  50620. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50621. */
  50622. protected _init(options: Partial<IEffectLayerOptions>): void;
  50623. /**
  50624. * Generates the index buffer of the full screen quad blending to the main canvas.
  50625. */
  50626. private _generateIndexBuffer;
  50627. /**
  50628. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50629. */
  50630. private _generateVertexBuffer;
  50631. /**
  50632. * Sets the main texture desired size which is the closest power of two
  50633. * of the engine canvas size.
  50634. */
  50635. private _setMainTextureSize;
  50636. /**
  50637. * Creates the main texture for the effect layer.
  50638. */
  50639. protected _createMainTexture(): void;
  50640. /**
  50641. * Adds specific effects defines.
  50642. * @param defines The defines to add specifics to.
  50643. */
  50644. protected _addCustomEffectDefines(defines: string[]): void;
  50645. /**
  50646. * Checks for the readiness of the element composing the layer.
  50647. * @param subMesh the mesh to check for
  50648. * @param useInstances specify wether or not to use instances to render the mesh
  50649. * @param emissiveTexture the associated emissive texture used to generate the glow
  50650. * @return true if ready otherwise, false
  50651. */
  50652. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50653. /**
  50654. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50655. */
  50656. render(): void;
  50657. /**
  50658. * Determine if a given mesh will be used in the current effect.
  50659. * @param mesh mesh to test
  50660. * @returns true if the mesh will be used
  50661. */
  50662. hasMesh(mesh: AbstractMesh): boolean;
  50663. /**
  50664. * Returns true if the layer contains information to display, otherwise false.
  50665. * @returns true if the glow layer should be rendered
  50666. */
  50667. shouldRender(): boolean;
  50668. /**
  50669. * Returns true if the mesh should render, otherwise false.
  50670. * @param mesh The mesh to render
  50671. * @returns true if it should render otherwise false
  50672. */
  50673. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50674. /**
  50675. * Returns true if the mesh can be rendered, otherwise false.
  50676. * @param mesh The mesh to render
  50677. * @param material The material used on the mesh
  50678. * @returns true if it can be rendered otherwise false
  50679. */
  50680. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50681. /**
  50682. * Returns true if the mesh should render, otherwise false.
  50683. * @param mesh The mesh to render
  50684. * @returns true if it should render otherwise false
  50685. */
  50686. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50687. /**
  50688. * Renders the submesh passed in parameter to the generation map.
  50689. */
  50690. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50691. /**
  50692. * Rebuild the required buffers.
  50693. * @hidden Internal use only.
  50694. */
  50695. _rebuild(): void;
  50696. /**
  50697. * Dispose only the render target textures and post process.
  50698. */
  50699. private _disposeTextureAndPostProcesses;
  50700. /**
  50701. * Dispose the highlight layer and free resources.
  50702. */
  50703. dispose(): void;
  50704. /**
  50705. * Gets the class name of the effect layer
  50706. * @returns the string with the class name of the effect layer
  50707. */
  50708. getClassName(): string;
  50709. /**
  50710. * Creates an effect layer from parsed effect layer data
  50711. * @param parsedEffectLayer defines effect layer data
  50712. * @param scene defines the current scene
  50713. * @param rootUrl defines the root URL containing the effect layer information
  50714. * @returns a parsed effect Layer
  50715. */
  50716. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50717. }
  50718. }
  50719. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50720. import { Scene } from "babylonjs/scene";
  50721. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50722. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50723. import { AbstractScene } from "babylonjs/abstractScene";
  50724. module "babylonjs/abstractScene" {
  50725. interface AbstractScene {
  50726. /**
  50727. * The list of effect layers (highlights/glow) added to the scene
  50728. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50729. * @see http://doc.babylonjs.com/how_to/glow_layer
  50730. */
  50731. effectLayers: Array<EffectLayer>;
  50732. /**
  50733. * Removes the given effect layer from this scene.
  50734. * @param toRemove defines the effect layer to remove
  50735. * @returns the index of the removed effect layer
  50736. */
  50737. removeEffectLayer(toRemove: EffectLayer): number;
  50738. /**
  50739. * Adds the given effect layer to this scene
  50740. * @param newEffectLayer defines the effect layer to add
  50741. */
  50742. addEffectLayer(newEffectLayer: EffectLayer): void;
  50743. }
  50744. }
  50745. /**
  50746. * Defines the layer scene component responsible to manage any effect layers
  50747. * in a given scene.
  50748. */
  50749. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50750. /**
  50751. * The component name helpfull to identify the component in the list of scene components.
  50752. */
  50753. readonly name: string;
  50754. /**
  50755. * The scene the component belongs to.
  50756. */
  50757. scene: Scene;
  50758. private _engine;
  50759. private _renderEffects;
  50760. private _needStencil;
  50761. private _previousStencilState;
  50762. /**
  50763. * Creates a new instance of the component for the given scene
  50764. * @param scene Defines the scene to register the component in
  50765. */
  50766. constructor(scene: Scene);
  50767. /**
  50768. * Registers the component in a given scene
  50769. */
  50770. register(): void;
  50771. /**
  50772. * Rebuilds the elements related to this component in case of
  50773. * context lost for instance.
  50774. */
  50775. rebuild(): void;
  50776. /**
  50777. * Serializes the component data to the specified json object
  50778. * @param serializationObject The object to serialize to
  50779. */
  50780. serialize(serializationObject: any): void;
  50781. /**
  50782. * Adds all the elements from the container to the scene
  50783. * @param container the container holding the elements
  50784. */
  50785. addFromContainer(container: AbstractScene): void;
  50786. /**
  50787. * Removes all the elements in the container from the scene
  50788. * @param container contains the elements to remove
  50789. * @param dispose if the removed element should be disposed (default: false)
  50790. */
  50791. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50792. /**
  50793. * Disposes the component and the associated ressources.
  50794. */
  50795. dispose(): void;
  50796. private _isReadyForMesh;
  50797. private _renderMainTexture;
  50798. private _setStencil;
  50799. private _setStencilBack;
  50800. private _draw;
  50801. private _drawCamera;
  50802. private _drawRenderingGroup;
  50803. }
  50804. }
  50805. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50806. /** @hidden */
  50807. export var glowMapMergePixelShader: {
  50808. name: string;
  50809. shader: string;
  50810. };
  50811. }
  50812. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50813. /** @hidden */
  50814. export var glowMapMergeVertexShader: {
  50815. name: string;
  50816. shader: string;
  50817. };
  50818. }
  50819. declare module "babylonjs/Layers/glowLayer" {
  50820. import { Nullable } from "babylonjs/types";
  50821. import { Camera } from "babylonjs/Cameras/camera";
  50822. import { Scene } from "babylonjs/scene";
  50823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50825. import { Mesh } from "babylonjs/Meshes/mesh";
  50826. import { Texture } from "babylonjs/Materials/Textures/texture";
  50827. import { Effect } from "babylonjs/Materials/effect";
  50828. import { Material } from "babylonjs/Materials/material";
  50829. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50830. import { Color4 } from "babylonjs/Maths/math.color";
  50831. import "babylonjs/Shaders/glowMapMerge.fragment";
  50832. import "babylonjs/Shaders/glowMapMerge.vertex";
  50833. import "babylonjs/Layers/effectLayerSceneComponent";
  50834. module "babylonjs/abstractScene" {
  50835. interface AbstractScene {
  50836. /**
  50837. * Return a the first highlight layer of the scene with a given name.
  50838. * @param name The name of the highlight layer to look for.
  50839. * @return The highlight layer if found otherwise null.
  50840. */
  50841. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50842. }
  50843. }
  50844. /**
  50845. * Glow layer options. This helps customizing the behaviour
  50846. * of the glow layer.
  50847. */
  50848. export interface IGlowLayerOptions {
  50849. /**
  50850. * Multiplication factor apply to the canvas size to compute the render target size
  50851. * used to generated the glowing objects (the smaller the faster).
  50852. */
  50853. mainTextureRatio: number;
  50854. /**
  50855. * Enforces a fixed size texture to ensure resize independant blur.
  50856. */
  50857. mainTextureFixedSize?: number;
  50858. /**
  50859. * How big is the kernel of the blur texture.
  50860. */
  50861. blurKernelSize: number;
  50862. /**
  50863. * The camera attached to the layer.
  50864. */
  50865. camera: Nullable<Camera>;
  50866. /**
  50867. * Enable MSAA by chosing the number of samples.
  50868. */
  50869. mainTextureSamples?: number;
  50870. /**
  50871. * The rendering group to draw the layer in.
  50872. */
  50873. renderingGroupId: number;
  50874. }
  50875. /**
  50876. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50877. *
  50878. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50879. * glowy meshes to your scene.
  50880. *
  50881. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50882. */
  50883. export class GlowLayer extends EffectLayer {
  50884. /**
  50885. * Effect Name of the layer.
  50886. */
  50887. static readonly EffectName: string;
  50888. /**
  50889. * The default blur kernel size used for the glow.
  50890. */
  50891. static DefaultBlurKernelSize: number;
  50892. /**
  50893. * The default texture size ratio used for the glow.
  50894. */
  50895. static DefaultTextureRatio: number;
  50896. /**
  50897. * Sets the kernel size of the blur.
  50898. */
  50899. /**
  50900. * Gets the kernel size of the blur.
  50901. */
  50902. blurKernelSize: number;
  50903. /**
  50904. * Sets the glow intensity.
  50905. */
  50906. /**
  50907. * Gets the glow intensity.
  50908. */
  50909. intensity: number;
  50910. private _options;
  50911. private _intensity;
  50912. private _horizontalBlurPostprocess1;
  50913. private _verticalBlurPostprocess1;
  50914. private _horizontalBlurPostprocess2;
  50915. private _verticalBlurPostprocess2;
  50916. private _blurTexture1;
  50917. private _blurTexture2;
  50918. private _postProcesses1;
  50919. private _postProcesses2;
  50920. private _includedOnlyMeshes;
  50921. private _excludedMeshes;
  50922. /**
  50923. * Callback used to let the user override the color selection on a per mesh basis
  50924. */
  50925. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50926. /**
  50927. * Callback used to let the user override the texture selection on a per mesh basis
  50928. */
  50929. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50930. /**
  50931. * Instantiates a new glow Layer and references it to the scene.
  50932. * @param name The name of the layer
  50933. * @param scene The scene to use the layer in
  50934. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50935. */
  50936. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50937. /**
  50938. * Get the effect name of the layer.
  50939. * @return The effect name
  50940. */
  50941. getEffectName(): string;
  50942. /**
  50943. * Create the merge effect. This is the shader use to blit the information back
  50944. * to the main canvas at the end of the scene rendering.
  50945. */
  50946. protected _createMergeEffect(): Effect;
  50947. /**
  50948. * Creates the render target textures and post processes used in the glow layer.
  50949. */
  50950. protected _createTextureAndPostProcesses(): void;
  50951. /**
  50952. * Checks for the readiness of the element composing the layer.
  50953. * @param subMesh the mesh to check for
  50954. * @param useInstances specify wether or not to use instances to render the mesh
  50955. * @param emissiveTexture the associated emissive texture used to generate the glow
  50956. * @return true if ready otherwise, false
  50957. */
  50958. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50959. /**
  50960. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50961. */
  50962. needStencil(): boolean;
  50963. /**
  50964. * Returns true if the mesh can be rendered, otherwise false.
  50965. * @param mesh The mesh to render
  50966. * @param material The material used on the mesh
  50967. * @returns true if it can be rendered otherwise false
  50968. */
  50969. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50970. /**
  50971. * Implementation specific of rendering the generating effect on the main canvas.
  50972. * @param effect The effect used to render through
  50973. */
  50974. protected _internalRender(effect: Effect): void;
  50975. /**
  50976. * Sets the required values for both the emissive texture and and the main color.
  50977. */
  50978. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50979. /**
  50980. * Returns true if the mesh should render, otherwise false.
  50981. * @param mesh The mesh to render
  50982. * @returns true if it should render otherwise false
  50983. */
  50984. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50985. /**
  50986. * Adds specific effects defines.
  50987. * @param defines The defines to add specifics to.
  50988. */
  50989. protected _addCustomEffectDefines(defines: string[]): void;
  50990. /**
  50991. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50992. * @param mesh The mesh to exclude from the glow layer
  50993. */
  50994. addExcludedMesh(mesh: Mesh): void;
  50995. /**
  50996. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50997. * @param mesh The mesh to remove
  50998. */
  50999. removeExcludedMesh(mesh: Mesh): void;
  51000. /**
  51001. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51002. * @param mesh The mesh to include in the glow layer
  51003. */
  51004. addIncludedOnlyMesh(mesh: Mesh): void;
  51005. /**
  51006. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51007. * @param mesh The mesh to remove
  51008. */
  51009. removeIncludedOnlyMesh(mesh: Mesh): void;
  51010. /**
  51011. * Determine if a given mesh will be used in the glow layer
  51012. * @param mesh The mesh to test
  51013. * @returns true if the mesh will be highlighted by the current glow layer
  51014. */
  51015. hasMesh(mesh: AbstractMesh): boolean;
  51016. /**
  51017. * Free any resources and references associated to a mesh.
  51018. * Internal use
  51019. * @param mesh The mesh to free.
  51020. * @hidden
  51021. */
  51022. _disposeMesh(mesh: Mesh): void;
  51023. /**
  51024. * Gets the class name of the effect layer
  51025. * @returns the string with the class name of the effect layer
  51026. */
  51027. getClassName(): string;
  51028. /**
  51029. * Serializes this glow layer
  51030. * @returns a serialized glow layer object
  51031. */
  51032. serialize(): any;
  51033. /**
  51034. * Creates a Glow Layer from parsed glow layer data
  51035. * @param parsedGlowLayer defines glow layer data
  51036. * @param scene defines the current scene
  51037. * @param rootUrl defines the root URL containing the glow layer information
  51038. * @returns a parsed Glow Layer
  51039. */
  51040. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51041. }
  51042. }
  51043. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51044. /** @hidden */
  51045. export var glowBlurPostProcessPixelShader: {
  51046. name: string;
  51047. shader: string;
  51048. };
  51049. }
  51050. declare module "babylonjs/Layers/highlightLayer" {
  51051. import { Observable } from "babylonjs/Misc/observable";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { Camera } from "babylonjs/Cameras/camera";
  51054. import { Scene } from "babylonjs/scene";
  51055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51057. import { Mesh } from "babylonjs/Meshes/mesh";
  51058. import { Effect } from "babylonjs/Materials/effect";
  51059. import { Material } from "babylonjs/Materials/material";
  51060. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51061. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51062. import "babylonjs/Shaders/glowMapMerge.fragment";
  51063. import "babylonjs/Shaders/glowMapMerge.vertex";
  51064. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51065. module "babylonjs/abstractScene" {
  51066. interface AbstractScene {
  51067. /**
  51068. * Return a the first highlight layer of the scene with a given name.
  51069. * @param name The name of the highlight layer to look for.
  51070. * @return The highlight layer if found otherwise null.
  51071. */
  51072. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51073. }
  51074. }
  51075. /**
  51076. * Highlight layer options. This helps customizing the behaviour
  51077. * of the highlight layer.
  51078. */
  51079. export interface IHighlightLayerOptions {
  51080. /**
  51081. * Multiplication factor apply to the canvas size to compute the render target size
  51082. * used to generated the glowing objects (the smaller the faster).
  51083. */
  51084. mainTextureRatio: number;
  51085. /**
  51086. * Enforces a fixed size texture to ensure resize independant blur.
  51087. */
  51088. mainTextureFixedSize?: number;
  51089. /**
  51090. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51091. * of the picture to blur (the smaller the faster).
  51092. */
  51093. blurTextureSizeRatio: number;
  51094. /**
  51095. * How big in texel of the blur texture is the vertical blur.
  51096. */
  51097. blurVerticalSize: number;
  51098. /**
  51099. * How big in texel of the blur texture is the horizontal blur.
  51100. */
  51101. blurHorizontalSize: number;
  51102. /**
  51103. * Alpha blending mode used to apply the blur. Default is combine.
  51104. */
  51105. alphaBlendingMode: number;
  51106. /**
  51107. * The camera attached to the layer.
  51108. */
  51109. camera: Nullable<Camera>;
  51110. /**
  51111. * Should we display highlight as a solid stroke?
  51112. */
  51113. isStroke?: boolean;
  51114. /**
  51115. * The rendering group to draw the layer in.
  51116. */
  51117. renderingGroupId: number;
  51118. }
  51119. /**
  51120. * The highlight layer Helps adding a glow effect around a mesh.
  51121. *
  51122. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51123. * glowy meshes to your scene.
  51124. *
  51125. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51126. */
  51127. export class HighlightLayer extends EffectLayer {
  51128. name: string;
  51129. /**
  51130. * Effect Name of the highlight layer.
  51131. */
  51132. static readonly EffectName: string;
  51133. /**
  51134. * The neutral color used during the preparation of the glow effect.
  51135. * This is black by default as the blend operation is a blend operation.
  51136. */
  51137. static NeutralColor: Color4;
  51138. /**
  51139. * Stencil value used for glowing meshes.
  51140. */
  51141. static GlowingMeshStencilReference: number;
  51142. /**
  51143. * Stencil value used for the other meshes in the scene.
  51144. */
  51145. static NormalMeshStencilReference: number;
  51146. /**
  51147. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51148. */
  51149. innerGlow: boolean;
  51150. /**
  51151. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51152. */
  51153. outerGlow: boolean;
  51154. /**
  51155. * Specifies the horizontal size of the blur.
  51156. */
  51157. /**
  51158. * Gets the horizontal size of the blur.
  51159. */
  51160. blurHorizontalSize: number;
  51161. /**
  51162. * Specifies the vertical size of the blur.
  51163. */
  51164. /**
  51165. * Gets the vertical size of the blur.
  51166. */
  51167. blurVerticalSize: number;
  51168. /**
  51169. * An event triggered when the highlight layer is being blurred.
  51170. */
  51171. onBeforeBlurObservable: Observable<HighlightLayer>;
  51172. /**
  51173. * An event triggered when the highlight layer has been blurred.
  51174. */
  51175. onAfterBlurObservable: Observable<HighlightLayer>;
  51176. private _instanceGlowingMeshStencilReference;
  51177. private _options;
  51178. private _downSamplePostprocess;
  51179. private _horizontalBlurPostprocess;
  51180. private _verticalBlurPostprocess;
  51181. private _blurTexture;
  51182. private _meshes;
  51183. private _excludedMeshes;
  51184. /**
  51185. * Instantiates a new highlight Layer and references it to the scene..
  51186. * @param name The name of the layer
  51187. * @param scene The scene to use the layer in
  51188. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51189. */
  51190. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51191. /**
  51192. * Get the effect name of the layer.
  51193. * @return The effect name
  51194. */
  51195. getEffectName(): string;
  51196. /**
  51197. * Create the merge effect. This is the shader use to blit the information back
  51198. * to the main canvas at the end of the scene rendering.
  51199. */
  51200. protected _createMergeEffect(): Effect;
  51201. /**
  51202. * Creates the render target textures and post processes used in the highlight layer.
  51203. */
  51204. protected _createTextureAndPostProcesses(): void;
  51205. /**
  51206. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51207. */
  51208. needStencil(): boolean;
  51209. /**
  51210. * Checks for the readiness of the element composing the layer.
  51211. * @param subMesh the mesh to check for
  51212. * @param useInstances specify wether or not to use instances to render the mesh
  51213. * @param emissiveTexture the associated emissive texture used to generate the glow
  51214. * @return true if ready otherwise, false
  51215. */
  51216. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51217. /**
  51218. * Implementation specific of rendering the generating effect on the main canvas.
  51219. * @param effect The effect used to render through
  51220. */
  51221. protected _internalRender(effect: Effect): void;
  51222. /**
  51223. * Returns true if the layer contains information to display, otherwise false.
  51224. */
  51225. shouldRender(): boolean;
  51226. /**
  51227. * Returns true if the mesh should render, otherwise false.
  51228. * @param mesh The mesh to render
  51229. * @returns true if it should render otherwise false
  51230. */
  51231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51232. /**
  51233. * Sets the required values for both the emissive texture and and the main color.
  51234. */
  51235. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51236. /**
  51237. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51238. * @param mesh The mesh to exclude from the highlight layer
  51239. */
  51240. addExcludedMesh(mesh: Mesh): void;
  51241. /**
  51242. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51243. * @param mesh The mesh to highlight
  51244. */
  51245. removeExcludedMesh(mesh: Mesh): void;
  51246. /**
  51247. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51248. * @param mesh mesh to test
  51249. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51250. */
  51251. hasMesh(mesh: AbstractMesh): boolean;
  51252. /**
  51253. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51254. * @param mesh The mesh to highlight
  51255. * @param color The color of the highlight
  51256. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51257. */
  51258. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51259. /**
  51260. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51261. * @param mesh The mesh to highlight
  51262. */
  51263. removeMesh(mesh: Mesh): void;
  51264. /**
  51265. * Force the stencil to the normal expected value for none glowing parts
  51266. */
  51267. private _defaultStencilReference;
  51268. /**
  51269. * Free any resources and references associated to a mesh.
  51270. * Internal use
  51271. * @param mesh The mesh to free.
  51272. * @hidden
  51273. */
  51274. _disposeMesh(mesh: Mesh): void;
  51275. /**
  51276. * Dispose the highlight layer and free resources.
  51277. */
  51278. dispose(): void;
  51279. /**
  51280. * Gets the class name of the effect layer
  51281. * @returns the string with the class name of the effect layer
  51282. */
  51283. getClassName(): string;
  51284. /**
  51285. * Serializes this Highlight layer
  51286. * @returns a serialized Highlight layer object
  51287. */
  51288. serialize(): any;
  51289. /**
  51290. * Creates a Highlight layer from parsed Highlight layer data
  51291. * @param parsedHightlightLayer defines the Highlight layer data
  51292. * @param scene defines the current scene
  51293. * @param rootUrl defines the root URL containing the Highlight layer information
  51294. * @returns a parsed Highlight layer
  51295. */
  51296. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51297. }
  51298. }
  51299. declare module "babylonjs/Layers/layerSceneComponent" {
  51300. import { Scene } from "babylonjs/scene";
  51301. import { ISceneComponent } from "babylonjs/sceneComponent";
  51302. import { Layer } from "babylonjs/Layers/layer";
  51303. import { AbstractScene } from "babylonjs/abstractScene";
  51304. module "babylonjs/abstractScene" {
  51305. interface AbstractScene {
  51306. /**
  51307. * The list of layers (background and foreground) of the scene
  51308. */
  51309. layers: Array<Layer>;
  51310. }
  51311. }
  51312. /**
  51313. * Defines the layer scene component responsible to manage any layers
  51314. * in a given scene.
  51315. */
  51316. export class LayerSceneComponent implements ISceneComponent {
  51317. /**
  51318. * The component name helpfull to identify the component in the list of scene components.
  51319. */
  51320. readonly name: string;
  51321. /**
  51322. * The scene the component belongs to.
  51323. */
  51324. scene: Scene;
  51325. private _engine;
  51326. /**
  51327. * Creates a new instance of the component for the given scene
  51328. * @param scene Defines the scene to register the component in
  51329. */
  51330. constructor(scene: Scene);
  51331. /**
  51332. * Registers the component in a given scene
  51333. */
  51334. register(): void;
  51335. /**
  51336. * Rebuilds the elements related to this component in case of
  51337. * context lost for instance.
  51338. */
  51339. rebuild(): void;
  51340. /**
  51341. * Disposes the component and the associated ressources.
  51342. */
  51343. dispose(): void;
  51344. private _draw;
  51345. private _drawCameraPredicate;
  51346. private _drawCameraBackground;
  51347. private _drawCameraForeground;
  51348. private _drawRenderTargetPredicate;
  51349. private _drawRenderTargetBackground;
  51350. private _drawRenderTargetForeground;
  51351. /**
  51352. * Adds all the elements from the container to the scene
  51353. * @param container the container holding the elements
  51354. */
  51355. addFromContainer(container: AbstractScene): void;
  51356. /**
  51357. * Removes all the elements in the container from the scene
  51358. * @param container contains the elements to remove
  51359. * @param dispose if the removed element should be disposed (default: false)
  51360. */
  51361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51362. }
  51363. }
  51364. declare module "babylonjs/Shaders/layer.fragment" {
  51365. /** @hidden */
  51366. export var layerPixelShader: {
  51367. name: string;
  51368. shader: string;
  51369. };
  51370. }
  51371. declare module "babylonjs/Shaders/layer.vertex" {
  51372. /** @hidden */
  51373. export var layerVertexShader: {
  51374. name: string;
  51375. shader: string;
  51376. };
  51377. }
  51378. declare module "babylonjs/Layers/layer" {
  51379. import { Observable } from "babylonjs/Misc/observable";
  51380. import { Nullable } from "babylonjs/types";
  51381. import { Scene } from "babylonjs/scene";
  51382. import { Vector2 } from "babylonjs/Maths/math.vector";
  51383. import { Color4 } from "babylonjs/Maths/math.color";
  51384. import { Texture } from "babylonjs/Materials/Textures/texture";
  51385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51386. import "babylonjs/Shaders/layer.fragment";
  51387. import "babylonjs/Shaders/layer.vertex";
  51388. /**
  51389. * This represents a full screen 2d layer.
  51390. * This can be useful to display a picture in the background of your scene for instance.
  51391. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51392. */
  51393. export class Layer {
  51394. /**
  51395. * Define the name of the layer.
  51396. */
  51397. name: string;
  51398. /**
  51399. * Define the texture the layer should display.
  51400. */
  51401. texture: Nullable<Texture>;
  51402. /**
  51403. * Is the layer in background or foreground.
  51404. */
  51405. isBackground: boolean;
  51406. /**
  51407. * Define the color of the layer (instead of texture).
  51408. */
  51409. color: Color4;
  51410. /**
  51411. * Define the scale of the layer in order to zoom in out of the texture.
  51412. */
  51413. scale: Vector2;
  51414. /**
  51415. * Define an offset for the layer in order to shift the texture.
  51416. */
  51417. offset: Vector2;
  51418. /**
  51419. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51420. */
  51421. alphaBlendingMode: number;
  51422. /**
  51423. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51424. * Alpha test will not mix with the background color in case of transparency.
  51425. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51426. */
  51427. alphaTest: boolean;
  51428. /**
  51429. * Define a mask to restrict the layer to only some of the scene cameras.
  51430. */
  51431. layerMask: number;
  51432. /**
  51433. * Define the list of render target the layer is visible into.
  51434. */
  51435. renderTargetTextures: RenderTargetTexture[];
  51436. /**
  51437. * Define if the layer is only used in renderTarget or if it also
  51438. * renders in the main frame buffer of the canvas.
  51439. */
  51440. renderOnlyInRenderTargetTextures: boolean;
  51441. private _scene;
  51442. private _vertexBuffers;
  51443. private _indexBuffer;
  51444. private _effect;
  51445. private _alphaTestEffect;
  51446. /**
  51447. * An event triggered when the layer is disposed.
  51448. */
  51449. onDisposeObservable: Observable<Layer>;
  51450. private _onDisposeObserver;
  51451. /**
  51452. * Back compatibility with callback before the onDisposeObservable existed.
  51453. * The set callback will be triggered when the layer has been disposed.
  51454. */
  51455. onDispose: () => void;
  51456. /**
  51457. * An event triggered before rendering the scene
  51458. */
  51459. onBeforeRenderObservable: Observable<Layer>;
  51460. private _onBeforeRenderObserver;
  51461. /**
  51462. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51463. * The set callback will be triggered just before rendering the layer.
  51464. */
  51465. onBeforeRender: () => void;
  51466. /**
  51467. * An event triggered after rendering the scene
  51468. */
  51469. onAfterRenderObservable: Observable<Layer>;
  51470. private _onAfterRenderObserver;
  51471. /**
  51472. * Back compatibility with callback before the onAfterRenderObservable existed.
  51473. * The set callback will be triggered just after rendering the layer.
  51474. */
  51475. onAfterRender: () => void;
  51476. /**
  51477. * Instantiates a new layer.
  51478. * This represents a full screen 2d layer.
  51479. * This can be useful to display a picture in the background of your scene for instance.
  51480. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51481. * @param name Define the name of the layer in the scene
  51482. * @param imgUrl Define the url of the texture to display in the layer
  51483. * @param scene Define the scene the layer belongs to
  51484. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51485. * @param color Defines a color for the layer
  51486. */
  51487. constructor(
  51488. /**
  51489. * Define the name of the layer.
  51490. */
  51491. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51492. private _createIndexBuffer;
  51493. /** @hidden */
  51494. _rebuild(): void;
  51495. /**
  51496. * Renders the layer in the scene.
  51497. */
  51498. render(): void;
  51499. /**
  51500. * Disposes and releases the associated ressources.
  51501. */
  51502. dispose(): void;
  51503. }
  51504. }
  51505. declare module "babylonjs/Layers/index" {
  51506. export * from "babylonjs/Layers/effectLayer";
  51507. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51508. export * from "babylonjs/Layers/glowLayer";
  51509. export * from "babylonjs/Layers/highlightLayer";
  51510. export * from "babylonjs/Layers/layer";
  51511. export * from "babylonjs/Layers/layerSceneComponent";
  51512. }
  51513. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51514. /** @hidden */
  51515. export var lensFlarePixelShader: {
  51516. name: string;
  51517. shader: string;
  51518. };
  51519. }
  51520. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51521. /** @hidden */
  51522. export var lensFlareVertexShader: {
  51523. name: string;
  51524. shader: string;
  51525. };
  51526. }
  51527. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51528. import { Scene } from "babylonjs/scene";
  51529. import { Vector3 } from "babylonjs/Maths/math.vector";
  51530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51531. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51532. import "babylonjs/Shaders/lensFlare.fragment";
  51533. import "babylonjs/Shaders/lensFlare.vertex";
  51534. import { Viewport } from "babylonjs/Maths/math.viewport";
  51535. /**
  51536. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51537. * It is usually composed of several `lensFlare`.
  51538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51539. */
  51540. export class LensFlareSystem {
  51541. /**
  51542. * Define the name of the lens flare system
  51543. */
  51544. name: string;
  51545. /**
  51546. * List of lens flares used in this system.
  51547. */
  51548. lensFlares: LensFlare[];
  51549. /**
  51550. * Define a limit from the border the lens flare can be visible.
  51551. */
  51552. borderLimit: number;
  51553. /**
  51554. * Define a viewport border we do not want to see the lens flare in.
  51555. */
  51556. viewportBorder: number;
  51557. /**
  51558. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51559. */
  51560. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51561. /**
  51562. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51563. */
  51564. layerMask: number;
  51565. /**
  51566. * Define the id of the lens flare system in the scene.
  51567. * (equal to name by default)
  51568. */
  51569. id: string;
  51570. private _scene;
  51571. private _emitter;
  51572. private _vertexBuffers;
  51573. private _indexBuffer;
  51574. private _effect;
  51575. private _positionX;
  51576. private _positionY;
  51577. private _isEnabled;
  51578. /** @hidden */
  51579. static _SceneComponentInitialization: (scene: Scene) => void;
  51580. /**
  51581. * Instantiates a lens flare system.
  51582. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51583. * It is usually composed of several `lensFlare`.
  51584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51585. * @param name Define the name of the lens flare system in the scene
  51586. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51587. * @param scene Define the scene the lens flare system belongs to
  51588. */
  51589. constructor(
  51590. /**
  51591. * Define the name of the lens flare system
  51592. */
  51593. name: string, emitter: any, scene: Scene);
  51594. /**
  51595. * Define if the lens flare system is enabled.
  51596. */
  51597. isEnabled: boolean;
  51598. /**
  51599. * Get the scene the effects belongs to.
  51600. * @returns the scene holding the lens flare system
  51601. */
  51602. getScene(): Scene;
  51603. /**
  51604. * Get the emitter of the lens flare system.
  51605. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51606. * @returns the emitter of the lens flare system
  51607. */
  51608. getEmitter(): any;
  51609. /**
  51610. * Set the emitter of the lens flare system.
  51611. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51612. * @param newEmitter Define the new emitter of the system
  51613. */
  51614. setEmitter(newEmitter: any): void;
  51615. /**
  51616. * Get the lens flare system emitter position.
  51617. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51618. * @returns the position
  51619. */
  51620. getEmitterPosition(): Vector3;
  51621. /**
  51622. * @hidden
  51623. */
  51624. computeEffectivePosition(globalViewport: Viewport): boolean;
  51625. /** @hidden */
  51626. _isVisible(): boolean;
  51627. /**
  51628. * @hidden
  51629. */
  51630. render(): boolean;
  51631. /**
  51632. * Dispose and release the lens flare with its associated resources.
  51633. */
  51634. dispose(): void;
  51635. /**
  51636. * Parse a lens flare system from a JSON repressentation
  51637. * @param parsedLensFlareSystem Define the JSON to parse
  51638. * @param scene Define the scene the parsed system should be instantiated in
  51639. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51640. * @returns the parsed system
  51641. */
  51642. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51643. /**
  51644. * Serialize the current Lens Flare System into a JSON representation.
  51645. * @returns the serialized JSON
  51646. */
  51647. serialize(): any;
  51648. }
  51649. }
  51650. declare module "babylonjs/LensFlares/lensFlare" {
  51651. import { Nullable } from "babylonjs/types";
  51652. import { Color3 } from "babylonjs/Maths/math.color";
  51653. import { Texture } from "babylonjs/Materials/Textures/texture";
  51654. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51655. /**
  51656. * This represents one of the lens effect in a `lensFlareSystem`.
  51657. * It controls one of the indiviual texture used in the effect.
  51658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51659. */
  51660. export class LensFlare {
  51661. /**
  51662. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51663. */
  51664. size: number;
  51665. /**
  51666. * 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.
  51667. */
  51668. position: number;
  51669. /**
  51670. * Define the lens color.
  51671. */
  51672. color: Color3;
  51673. /**
  51674. * Define the lens texture.
  51675. */
  51676. texture: Nullable<Texture>;
  51677. /**
  51678. * Define the alpha mode to render this particular lens.
  51679. */
  51680. alphaMode: number;
  51681. private _system;
  51682. /**
  51683. * Creates a new Lens Flare.
  51684. * This represents one of the lens effect in a `lensFlareSystem`.
  51685. * It controls one of the indiviual texture used in the effect.
  51686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51687. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51688. * @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.
  51689. * @param color Define the lens color
  51690. * @param imgUrl Define the lens texture url
  51691. * @param system Define the `lensFlareSystem` this flare is part of
  51692. * @returns The newly created Lens Flare
  51693. */
  51694. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51695. /**
  51696. * Instantiates a new Lens Flare.
  51697. * This represents one of the lens effect in a `lensFlareSystem`.
  51698. * It controls one of the indiviual texture used in the effect.
  51699. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51700. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51701. * @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.
  51702. * @param color Define the lens color
  51703. * @param imgUrl Define the lens texture url
  51704. * @param system Define the `lensFlareSystem` this flare is part of
  51705. */
  51706. constructor(
  51707. /**
  51708. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51709. */
  51710. size: number,
  51711. /**
  51712. * 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.
  51713. */
  51714. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51715. /**
  51716. * Dispose and release the lens flare with its associated resources.
  51717. */
  51718. dispose(): void;
  51719. }
  51720. }
  51721. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51722. import { Nullable } from "babylonjs/types";
  51723. import { Scene } from "babylonjs/scene";
  51724. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51725. import { AbstractScene } from "babylonjs/abstractScene";
  51726. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51727. module "babylonjs/abstractScene" {
  51728. interface AbstractScene {
  51729. /**
  51730. * The list of lens flare system added to the scene
  51731. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51732. */
  51733. lensFlareSystems: Array<LensFlareSystem>;
  51734. /**
  51735. * Removes the given lens flare system from this scene.
  51736. * @param toRemove The lens flare system to remove
  51737. * @returns The index of the removed lens flare system
  51738. */
  51739. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51740. /**
  51741. * Adds the given lens flare system to this scene
  51742. * @param newLensFlareSystem The lens flare system to add
  51743. */
  51744. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51745. /**
  51746. * Gets a lens flare system using its name
  51747. * @param name defines the name to look for
  51748. * @returns the lens flare system or null if not found
  51749. */
  51750. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51751. /**
  51752. * Gets a lens flare system using its id
  51753. * @param id defines the id to look for
  51754. * @returns the lens flare system or null if not found
  51755. */
  51756. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51757. }
  51758. }
  51759. /**
  51760. * Defines the lens flare scene component responsible to manage any lens flares
  51761. * in a given scene.
  51762. */
  51763. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51764. /**
  51765. * The component name helpfull to identify the component in the list of scene components.
  51766. */
  51767. readonly name: string;
  51768. /**
  51769. * The scene the component belongs to.
  51770. */
  51771. scene: Scene;
  51772. /**
  51773. * Creates a new instance of the component for the given scene
  51774. * @param scene Defines the scene to register the component in
  51775. */
  51776. constructor(scene: Scene);
  51777. /**
  51778. * Registers the component in a given scene
  51779. */
  51780. register(): void;
  51781. /**
  51782. * Rebuilds the elements related to this component in case of
  51783. * context lost for instance.
  51784. */
  51785. rebuild(): void;
  51786. /**
  51787. * Adds all the elements from the container to the scene
  51788. * @param container the container holding the elements
  51789. */
  51790. addFromContainer(container: AbstractScene): void;
  51791. /**
  51792. * Removes all the elements in the container from the scene
  51793. * @param container contains the elements to remove
  51794. * @param dispose if the removed element should be disposed (default: false)
  51795. */
  51796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51797. /**
  51798. * Serializes the component data to the specified json object
  51799. * @param serializationObject The object to serialize to
  51800. */
  51801. serialize(serializationObject: any): void;
  51802. /**
  51803. * Disposes the component and the associated ressources.
  51804. */
  51805. dispose(): void;
  51806. private _draw;
  51807. }
  51808. }
  51809. declare module "babylonjs/LensFlares/index" {
  51810. export * from "babylonjs/LensFlares/lensFlare";
  51811. export * from "babylonjs/LensFlares/lensFlareSystem";
  51812. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51813. }
  51814. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51815. import { Scene } from "babylonjs/scene";
  51816. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51817. import { AbstractScene } from "babylonjs/abstractScene";
  51818. /**
  51819. * Defines the shadow generator component responsible to manage any shadow generators
  51820. * in a given scene.
  51821. */
  51822. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51823. /**
  51824. * The component name helpfull to identify the component in the list of scene components.
  51825. */
  51826. readonly name: string;
  51827. /**
  51828. * The scene the component belongs to.
  51829. */
  51830. scene: Scene;
  51831. /**
  51832. * Creates a new instance of the component for the given scene
  51833. * @param scene Defines the scene to register the component in
  51834. */
  51835. constructor(scene: Scene);
  51836. /**
  51837. * Registers the component in a given scene
  51838. */
  51839. register(): void;
  51840. /**
  51841. * Rebuilds the elements related to this component in case of
  51842. * context lost for instance.
  51843. */
  51844. rebuild(): void;
  51845. /**
  51846. * Serializes the component data to the specified json object
  51847. * @param serializationObject The object to serialize to
  51848. */
  51849. serialize(serializationObject: any): void;
  51850. /**
  51851. * Adds all the elements from the container to the scene
  51852. * @param container the container holding the elements
  51853. */
  51854. addFromContainer(container: AbstractScene): void;
  51855. /**
  51856. * Removes all the elements in the container from the scene
  51857. * @param container contains the elements to remove
  51858. * @param dispose if the removed element should be disposed (default: false)
  51859. */
  51860. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51861. /**
  51862. * Rebuilds the elements related to this component in case of
  51863. * context lost for instance.
  51864. */
  51865. dispose(): void;
  51866. private _gatherRenderTargets;
  51867. }
  51868. }
  51869. declare module "babylonjs/Lights/Shadows/index" {
  51870. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51871. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51872. }
  51873. declare module "babylonjs/Lights/pointLight" {
  51874. import { Scene } from "babylonjs/scene";
  51875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51877. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51878. import { Effect } from "babylonjs/Materials/effect";
  51879. /**
  51880. * A point light is a light defined by an unique point in world space.
  51881. * The light is emitted in every direction from this point.
  51882. * A good example of a point light is a standard light bulb.
  51883. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51884. */
  51885. export class PointLight extends ShadowLight {
  51886. private _shadowAngle;
  51887. /**
  51888. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51889. * This specifies what angle the shadow will use to be created.
  51890. *
  51891. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51892. */
  51893. /**
  51894. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51895. * This specifies what angle the shadow will use to be created.
  51896. *
  51897. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51898. */
  51899. shadowAngle: number;
  51900. /**
  51901. * Gets the direction if it has been set.
  51902. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51903. */
  51904. /**
  51905. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51906. */
  51907. direction: Vector3;
  51908. /**
  51909. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51910. * A PointLight emits the light in every direction.
  51911. * It can cast shadows.
  51912. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51913. * ```javascript
  51914. * var pointLight = new PointLight("pl", camera.position, scene);
  51915. * ```
  51916. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51917. * @param name The light friendly name
  51918. * @param position The position of the point light in the scene
  51919. * @param scene The scene the lights belongs to
  51920. */
  51921. constructor(name: string, position: Vector3, scene: Scene);
  51922. /**
  51923. * Returns the string "PointLight"
  51924. * @returns the class name
  51925. */
  51926. getClassName(): string;
  51927. /**
  51928. * Returns the integer 0.
  51929. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51930. */
  51931. getTypeID(): number;
  51932. /**
  51933. * Specifies wether or not the shadowmap should be a cube texture.
  51934. * @returns true if the shadowmap needs to be a cube texture.
  51935. */
  51936. needCube(): boolean;
  51937. /**
  51938. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51941. */
  51942. getShadowDirection(faceIndex?: number): Vector3;
  51943. /**
  51944. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51945. * - fov = PI / 2
  51946. * - aspect ratio : 1.0
  51947. * - z-near and far equal to the active camera minZ and maxZ.
  51948. * Returns the PointLight.
  51949. */
  51950. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51951. protected _buildUniformLayout(): void;
  51952. /**
  51953. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51954. * @param effect The effect to update
  51955. * @param lightIndex The index of the light in the effect to update
  51956. * @returns The point light
  51957. */
  51958. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51959. /**
  51960. * Prepares the list of defines specific to the light type.
  51961. * @param defines the list of defines
  51962. * @param lightIndex defines the index of the light for the effect
  51963. */
  51964. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51965. }
  51966. }
  51967. declare module "babylonjs/Lights/index" {
  51968. export * from "babylonjs/Lights/light";
  51969. export * from "babylonjs/Lights/shadowLight";
  51970. export * from "babylonjs/Lights/Shadows/index";
  51971. export * from "babylonjs/Lights/directionalLight";
  51972. export * from "babylonjs/Lights/hemisphericLight";
  51973. export * from "babylonjs/Lights/pointLight";
  51974. export * from "babylonjs/Lights/spotLight";
  51975. }
  51976. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51977. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51978. /**
  51979. * Header information of HDR texture files.
  51980. */
  51981. export interface HDRInfo {
  51982. /**
  51983. * The height of the texture in pixels.
  51984. */
  51985. height: number;
  51986. /**
  51987. * The width of the texture in pixels.
  51988. */
  51989. width: number;
  51990. /**
  51991. * The index of the beginning of the data in the binary file.
  51992. */
  51993. dataPosition: number;
  51994. }
  51995. /**
  51996. * This groups tools to convert HDR texture to native colors array.
  51997. */
  51998. export class HDRTools {
  51999. private static Ldexp;
  52000. private static Rgbe2float;
  52001. private static readStringLine;
  52002. /**
  52003. * Reads header information from an RGBE texture stored in a native array.
  52004. * More information on this format are available here:
  52005. * https://en.wikipedia.org/wiki/RGBE_image_format
  52006. *
  52007. * @param uint8array The binary file stored in native array.
  52008. * @return The header information.
  52009. */
  52010. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52011. /**
  52012. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52013. * This RGBE texture needs to store the information as a panorama.
  52014. *
  52015. * More information on this format are available here:
  52016. * https://en.wikipedia.org/wiki/RGBE_image_format
  52017. *
  52018. * @param buffer The binary file stored in an array buffer.
  52019. * @param size The expected size of the extracted cubemap.
  52020. * @return The Cube Map information.
  52021. */
  52022. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52023. /**
  52024. * Returns the pixels data extracted from an RGBE texture.
  52025. * This pixels will be stored left to right up to down in the R G B order in one array.
  52026. *
  52027. * More information on this format are available here:
  52028. * https://en.wikipedia.org/wiki/RGBE_image_format
  52029. *
  52030. * @param uint8array The binary file stored in an array buffer.
  52031. * @param hdrInfo The header information of the file.
  52032. * @return The pixels data in RGB right to left up to down order.
  52033. */
  52034. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52035. private static RGBE_ReadPixels_RLE;
  52036. }
  52037. }
  52038. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52039. import { Nullable } from "babylonjs/types";
  52040. import { Scene } from "babylonjs/scene";
  52041. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52043. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52044. /**
  52045. * This represents a texture coming from an HDR input.
  52046. *
  52047. * The only supported format is currently panorama picture stored in RGBE format.
  52048. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52049. */
  52050. export class HDRCubeTexture extends BaseTexture {
  52051. private static _facesMapping;
  52052. private _generateHarmonics;
  52053. private _noMipmap;
  52054. private _textureMatrix;
  52055. private _size;
  52056. private _onLoad;
  52057. private _onError;
  52058. /**
  52059. * The texture URL.
  52060. */
  52061. url: string;
  52062. /**
  52063. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52064. */
  52065. coordinatesMode: number;
  52066. protected _isBlocking: boolean;
  52067. /**
  52068. * Sets wether or not the texture is blocking during loading.
  52069. */
  52070. /**
  52071. * Gets wether or not the texture is blocking during loading.
  52072. */
  52073. isBlocking: boolean;
  52074. protected _rotationY: number;
  52075. /**
  52076. * Sets texture matrix rotation angle around Y axis in radians.
  52077. */
  52078. /**
  52079. * Gets texture matrix rotation angle around Y axis radians.
  52080. */
  52081. rotationY: number;
  52082. /**
  52083. * Gets or sets the center of the bounding box associated with the cube texture
  52084. * It must define where the camera used to render the texture was set
  52085. */
  52086. boundingBoxPosition: Vector3;
  52087. private _boundingBoxSize;
  52088. /**
  52089. * Gets or sets the size of the bounding box associated with the cube texture
  52090. * When defined, the cubemap will switch to local mode
  52091. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52092. * @example https://www.babylonjs-playground.com/#RNASML
  52093. */
  52094. boundingBoxSize: Vector3;
  52095. /**
  52096. * Instantiates an HDRTexture from the following parameters.
  52097. *
  52098. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52099. * @param scene The scene the texture will be used in
  52100. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52101. * @param noMipmap Forces to not generate the mipmap if true
  52102. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52103. * @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)
  52104. * @param reserved Reserved flag for internal use.
  52105. */
  52106. 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>);
  52107. /**
  52108. * Get the current class name of the texture useful for serialization or dynamic coding.
  52109. * @returns "HDRCubeTexture"
  52110. */
  52111. getClassName(): string;
  52112. /**
  52113. * Occurs when the file is raw .hdr file.
  52114. */
  52115. private loadTexture;
  52116. clone(): HDRCubeTexture;
  52117. delayLoad(): void;
  52118. /**
  52119. * Get the texture reflection matrix used to rotate/transform the reflection.
  52120. * @returns the reflection matrix
  52121. */
  52122. getReflectionTextureMatrix(): Matrix;
  52123. /**
  52124. * Set the texture reflection matrix used to rotate/transform the reflection.
  52125. * @param value Define the reflection matrix to set
  52126. */
  52127. setReflectionTextureMatrix(value: Matrix): void;
  52128. /**
  52129. * Parses a JSON representation of an HDR Texture in order to create the texture
  52130. * @param parsedTexture Define the JSON representation
  52131. * @param scene Define the scene the texture should be created in
  52132. * @param rootUrl Define the root url in case we need to load relative dependencies
  52133. * @returns the newly created texture after parsing
  52134. */
  52135. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52136. serialize(): any;
  52137. }
  52138. }
  52139. declare module "babylonjs/Physics/physicsEngine" {
  52140. import { Nullable } from "babylonjs/types";
  52141. import { Vector3 } from "babylonjs/Maths/math.vector";
  52142. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52143. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52144. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52145. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52146. /**
  52147. * Class used to control physics engine
  52148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52149. */
  52150. export class PhysicsEngine implements IPhysicsEngine {
  52151. private _physicsPlugin;
  52152. /**
  52153. * Global value used to control the smallest number supported by the simulation
  52154. */
  52155. static Epsilon: number;
  52156. private _impostors;
  52157. private _joints;
  52158. /**
  52159. * Gets the gravity vector used by the simulation
  52160. */
  52161. gravity: Vector3;
  52162. /**
  52163. * Factory used to create the default physics plugin.
  52164. * @returns The default physics plugin
  52165. */
  52166. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52167. /**
  52168. * Creates a new Physics Engine
  52169. * @param gravity defines the gravity vector used by the simulation
  52170. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52171. */
  52172. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52173. /**
  52174. * Sets the gravity vector used by the simulation
  52175. * @param gravity defines the gravity vector to use
  52176. */
  52177. setGravity(gravity: Vector3): void;
  52178. /**
  52179. * Set the time step of the physics engine.
  52180. * Default is 1/60.
  52181. * To slow it down, enter 1/600 for example.
  52182. * To speed it up, 1/30
  52183. * @param newTimeStep defines the new timestep to apply to this world.
  52184. */
  52185. setTimeStep(newTimeStep?: number): void;
  52186. /**
  52187. * Get the time step of the physics engine.
  52188. * @returns the current time step
  52189. */
  52190. getTimeStep(): number;
  52191. /**
  52192. * Release all resources
  52193. */
  52194. dispose(): void;
  52195. /**
  52196. * Gets the name of the current physics plugin
  52197. * @returns the name of the plugin
  52198. */
  52199. getPhysicsPluginName(): string;
  52200. /**
  52201. * Adding a new impostor for the impostor tracking.
  52202. * This will be done by the impostor itself.
  52203. * @param impostor the impostor to add
  52204. */
  52205. addImpostor(impostor: PhysicsImpostor): void;
  52206. /**
  52207. * Remove an impostor from the engine.
  52208. * This impostor and its mesh will not longer be updated by the physics engine.
  52209. * @param impostor the impostor to remove
  52210. */
  52211. removeImpostor(impostor: PhysicsImpostor): void;
  52212. /**
  52213. * Add a joint to the physics engine
  52214. * @param mainImpostor defines the main impostor to which the joint is added.
  52215. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52216. * @param joint defines the joint that will connect both impostors.
  52217. */
  52218. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52219. /**
  52220. * Removes a joint from the simulation
  52221. * @param mainImpostor defines the impostor used with the joint
  52222. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52223. * @param joint defines the joint to remove
  52224. */
  52225. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52226. /**
  52227. * Called by the scene. No need to call it.
  52228. * @param delta defines the timespam between frames
  52229. */
  52230. _step(delta: number): void;
  52231. /**
  52232. * Gets the current plugin used to run the simulation
  52233. * @returns current plugin
  52234. */
  52235. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52236. /**
  52237. * Gets the list of physic impostors
  52238. * @returns an array of PhysicsImpostor
  52239. */
  52240. getImpostors(): Array<PhysicsImpostor>;
  52241. /**
  52242. * Gets the impostor for a physics enabled object
  52243. * @param object defines the object impersonated by the impostor
  52244. * @returns the PhysicsImpostor or null if not found
  52245. */
  52246. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52247. /**
  52248. * Gets the impostor for a physics body object
  52249. * @param body defines physics body used by the impostor
  52250. * @returns the PhysicsImpostor or null if not found
  52251. */
  52252. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52253. /**
  52254. * Does a raycast in the physics world
  52255. * @param from when should the ray start?
  52256. * @param to when should the ray end?
  52257. * @returns PhysicsRaycastResult
  52258. */
  52259. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52260. }
  52261. }
  52262. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52263. import { Nullable } from "babylonjs/types";
  52264. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52266. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52267. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52268. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52269. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52270. /** @hidden */
  52271. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52272. private _useDeltaForWorldStep;
  52273. world: any;
  52274. name: string;
  52275. private _physicsMaterials;
  52276. private _fixedTimeStep;
  52277. private _cannonRaycastResult;
  52278. private _raycastResult;
  52279. private _physicsBodysToRemoveAfterStep;
  52280. BJSCANNON: any;
  52281. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52282. setGravity(gravity: Vector3): void;
  52283. setTimeStep(timeStep: number): void;
  52284. getTimeStep(): number;
  52285. executeStep(delta: number): void;
  52286. private _removeMarkedPhysicsBodiesFromWorld;
  52287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52290. private _processChildMeshes;
  52291. removePhysicsBody(impostor: PhysicsImpostor): void;
  52292. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52293. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52294. private _addMaterial;
  52295. private _checkWithEpsilon;
  52296. private _createShape;
  52297. private _createHeightmap;
  52298. private _minus90X;
  52299. private _plus90X;
  52300. private _tmpPosition;
  52301. private _tmpDeltaPosition;
  52302. private _tmpUnityRotation;
  52303. private _updatePhysicsBodyTransformation;
  52304. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52305. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52306. isSupported(): boolean;
  52307. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52308. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52309. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52310. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52311. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52312. getBodyMass(impostor: PhysicsImpostor): number;
  52313. getBodyFriction(impostor: PhysicsImpostor): number;
  52314. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52315. getBodyRestitution(impostor: PhysicsImpostor): number;
  52316. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52317. sleepBody(impostor: PhysicsImpostor): void;
  52318. wakeUpBody(impostor: PhysicsImpostor): void;
  52319. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52320. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52321. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52322. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52323. getRadius(impostor: PhysicsImpostor): number;
  52324. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52325. dispose(): void;
  52326. private _extendNamespace;
  52327. /**
  52328. * Does a raycast in the physics world
  52329. * @param from when should the ray start?
  52330. * @param to when should the ray end?
  52331. * @returns PhysicsRaycastResult
  52332. */
  52333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52334. }
  52335. }
  52336. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52337. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52338. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52339. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52341. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52342. import { Nullable } from "babylonjs/types";
  52343. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52344. /** @hidden */
  52345. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52346. world: any;
  52347. name: string;
  52348. BJSOIMO: any;
  52349. private _raycastResult;
  52350. constructor(iterations?: number, oimoInjection?: any);
  52351. setGravity(gravity: Vector3): void;
  52352. setTimeStep(timeStep: number): void;
  52353. getTimeStep(): number;
  52354. private _tmpImpostorsArray;
  52355. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52356. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52357. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52358. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52359. private _tmpPositionVector;
  52360. removePhysicsBody(impostor: PhysicsImpostor): void;
  52361. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52362. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52363. isSupported(): boolean;
  52364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52365. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52366. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52367. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52368. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52369. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52370. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52371. getBodyMass(impostor: PhysicsImpostor): number;
  52372. getBodyFriction(impostor: PhysicsImpostor): number;
  52373. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52374. getBodyRestitution(impostor: PhysicsImpostor): number;
  52375. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52376. sleepBody(impostor: PhysicsImpostor): void;
  52377. wakeUpBody(impostor: PhysicsImpostor): void;
  52378. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52379. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52380. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52381. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52382. getRadius(impostor: PhysicsImpostor): number;
  52383. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52384. dispose(): void;
  52385. /**
  52386. * Does a raycast in the physics world
  52387. * @param from when should the ray start?
  52388. * @param to when should the ray end?
  52389. * @returns PhysicsRaycastResult
  52390. */
  52391. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52392. }
  52393. }
  52394. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52395. import { Nullable } from "babylonjs/types";
  52396. import { Scene } from "babylonjs/scene";
  52397. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52398. import { Color4 } from "babylonjs/Maths/math.color";
  52399. import { Mesh } from "babylonjs/Meshes/mesh";
  52400. /**
  52401. * Class containing static functions to help procedurally build meshes
  52402. */
  52403. export class RibbonBuilder {
  52404. /**
  52405. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52406. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52407. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52408. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52409. * * 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
  52410. * * 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
  52411. * * 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
  52412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52415. * * 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
  52416. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52417. * * 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
  52418. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52420. * @param name defines the name of the mesh
  52421. * @param options defines the options used to create the mesh
  52422. * @param scene defines the hosting scene
  52423. * @returns the ribbon mesh
  52424. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52426. */
  52427. static CreateRibbon(name: string, options: {
  52428. pathArray: Vector3[][];
  52429. closeArray?: boolean;
  52430. closePath?: boolean;
  52431. offset?: number;
  52432. updatable?: boolean;
  52433. sideOrientation?: number;
  52434. frontUVs?: Vector4;
  52435. backUVs?: Vector4;
  52436. instance?: Mesh;
  52437. invertUV?: boolean;
  52438. uvs?: Vector2[];
  52439. colors?: Color4[];
  52440. }, scene?: Nullable<Scene>): Mesh;
  52441. }
  52442. }
  52443. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52444. import { Nullable } from "babylonjs/types";
  52445. import { Scene } from "babylonjs/scene";
  52446. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52447. import { Mesh } from "babylonjs/Meshes/mesh";
  52448. /**
  52449. * Class containing static functions to help procedurally build meshes
  52450. */
  52451. export class ShapeBuilder {
  52452. /**
  52453. * 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.
  52454. * * 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.
  52455. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52456. * * 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.
  52457. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52458. * * 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
  52459. * * 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
  52460. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52465. * @param name defines the name of the mesh
  52466. * @param options defines the options used to create the mesh
  52467. * @param scene defines the hosting scene
  52468. * @returns the extruded shape mesh
  52469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52471. */
  52472. static ExtrudeShape(name: string, options: {
  52473. shape: Vector3[];
  52474. path: Vector3[];
  52475. scale?: number;
  52476. rotation?: number;
  52477. cap?: number;
  52478. updatable?: boolean;
  52479. sideOrientation?: number;
  52480. frontUVs?: Vector4;
  52481. backUVs?: Vector4;
  52482. instance?: Mesh;
  52483. invertUV?: boolean;
  52484. }, scene?: Nullable<Scene>): Mesh;
  52485. /**
  52486. * Creates an custom extruded shape mesh.
  52487. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52488. * * 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.
  52489. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52490. * * 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
  52491. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52492. * * 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
  52493. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52494. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52495. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52496. * * 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
  52497. * * 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
  52498. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52503. * @param name defines the name of the mesh
  52504. * @param options defines the options used to create the mesh
  52505. * @param scene defines the hosting scene
  52506. * @returns the custom extruded shape mesh
  52507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52510. */
  52511. static ExtrudeShapeCustom(name: string, options: {
  52512. shape: Vector3[];
  52513. path: Vector3[];
  52514. scaleFunction?: any;
  52515. rotationFunction?: any;
  52516. ribbonCloseArray?: boolean;
  52517. ribbonClosePath?: boolean;
  52518. cap?: number;
  52519. updatable?: boolean;
  52520. sideOrientation?: number;
  52521. frontUVs?: Vector4;
  52522. backUVs?: Vector4;
  52523. instance?: Mesh;
  52524. invertUV?: boolean;
  52525. }, scene?: Nullable<Scene>): Mesh;
  52526. private static _ExtrudeShapeGeneric;
  52527. }
  52528. }
  52529. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52530. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52531. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52532. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52533. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52534. import { Nullable } from "babylonjs/types";
  52535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52536. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52537. /**
  52538. * AmmoJS Physics plugin
  52539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52540. * @see https://github.com/kripken/ammo.js/
  52541. */
  52542. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52543. private _useDeltaForWorldStep;
  52544. /**
  52545. * Reference to the Ammo library
  52546. */
  52547. bjsAMMO: any;
  52548. /**
  52549. * Created ammoJS world which physics bodies are added to
  52550. */
  52551. world: any;
  52552. /**
  52553. * Name of the plugin
  52554. */
  52555. name: string;
  52556. private _timeStep;
  52557. private _fixedTimeStep;
  52558. private _maxSteps;
  52559. private _tmpQuaternion;
  52560. private _tmpAmmoTransform;
  52561. private _tmpAmmoQuaternion;
  52562. private _tmpAmmoConcreteContactResultCallback;
  52563. private _collisionConfiguration;
  52564. private _dispatcher;
  52565. private _overlappingPairCache;
  52566. private _solver;
  52567. private _softBodySolver;
  52568. private _tmpAmmoVectorA;
  52569. private _tmpAmmoVectorB;
  52570. private _tmpAmmoVectorC;
  52571. private _tmpAmmoVectorD;
  52572. private _tmpContactCallbackResult;
  52573. private _tmpAmmoVectorRCA;
  52574. private _tmpAmmoVectorRCB;
  52575. private _raycastResult;
  52576. private static readonly DISABLE_COLLISION_FLAG;
  52577. private static readonly KINEMATIC_FLAG;
  52578. private static readonly DISABLE_DEACTIVATION_FLAG;
  52579. /**
  52580. * Initializes the ammoJS plugin
  52581. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52582. * @param ammoInjection can be used to inject your own ammo reference
  52583. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52584. */
  52585. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52586. /**
  52587. * Sets the gravity of the physics world (m/(s^2))
  52588. * @param gravity Gravity to set
  52589. */
  52590. setGravity(gravity: Vector3): void;
  52591. /**
  52592. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52593. * @param timeStep timestep to use in seconds
  52594. */
  52595. setTimeStep(timeStep: number): void;
  52596. /**
  52597. * 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)
  52598. * @param fixedTimeStep fixedTimeStep to use in seconds
  52599. */
  52600. setFixedTimeStep(fixedTimeStep: number): void;
  52601. /**
  52602. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52603. * @param maxSteps the maximum number of steps by the physics engine per frame
  52604. */
  52605. setMaxSteps(maxSteps: number): void;
  52606. /**
  52607. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52608. * @returns the current timestep in seconds
  52609. */
  52610. getTimeStep(): number;
  52611. private _isImpostorInContact;
  52612. private _isImpostorPairInContact;
  52613. private _stepSimulation;
  52614. /**
  52615. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52616. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52617. * After the step the babylon meshes are set to the position of the physics imposters
  52618. * @param delta amount of time to step forward
  52619. * @param impostors array of imposters to update before/after the step
  52620. */
  52621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52622. /**
  52623. * Update babylon mesh to match physics world object
  52624. * @param impostor imposter to match
  52625. */
  52626. private _afterSoftStep;
  52627. /**
  52628. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52629. * @param impostor imposter to match
  52630. */
  52631. private _ropeStep;
  52632. /**
  52633. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52634. * @param impostor imposter to match
  52635. */
  52636. private _softbodyOrClothStep;
  52637. private _tmpVector;
  52638. private _tmpMatrix;
  52639. /**
  52640. * Applies an impulse on the imposter
  52641. * @param impostor imposter to apply impulse to
  52642. * @param force amount of force to be applied to the imposter
  52643. * @param contactPoint the location to apply the impulse on the imposter
  52644. */
  52645. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52646. /**
  52647. * Applies a force on the imposter
  52648. * @param impostor imposter to apply force
  52649. * @param force amount of force to be applied to the imposter
  52650. * @param contactPoint the location to apply the force on the imposter
  52651. */
  52652. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52653. /**
  52654. * Creates a physics body using the plugin
  52655. * @param impostor the imposter to create the physics body on
  52656. */
  52657. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52658. /**
  52659. * Removes the physics body from the imposter and disposes of the body's memory
  52660. * @param impostor imposter to remove the physics body from
  52661. */
  52662. removePhysicsBody(impostor: PhysicsImpostor): void;
  52663. /**
  52664. * Generates a joint
  52665. * @param impostorJoint the imposter joint to create the joint with
  52666. */
  52667. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52668. /**
  52669. * Removes a joint
  52670. * @param impostorJoint the imposter joint to remove the joint from
  52671. */
  52672. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52673. private _addMeshVerts;
  52674. /**
  52675. * Initialise the soft body vertices to match its object's (mesh) vertices
  52676. * Softbody vertices (nodes) are in world space and to match this
  52677. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52678. * @param impostor to create the softbody for
  52679. */
  52680. private _softVertexData;
  52681. /**
  52682. * Create an impostor's soft body
  52683. * @param impostor to create the softbody for
  52684. */
  52685. private _createSoftbody;
  52686. /**
  52687. * Create cloth for an impostor
  52688. * @param impostor to create the softbody for
  52689. */
  52690. private _createCloth;
  52691. /**
  52692. * Create rope for an impostor
  52693. * @param impostor to create the softbody for
  52694. */
  52695. private _createRope;
  52696. private _addHullVerts;
  52697. private _createShape;
  52698. /**
  52699. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52700. * @param impostor imposter containing the physics body and babylon object
  52701. */
  52702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52703. /**
  52704. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52705. * @param impostor imposter containing the physics body and babylon object
  52706. * @param newPosition new position
  52707. * @param newRotation new rotation
  52708. */
  52709. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52710. /**
  52711. * If this plugin is supported
  52712. * @returns true if its supported
  52713. */
  52714. isSupported(): boolean;
  52715. /**
  52716. * Sets the linear velocity of the physics body
  52717. * @param impostor imposter to set the velocity on
  52718. * @param velocity velocity to set
  52719. */
  52720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52721. /**
  52722. * Sets the angular velocity of the physics body
  52723. * @param impostor imposter to set the velocity on
  52724. * @param velocity velocity to set
  52725. */
  52726. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52727. /**
  52728. * gets the linear velocity
  52729. * @param impostor imposter to get linear velocity from
  52730. * @returns linear velocity
  52731. */
  52732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52733. /**
  52734. * gets the angular velocity
  52735. * @param impostor imposter to get angular velocity from
  52736. * @returns angular velocity
  52737. */
  52738. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52739. /**
  52740. * Sets the mass of physics body
  52741. * @param impostor imposter to set the mass on
  52742. * @param mass mass to set
  52743. */
  52744. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52745. /**
  52746. * Gets the mass of the physics body
  52747. * @param impostor imposter to get the mass from
  52748. * @returns mass
  52749. */
  52750. getBodyMass(impostor: PhysicsImpostor): number;
  52751. /**
  52752. * Gets friction of the impostor
  52753. * @param impostor impostor to get friction from
  52754. * @returns friction value
  52755. */
  52756. getBodyFriction(impostor: PhysicsImpostor): number;
  52757. /**
  52758. * Sets friction of the impostor
  52759. * @param impostor impostor to set friction on
  52760. * @param friction friction value
  52761. */
  52762. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52763. /**
  52764. * Gets restitution of the impostor
  52765. * @param impostor impostor to get restitution from
  52766. * @returns restitution value
  52767. */
  52768. getBodyRestitution(impostor: PhysicsImpostor): number;
  52769. /**
  52770. * Sets resitution of the impostor
  52771. * @param impostor impostor to set resitution on
  52772. * @param restitution resitution value
  52773. */
  52774. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52775. /**
  52776. * Gets pressure inside the impostor
  52777. * @param impostor impostor to get pressure from
  52778. * @returns pressure value
  52779. */
  52780. getBodyPressure(impostor: PhysicsImpostor): number;
  52781. /**
  52782. * Sets pressure inside a soft body impostor
  52783. * Cloth and rope must remain 0 pressure
  52784. * @param impostor impostor to set pressure on
  52785. * @param pressure pressure value
  52786. */
  52787. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52788. /**
  52789. * Gets stiffness of the impostor
  52790. * @param impostor impostor to get stiffness from
  52791. * @returns pressure value
  52792. */
  52793. getBodyStiffness(impostor: PhysicsImpostor): number;
  52794. /**
  52795. * Sets stiffness of the impostor
  52796. * @param impostor impostor to set stiffness on
  52797. * @param stiffness stiffness value from 0 to 1
  52798. */
  52799. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52800. /**
  52801. * Gets velocityIterations of the impostor
  52802. * @param impostor impostor to get velocity iterations from
  52803. * @returns velocityIterations value
  52804. */
  52805. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52806. /**
  52807. * Sets velocityIterations of the impostor
  52808. * @param impostor impostor to set velocity iterations on
  52809. * @param velocityIterations velocityIterations value
  52810. */
  52811. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52812. /**
  52813. * Gets positionIterations of the impostor
  52814. * @param impostor impostor to get position iterations from
  52815. * @returns positionIterations value
  52816. */
  52817. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52818. /**
  52819. * Sets positionIterations of the impostor
  52820. * @param impostor impostor to set position on
  52821. * @param positionIterations positionIterations value
  52822. */
  52823. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52824. /**
  52825. * Append an anchor to a cloth object
  52826. * @param impostor is the cloth impostor to add anchor to
  52827. * @param otherImpostor is the rigid impostor to anchor to
  52828. * @param width ratio across width from 0 to 1
  52829. * @param height ratio up height from 0 to 1
  52830. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52831. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52832. */
  52833. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52834. /**
  52835. * Append an hook to a rope object
  52836. * @param impostor is the rope impostor to add hook to
  52837. * @param otherImpostor is the rigid impostor to hook to
  52838. * @param length ratio along the rope from 0 to 1
  52839. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52840. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52841. */
  52842. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52843. /**
  52844. * Sleeps the physics body and stops it from being active
  52845. * @param impostor impostor to sleep
  52846. */
  52847. sleepBody(impostor: PhysicsImpostor): void;
  52848. /**
  52849. * Activates the physics body
  52850. * @param impostor impostor to activate
  52851. */
  52852. wakeUpBody(impostor: PhysicsImpostor): void;
  52853. /**
  52854. * Updates the distance parameters of the joint
  52855. * @param joint joint to update
  52856. * @param maxDistance maximum distance of the joint
  52857. * @param minDistance minimum distance of the joint
  52858. */
  52859. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52860. /**
  52861. * Sets a motor on the joint
  52862. * @param joint joint to set motor on
  52863. * @param speed speed of the motor
  52864. * @param maxForce maximum force of the motor
  52865. * @param motorIndex index of the motor
  52866. */
  52867. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52868. /**
  52869. * Sets the motors limit
  52870. * @param joint joint to set limit on
  52871. * @param upperLimit upper limit
  52872. * @param lowerLimit lower limit
  52873. */
  52874. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52875. /**
  52876. * Syncs the position and rotation of a mesh with the impostor
  52877. * @param mesh mesh to sync
  52878. * @param impostor impostor to update the mesh with
  52879. */
  52880. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52881. /**
  52882. * Gets the radius of the impostor
  52883. * @param impostor impostor to get radius from
  52884. * @returns the radius
  52885. */
  52886. getRadius(impostor: PhysicsImpostor): number;
  52887. /**
  52888. * Gets the box size of the impostor
  52889. * @param impostor impostor to get box size from
  52890. * @param result the resulting box size
  52891. */
  52892. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52893. /**
  52894. * Disposes of the impostor
  52895. */
  52896. dispose(): void;
  52897. /**
  52898. * Does a raycast in the physics world
  52899. * @param from when should the ray start?
  52900. * @param to when should the ray end?
  52901. * @returns PhysicsRaycastResult
  52902. */
  52903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52904. }
  52905. }
  52906. declare module "babylonjs/Probes/reflectionProbe" {
  52907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52908. import { Vector3 } from "babylonjs/Maths/math.vector";
  52909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52910. import { Nullable } from "babylonjs/types";
  52911. import { Scene } from "babylonjs/scene";
  52912. module "babylonjs/abstractScene" {
  52913. interface AbstractScene {
  52914. /**
  52915. * The list of reflection probes added to the scene
  52916. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52917. */
  52918. reflectionProbes: Array<ReflectionProbe>;
  52919. /**
  52920. * Removes the given reflection probe from this scene.
  52921. * @param toRemove The reflection probe to remove
  52922. * @returns The index of the removed reflection probe
  52923. */
  52924. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52925. /**
  52926. * Adds the given reflection probe to this scene.
  52927. * @param newReflectionProbe The reflection probe to add
  52928. */
  52929. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52930. }
  52931. }
  52932. /**
  52933. * Class used to generate realtime reflection / refraction cube textures
  52934. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52935. */
  52936. export class ReflectionProbe {
  52937. /** defines the name of the probe */
  52938. name: string;
  52939. private _scene;
  52940. private _renderTargetTexture;
  52941. private _projectionMatrix;
  52942. private _viewMatrix;
  52943. private _target;
  52944. private _add;
  52945. private _attachedMesh;
  52946. private _invertYAxis;
  52947. /** Gets or sets probe position (center of the cube map) */
  52948. position: Vector3;
  52949. /**
  52950. * Creates a new reflection probe
  52951. * @param name defines the name of the probe
  52952. * @param size defines the texture resolution (for each face)
  52953. * @param scene defines the hosting scene
  52954. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52955. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52956. */
  52957. constructor(
  52958. /** defines the name of the probe */
  52959. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52960. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52961. samples: number;
  52962. /** Gets or sets the refresh rate to use (on every frame by default) */
  52963. refreshRate: number;
  52964. /**
  52965. * Gets the hosting scene
  52966. * @returns a Scene
  52967. */
  52968. getScene(): Scene;
  52969. /** Gets the internal CubeTexture used to render to */
  52970. readonly cubeTexture: RenderTargetTexture;
  52971. /** Gets the list of meshes to render */
  52972. readonly renderList: Nullable<AbstractMesh[]>;
  52973. /**
  52974. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52975. * @param mesh defines the mesh to attach to
  52976. */
  52977. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52978. /**
  52979. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52980. * @param renderingGroupId The rendering group id corresponding to its index
  52981. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52982. */
  52983. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52984. /**
  52985. * Clean all associated resources
  52986. */
  52987. dispose(): void;
  52988. /**
  52989. * Converts the reflection probe information to a readable string for debug purpose.
  52990. * @param fullDetails Supports for multiple levels of logging within scene loading
  52991. * @returns the human readable reflection probe info
  52992. */
  52993. toString(fullDetails?: boolean): string;
  52994. /**
  52995. * Get the class name of the relfection probe.
  52996. * @returns "ReflectionProbe"
  52997. */
  52998. getClassName(): string;
  52999. /**
  53000. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53001. * @returns The JSON representation of the texture
  53002. */
  53003. serialize(): any;
  53004. /**
  53005. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53006. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53007. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53008. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53009. * @returns The parsed reflection probe if successful
  53010. */
  53011. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53012. }
  53013. }
  53014. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53015. /** @hidden */
  53016. export var _BabylonLoaderRegistered: boolean;
  53017. }
  53018. declare module "babylonjs/Loading/Plugins/index" {
  53019. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53020. }
  53021. declare module "babylonjs/Loading/index" {
  53022. export * from "babylonjs/Loading/loadingScreen";
  53023. export * from "babylonjs/Loading/Plugins/index";
  53024. export * from "babylonjs/Loading/sceneLoader";
  53025. export * from "babylonjs/Loading/sceneLoaderFlags";
  53026. }
  53027. declare module "babylonjs/Materials/Background/index" {
  53028. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53029. }
  53030. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53031. import { Scene } from "babylonjs/scene";
  53032. import { Color3 } from "babylonjs/Maths/math.color";
  53033. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53035. /**
  53036. * The Physically based simple base material of BJS.
  53037. *
  53038. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53039. * It is used as the base class for both the specGloss and metalRough conventions.
  53040. */
  53041. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53042. /**
  53043. * Number of Simultaneous lights allowed on the material.
  53044. */
  53045. maxSimultaneousLights: number;
  53046. /**
  53047. * If sets to true, disables all the lights affecting the material.
  53048. */
  53049. disableLighting: boolean;
  53050. /**
  53051. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53052. */
  53053. environmentTexture: BaseTexture;
  53054. /**
  53055. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53056. */
  53057. invertNormalMapX: boolean;
  53058. /**
  53059. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53060. */
  53061. invertNormalMapY: boolean;
  53062. /**
  53063. * Normal map used in the model.
  53064. */
  53065. normalTexture: BaseTexture;
  53066. /**
  53067. * Emissivie color used to self-illuminate the model.
  53068. */
  53069. emissiveColor: Color3;
  53070. /**
  53071. * Emissivie texture used to self-illuminate the model.
  53072. */
  53073. emissiveTexture: BaseTexture;
  53074. /**
  53075. * Occlusion Channel Strenght.
  53076. */
  53077. occlusionStrength: number;
  53078. /**
  53079. * Occlusion Texture of the material (adding extra occlusion effects).
  53080. */
  53081. occlusionTexture: BaseTexture;
  53082. /**
  53083. * Defines the alpha limits in alpha test mode.
  53084. */
  53085. alphaCutOff: number;
  53086. /**
  53087. * Gets the current double sided mode.
  53088. */
  53089. /**
  53090. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53091. */
  53092. doubleSided: boolean;
  53093. /**
  53094. * Stores the pre-calculated light information of a mesh in a texture.
  53095. */
  53096. lightmapTexture: BaseTexture;
  53097. /**
  53098. * If true, the light map contains occlusion information instead of lighting info.
  53099. */
  53100. useLightmapAsShadowmap: boolean;
  53101. /**
  53102. * Instantiates a new PBRMaterial instance.
  53103. *
  53104. * @param name The material name
  53105. * @param scene The scene the material will be use in.
  53106. */
  53107. constructor(name: string, scene: Scene);
  53108. getClassName(): string;
  53109. }
  53110. }
  53111. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53112. import { Scene } from "babylonjs/scene";
  53113. import { Color3 } from "babylonjs/Maths/math.color";
  53114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53115. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53116. /**
  53117. * The PBR material of BJS following the metal roughness convention.
  53118. *
  53119. * This fits to the PBR convention in the GLTF definition:
  53120. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53121. */
  53122. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53123. /**
  53124. * The base color has two different interpretations depending on the value of metalness.
  53125. * When the material is a metal, the base color is the specific measured reflectance value
  53126. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53127. * of the material.
  53128. */
  53129. baseColor: Color3;
  53130. /**
  53131. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53132. * well as opacity information in the alpha channel.
  53133. */
  53134. baseTexture: BaseTexture;
  53135. /**
  53136. * Specifies the metallic scalar value of the material.
  53137. * Can also be used to scale the metalness values of the metallic texture.
  53138. */
  53139. metallic: number;
  53140. /**
  53141. * Specifies the roughness scalar value of the material.
  53142. * Can also be used to scale the roughness values of the metallic texture.
  53143. */
  53144. roughness: number;
  53145. /**
  53146. * Texture containing both the metallic value in the B channel and the
  53147. * roughness value in the G channel to keep better precision.
  53148. */
  53149. metallicRoughnessTexture: BaseTexture;
  53150. /**
  53151. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53152. *
  53153. * @param name The material name
  53154. * @param scene The scene the material will be use in.
  53155. */
  53156. constructor(name: string, scene: Scene);
  53157. /**
  53158. * Return the currrent class name of the material.
  53159. */
  53160. getClassName(): string;
  53161. /**
  53162. * Makes a duplicate of the current material.
  53163. * @param name - name to use for the new material.
  53164. */
  53165. clone(name: string): PBRMetallicRoughnessMaterial;
  53166. /**
  53167. * Serialize the material to a parsable JSON object.
  53168. */
  53169. serialize(): any;
  53170. /**
  53171. * Parses a JSON object correponding to the serialize function.
  53172. */
  53173. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53174. }
  53175. }
  53176. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53177. import { Scene } from "babylonjs/scene";
  53178. import { Color3 } from "babylonjs/Maths/math.color";
  53179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53180. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53181. /**
  53182. * The PBR material of BJS following the specular glossiness convention.
  53183. *
  53184. * This fits to the PBR convention in the GLTF definition:
  53185. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53186. */
  53187. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53188. /**
  53189. * Specifies the diffuse color of the material.
  53190. */
  53191. diffuseColor: Color3;
  53192. /**
  53193. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53194. * channel.
  53195. */
  53196. diffuseTexture: BaseTexture;
  53197. /**
  53198. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53199. */
  53200. specularColor: Color3;
  53201. /**
  53202. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53203. */
  53204. glossiness: number;
  53205. /**
  53206. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53207. */
  53208. specularGlossinessTexture: BaseTexture;
  53209. /**
  53210. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53211. *
  53212. * @param name The material name
  53213. * @param scene The scene the material will be use in.
  53214. */
  53215. constructor(name: string, scene: Scene);
  53216. /**
  53217. * Return the currrent class name of the material.
  53218. */
  53219. getClassName(): string;
  53220. /**
  53221. * Makes a duplicate of the current material.
  53222. * @param name - name to use for the new material.
  53223. */
  53224. clone(name: string): PBRSpecularGlossinessMaterial;
  53225. /**
  53226. * Serialize the material to a parsable JSON object.
  53227. */
  53228. serialize(): any;
  53229. /**
  53230. * Parses a JSON object correponding to the serialize function.
  53231. */
  53232. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53233. }
  53234. }
  53235. declare module "babylonjs/Materials/PBR/index" {
  53236. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53237. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53238. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53239. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53240. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53241. }
  53242. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53243. import { Nullable } from "babylonjs/types";
  53244. import { Scene } from "babylonjs/scene";
  53245. import { Matrix } from "babylonjs/Maths/math.vector";
  53246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53247. /**
  53248. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53249. * It can help converting any input color in a desired output one. This can then be used to create effects
  53250. * from sepia, black and white to sixties or futuristic rendering...
  53251. *
  53252. * The only supported format is currently 3dl.
  53253. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53254. */
  53255. export class ColorGradingTexture extends BaseTexture {
  53256. /**
  53257. * The current texture matrix. (will always be identity in color grading texture)
  53258. */
  53259. private _textureMatrix;
  53260. /**
  53261. * The texture URL.
  53262. */
  53263. url: string;
  53264. /**
  53265. * Empty line regex stored for GC.
  53266. */
  53267. private static _noneEmptyLineRegex;
  53268. private _engine;
  53269. /**
  53270. * Instantiates a ColorGradingTexture from the following parameters.
  53271. *
  53272. * @param url The location of the color gradind data (currently only supporting 3dl)
  53273. * @param scene The scene the texture will be used in
  53274. */
  53275. constructor(url: string, scene: Scene);
  53276. /**
  53277. * Returns the texture matrix used in most of the material.
  53278. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53279. */
  53280. getTextureMatrix(): Matrix;
  53281. /**
  53282. * Occurs when the file being loaded is a .3dl LUT file.
  53283. */
  53284. private load3dlTexture;
  53285. /**
  53286. * Starts the loading process of the texture.
  53287. */
  53288. private loadTexture;
  53289. /**
  53290. * Clones the color gradind texture.
  53291. */
  53292. clone(): ColorGradingTexture;
  53293. /**
  53294. * Called during delayed load for textures.
  53295. */
  53296. delayLoad(): void;
  53297. /**
  53298. * Parses a color grading texture serialized by Babylon.
  53299. * @param parsedTexture The texture information being parsedTexture
  53300. * @param scene The scene to load the texture in
  53301. * @param rootUrl The root url of the data assets to load
  53302. * @return A color gradind texture
  53303. */
  53304. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53305. /**
  53306. * Serializes the LUT texture to json format.
  53307. */
  53308. serialize(): any;
  53309. }
  53310. }
  53311. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53313. import { Scene } from "babylonjs/scene";
  53314. import { Nullable } from "babylonjs/types";
  53315. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53316. /**
  53317. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53318. */
  53319. export class EquiRectangularCubeTexture extends BaseTexture {
  53320. /** The six faces of the cube. */
  53321. private static _FacesMapping;
  53322. private _noMipmap;
  53323. private _onLoad;
  53324. private _onError;
  53325. /** The size of the cubemap. */
  53326. private _size;
  53327. /** The buffer of the image. */
  53328. private _buffer;
  53329. /** The width of the input image. */
  53330. private _width;
  53331. /** The height of the input image. */
  53332. private _height;
  53333. /** The URL to the image. */
  53334. url: string;
  53335. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53336. coordinatesMode: number;
  53337. /**
  53338. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53339. * @param url The location of the image
  53340. * @param scene The scene the texture will be used in
  53341. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53342. * @param noMipmap Forces to not generate the mipmap if true
  53343. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53344. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53345. * @param onLoad — defines a callback called when texture is loaded
  53346. * @param onError — defines a callback called if there is an error
  53347. */
  53348. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53349. /**
  53350. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53351. */
  53352. private loadImage;
  53353. /**
  53354. * Convert the image buffer into a cubemap and create a CubeTexture.
  53355. */
  53356. private loadTexture;
  53357. /**
  53358. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53359. * @param buffer The ArrayBuffer that should be converted.
  53360. * @returns The buffer as Float32Array.
  53361. */
  53362. private getFloat32ArrayFromArrayBuffer;
  53363. /**
  53364. * Get the current class name of the texture useful for serialization or dynamic coding.
  53365. * @returns "EquiRectangularCubeTexture"
  53366. */
  53367. getClassName(): string;
  53368. /**
  53369. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53370. * @returns A clone of the current EquiRectangularCubeTexture.
  53371. */
  53372. clone(): EquiRectangularCubeTexture;
  53373. }
  53374. }
  53375. declare module "babylonjs/Misc/tga" {
  53376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53377. /**
  53378. * Based on jsTGALoader - Javascript loader for TGA file
  53379. * By Vincent Thibault
  53380. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53381. */
  53382. export class TGATools {
  53383. private static _TYPE_INDEXED;
  53384. private static _TYPE_RGB;
  53385. private static _TYPE_GREY;
  53386. private static _TYPE_RLE_INDEXED;
  53387. private static _TYPE_RLE_RGB;
  53388. private static _TYPE_RLE_GREY;
  53389. private static _ORIGIN_MASK;
  53390. private static _ORIGIN_SHIFT;
  53391. private static _ORIGIN_BL;
  53392. private static _ORIGIN_BR;
  53393. private static _ORIGIN_UL;
  53394. private static _ORIGIN_UR;
  53395. /**
  53396. * Gets the header of a TGA file
  53397. * @param data defines the TGA data
  53398. * @returns the header
  53399. */
  53400. static GetTGAHeader(data: Uint8Array): any;
  53401. /**
  53402. * Uploads TGA content to a Babylon Texture
  53403. * @hidden
  53404. */
  53405. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53406. /** @hidden */
  53407. 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;
  53408. /** @hidden */
  53409. 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;
  53410. /** @hidden */
  53411. 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;
  53412. /** @hidden */
  53413. 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;
  53414. /** @hidden */
  53415. 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;
  53416. /** @hidden */
  53417. 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;
  53418. }
  53419. }
  53420. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53421. import { Nullable } from "babylonjs/types";
  53422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53423. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53424. /**
  53425. * Implementation of the TGA Texture Loader.
  53426. * @hidden
  53427. */
  53428. export class _TGATextureLoader implements IInternalTextureLoader {
  53429. /**
  53430. * Defines wether the loader supports cascade loading the different faces.
  53431. */
  53432. readonly supportCascades: boolean;
  53433. /**
  53434. * This returns if the loader support the current file information.
  53435. * @param extension defines the file extension of the file being loaded
  53436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53437. * @param fallback defines the fallback internal texture if any
  53438. * @param isBase64 defines whether the texture is encoded as a base64
  53439. * @param isBuffer defines whether the texture data are stored as a buffer
  53440. * @returns true if the loader can load the specified file
  53441. */
  53442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53443. /**
  53444. * Transform the url before loading if required.
  53445. * @param rootUrl the url of the texture
  53446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53447. * @returns the transformed texture
  53448. */
  53449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53450. /**
  53451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53452. * @param rootUrl the url of the texture
  53453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53454. * @returns the fallback texture
  53455. */
  53456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53457. /**
  53458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53459. * @param data contains the texture data
  53460. * @param texture defines the BabylonJS internal texture
  53461. * @param createPolynomials will be true if polynomials have been requested
  53462. * @param onLoad defines the callback to trigger once the texture is ready
  53463. * @param onError defines the callback to trigger in case of error
  53464. */
  53465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53466. /**
  53467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53468. * @param data contains the texture data
  53469. * @param texture defines the BabylonJS internal texture
  53470. * @param callback defines the method to call once ready to upload
  53471. */
  53472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53473. }
  53474. }
  53475. declare module "babylonjs/Misc/basis" {
  53476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53477. /**
  53478. * Info about the .basis files
  53479. */
  53480. class BasisFileInfo {
  53481. /**
  53482. * If the file has alpha
  53483. */
  53484. hasAlpha: boolean;
  53485. /**
  53486. * Info about each image of the basis file
  53487. */
  53488. images: Array<{
  53489. levels: Array<{
  53490. width: number;
  53491. height: number;
  53492. transcodedPixels: ArrayBufferView;
  53493. }>;
  53494. }>;
  53495. }
  53496. /**
  53497. * Result of transcoding a basis file
  53498. */
  53499. class TranscodeResult {
  53500. /**
  53501. * Info about the .basis file
  53502. */
  53503. fileInfo: BasisFileInfo;
  53504. /**
  53505. * Format to use when loading the file
  53506. */
  53507. format: number;
  53508. }
  53509. /**
  53510. * Configuration options for the Basis transcoder
  53511. */
  53512. export class BasisTranscodeConfiguration {
  53513. /**
  53514. * Supported compression formats used to determine the supported output format of the transcoder
  53515. */
  53516. supportedCompressionFormats?: {
  53517. /**
  53518. * etc1 compression format
  53519. */
  53520. etc1?: boolean;
  53521. /**
  53522. * s3tc compression format
  53523. */
  53524. s3tc?: boolean;
  53525. /**
  53526. * pvrtc compression format
  53527. */
  53528. pvrtc?: boolean;
  53529. /**
  53530. * etc2 compression format
  53531. */
  53532. etc2?: boolean;
  53533. };
  53534. /**
  53535. * If mipmap levels should be loaded for transcoded images (Default: true)
  53536. */
  53537. loadMipmapLevels?: boolean;
  53538. /**
  53539. * Index of a single image to load (Default: all images)
  53540. */
  53541. loadSingleImage?: number;
  53542. }
  53543. /**
  53544. * Used to load .Basis files
  53545. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53546. */
  53547. export class BasisTools {
  53548. private static _IgnoreSupportedFormats;
  53549. /**
  53550. * URL to use when loading the basis transcoder
  53551. */
  53552. static JSModuleURL: string;
  53553. /**
  53554. * URL to use when loading the wasm module for the transcoder
  53555. */
  53556. static WasmModuleURL: string;
  53557. /**
  53558. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53559. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53560. * @returns internal format corresponding to the Basis format
  53561. */
  53562. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53563. private static _WorkerPromise;
  53564. private static _Worker;
  53565. private static _actionId;
  53566. private static _CreateWorkerAsync;
  53567. /**
  53568. * Transcodes a loaded image file to compressed pixel data
  53569. * @param imageData image data to transcode
  53570. * @param config configuration options for the transcoding
  53571. * @returns a promise resulting in the transcoded image
  53572. */
  53573. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53574. /**
  53575. * Loads a texture from the transcode result
  53576. * @param texture texture load to
  53577. * @param transcodeResult the result of transcoding the basis file to load from
  53578. */
  53579. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53580. }
  53581. }
  53582. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53583. import { Nullable } from "babylonjs/types";
  53584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53585. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53586. /**
  53587. * Loader for .basis file format
  53588. */
  53589. export class _BasisTextureLoader implements IInternalTextureLoader {
  53590. /**
  53591. * Defines whether the loader supports cascade loading the different faces.
  53592. */
  53593. readonly supportCascades: boolean;
  53594. /**
  53595. * This returns if the loader support the current file information.
  53596. * @param extension defines the file extension of the file being loaded
  53597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53598. * @param fallback defines the fallback internal texture if any
  53599. * @param isBase64 defines whether the texture is encoded as a base64
  53600. * @param isBuffer defines whether the texture data are stored as a buffer
  53601. * @returns true if the loader can load the specified file
  53602. */
  53603. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53604. /**
  53605. * Transform the url before loading if required.
  53606. * @param rootUrl the url of the texture
  53607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53608. * @returns the transformed texture
  53609. */
  53610. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53611. /**
  53612. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53613. * @param rootUrl the url of the texture
  53614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53615. * @returns the fallback texture
  53616. */
  53617. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53618. /**
  53619. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53620. * @param data contains the texture data
  53621. * @param texture defines the BabylonJS internal texture
  53622. * @param createPolynomials will be true if polynomials have been requested
  53623. * @param onLoad defines the callback to trigger once the texture is ready
  53624. * @param onError defines the callback to trigger in case of error
  53625. */
  53626. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53627. /**
  53628. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53629. * @param data contains the texture data
  53630. * @param texture defines the BabylonJS internal texture
  53631. * @param callback defines the method to call once ready to upload
  53632. */
  53633. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53634. }
  53635. }
  53636. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53637. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53638. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53639. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53640. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53641. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53642. }
  53643. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53644. import { Scene } from "babylonjs/scene";
  53645. import { Texture } from "babylonjs/Materials/Textures/texture";
  53646. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53647. /**
  53648. * 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.
  53649. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53651. */
  53652. export class CustomProceduralTexture extends ProceduralTexture {
  53653. private _animate;
  53654. private _time;
  53655. private _config;
  53656. private _texturePath;
  53657. /**
  53658. * Instantiates a new Custom Procedural Texture.
  53659. * 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.
  53660. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53661. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53662. * @param name Define the name of the texture
  53663. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53664. * @param size Define the size of the texture to create
  53665. * @param scene Define the scene the texture belongs to
  53666. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53667. * @param generateMipMaps Define if the texture should creates mip maps or not
  53668. */
  53669. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53670. private _loadJson;
  53671. /**
  53672. * Is the texture ready to be used ? (rendered at least once)
  53673. * @returns true if ready, otherwise, false.
  53674. */
  53675. isReady(): boolean;
  53676. /**
  53677. * Render the texture to its associated render target.
  53678. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53679. */
  53680. render(useCameraPostProcess?: boolean): void;
  53681. /**
  53682. * Update the list of dependant textures samplers in the shader.
  53683. */
  53684. updateTextures(): void;
  53685. /**
  53686. * Update the uniform values of the procedural texture in the shader.
  53687. */
  53688. updateShaderUniforms(): void;
  53689. /**
  53690. * Define if the texture animates or not.
  53691. */
  53692. animate: boolean;
  53693. }
  53694. }
  53695. declare module "babylonjs/Shaders/noise.fragment" {
  53696. /** @hidden */
  53697. export var noisePixelShader: {
  53698. name: string;
  53699. shader: string;
  53700. };
  53701. }
  53702. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53703. import { Nullable } from "babylonjs/types";
  53704. import { Scene } from "babylonjs/scene";
  53705. import { Texture } from "babylonjs/Materials/Textures/texture";
  53706. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53707. import "babylonjs/Shaders/noise.fragment";
  53708. /**
  53709. * Class used to generate noise procedural textures
  53710. */
  53711. export class NoiseProceduralTexture extends ProceduralTexture {
  53712. private _time;
  53713. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53714. brightness: number;
  53715. /** Defines the number of octaves to process */
  53716. octaves: number;
  53717. /** Defines the level of persistence (0.8 by default) */
  53718. persistence: number;
  53719. /** Gets or sets animation speed factor (default is 1) */
  53720. animationSpeedFactor: number;
  53721. /**
  53722. * Creates a new NoiseProceduralTexture
  53723. * @param name defines the name fo the texture
  53724. * @param size defines the size of the texture (default is 256)
  53725. * @param scene defines the hosting scene
  53726. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53727. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53728. */
  53729. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53730. private _updateShaderUniforms;
  53731. protected _getDefines(): string;
  53732. /** Generate the current state of the procedural texture */
  53733. render(useCameraPostProcess?: boolean): void;
  53734. /**
  53735. * Serializes this noise procedural texture
  53736. * @returns a serialized noise procedural texture object
  53737. */
  53738. serialize(): any;
  53739. /**
  53740. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53741. * @param parsedTexture defines parsed texture data
  53742. * @param scene defines the current scene
  53743. * @param rootUrl defines the root URL containing noise procedural texture information
  53744. * @returns a parsed NoiseProceduralTexture
  53745. */
  53746. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53747. }
  53748. }
  53749. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53750. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53751. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53752. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53753. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53754. }
  53755. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53756. import { Nullable } from "babylonjs/types";
  53757. import { Scene } from "babylonjs/scene";
  53758. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53759. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53760. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53761. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53762. /**
  53763. * Raw cube texture where the raw buffers are passed in
  53764. */
  53765. export class RawCubeTexture extends CubeTexture {
  53766. /**
  53767. * Creates a cube texture where the raw buffers are passed in.
  53768. * @param scene defines the scene the texture is attached to
  53769. * @param data defines the array of data to use to create each face
  53770. * @param size defines the size of the textures
  53771. * @param format defines the format of the data
  53772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53773. * @param generateMipMaps defines if the engine should generate the mip levels
  53774. * @param invertY defines if data must be stored with Y axis inverted
  53775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53776. * @param compression defines the compression used (null by default)
  53777. */
  53778. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53779. /**
  53780. * Updates the raw cube texture.
  53781. * @param data defines the data to store
  53782. * @param format defines the data format
  53783. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53784. * @param invertY defines if data must be stored with Y axis inverted
  53785. * @param compression defines the compression used (null by default)
  53786. * @param level defines which level of the texture to update
  53787. */
  53788. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53789. /**
  53790. * Updates a raw cube texture with RGBD encoded data.
  53791. * @param data defines the array of data [mipmap][face] to use to create each face
  53792. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53793. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53794. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53795. * @returns a promsie that resolves when the operation is complete
  53796. */
  53797. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53798. /**
  53799. * Clones the raw cube texture.
  53800. * @return a new cube texture
  53801. */
  53802. clone(): CubeTexture;
  53803. /** @hidden */
  53804. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53805. }
  53806. }
  53807. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53808. import { Scene } from "babylonjs/scene";
  53809. import { Texture } from "babylonjs/Materials/Textures/texture";
  53810. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53811. /**
  53812. * Class used to store 3D textures containing user data
  53813. */
  53814. export class RawTexture3D extends Texture {
  53815. /** Gets or sets the texture format to use */
  53816. format: number;
  53817. private _engine;
  53818. /**
  53819. * Create a new RawTexture3D
  53820. * @param data defines the data of the texture
  53821. * @param width defines the width of the texture
  53822. * @param height defines the height of the texture
  53823. * @param depth defines the depth of the texture
  53824. * @param format defines the texture format to use
  53825. * @param scene defines the hosting scene
  53826. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53827. * @param invertY defines if texture must be stored with Y axis inverted
  53828. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53829. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53830. */
  53831. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53832. /** Gets or sets the texture format to use */
  53833. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53834. /**
  53835. * Update the texture with new data
  53836. * @param data defines the data to store in the texture
  53837. */
  53838. update(data: ArrayBufferView): void;
  53839. }
  53840. }
  53841. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53842. import { Scene } from "babylonjs/scene";
  53843. import { Plane } from "babylonjs/Maths/math.plane";
  53844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53845. /**
  53846. * Creates a refraction texture used by refraction channel of the standard material.
  53847. * It is like a mirror but to see through a material.
  53848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53849. */
  53850. export class RefractionTexture extends RenderTargetTexture {
  53851. /**
  53852. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53853. * 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.
  53854. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53855. */
  53856. refractionPlane: Plane;
  53857. /**
  53858. * Define how deep under the surface we should see.
  53859. */
  53860. depth: number;
  53861. /**
  53862. * Creates a refraction texture used by refraction channel of the standard material.
  53863. * It is like a mirror but to see through a material.
  53864. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53865. * @param name Define the texture name
  53866. * @param size Define the size of the underlying texture
  53867. * @param scene Define the scene the refraction belongs to
  53868. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53869. */
  53870. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53871. /**
  53872. * Clone the refraction texture.
  53873. * @returns the cloned texture
  53874. */
  53875. clone(): RefractionTexture;
  53876. /**
  53877. * Serialize the texture to a JSON representation you could use in Parse later on
  53878. * @returns the serialized JSON representation
  53879. */
  53880. serialize(): any;
  53881. }
  53882. }
  53883. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53884. import { Nullable } from "babylonjs/types";
  53885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53886. import { Matrix } from "babylonjs/Maths/math.vector";
  53887. import { Engine } from "babylonjs/Engines/engine";
  53888. import { Scene } from "babylonjs/scene";
  53889. /**
  53890. * Defines the options related to the creation of an HtmlElementTexture
  53891. */
  53892. export interface IHtmlElementTextureOptions {
  53893. /**
  53894. * Defines wether mip maps should be created or not.
  53895. */
  53896. generateMipMaps?: boolean;
  53897. /**
  53898. * Defines the sampling mode of the texture.
  53899. */
  53900. samplingMode?: number;
  53901. /**
  53902. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53903. */
  53904. engine: Nullable<Engine>;
  53905. /**
  53906. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53907. */
  53908. scene: Nullable<Scene>;
  53909. }
  53910. /**
  53911. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53912. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53913. * is automatically managed.
  53914. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53915. * in your application.
  53916. *
  53917. * As the update is not automatic, you need to call them manually.
  53918. */
  53919. export class HtmlElementTexture extends BaseTexture {
  53920. /**
  53921. * The texture URL.
  53922. */
  53923. element: HTMLVideoElement | HTMLCanvasElement;
  53924. private static readonly DefaultOptions;
  53925. private _textureMatrix;
  53926. private _engine;
  53927. private _isVideo;
  53928. private _generateMipMaps;
  53929. private _samplingMode;
  53930. /**
  53931. * Instantiates a HtmlElementTexture from the following parameters.
  53932. *
  53933. * @param name Defines the name of the texture
  53934. * @param element Defines the video or canvas the texture is filled with
  53935. * @param options Defines the other none mandatory texture creation options
  53936. */
  53937. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53938. private _createInternalTexture;
  53939. /**
  53940. * Returns the texture matrix used in most of the material.
  53941. */
  53942. getTextureMatrix(): Matrix;
  53943. /**
  53944. * Updates the content of the texture.
  53945. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53946. */
  53947. update(invertY?: Nullable<boolean>): void;
  53948. }
  53949. }
  53950. declare module "babylonjs/Materials/Textures/index" {
  53951. export * from "babylonjs/Materials/Textures/baseTexture";
  53952. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53953. export * from "babylonjs/Materials/Textures/cubeTexture";
  53954. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53955. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53956. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53957. export * from "babylonjs/Materials/Textures/internalTexture";
  53958. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53959. export * from "babylonjs/Materials/Textures/Loaders/index";
  53960. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53961. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53962. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53963. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53964. export * from "babylonjs/Materials/Textures/rawTexture";
  53965. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53966. export * from "babylonjs/Materials/Textures/refractionTexture";
  53967. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53968. export * from "babylonjs/Materials/Textures/texture";
  53969. export * from "babylonjs/Materials/Textures/videoTexture";
  53970. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53971. }
  53972. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53973. /**
  53974. * Enum used to define the target of a block
  53975. */
  53976. export enum NodeMaterialBlockTargets {
  53977. /** Vertex shader */
  53978. Vertex = 1,
  53979. /** Fragment shader */
  53980. Fragment = 2,
  53981. /** Neutral */
  53982. Neutral = 4,
  53983. /** Vertex and Fragment */
  53984. VertexAndFragment = 3
  53985. }
  53986. }
  53987. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53988. /**
  53989. * Defines the kind of connection point for node based material
  53990. */
  53991. export enum NodeMaterialBlockConnectionPointTypes {
  53992. /** Float */
  53993. Float = 1,
  53994. /** Int */
  53995. Int = 2,
  53996. /** Vector2 */
  53997. Vector2 = 4,
  53998. /** Vector3 */
  53999. Vector3 = 8,
  54000. /** Vector4 */
  54001. Vector4 = 16,
  54002. /** Color3 */
  54003. Color3 = 32,
  54004. /** Color4 */
  54005. Color4 = 64,
  54006. /** Matrix */
  54007. Matrix = 128,
  54008. /** Detect type based on connection */
  54009. AutoDetect = 1024,
  54010. /** Output type that will be defined by input type */
  54011. BasedOnInput = 2048
  54012. }
  54013. }
  54014. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54016. /**
  54017. * Root class for all node material optimizers
  54018. */
  54019. export class NodeMaterialOptimizer {
  54020. /**
  54021. * Function used to optimize a NodeMaterial graph
  54022. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54023. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54024. */
  54025. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54026. }
  54027. }
  54028. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54032. import { Scene } from "babylonjs/scene";
  54033. /**
  54034. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54035. */
  54036. export class TransformBlock extends NodeMaterialBlock {
  54037. /**
  54038. * Defines the value to use to complement W value to transform it to a Vector4
  54039. */
  54040. complementW: number;
  54041. /**
  54042. * Defines the value to use to complement z value to transform it to a Vector4
  54043. */
  54044. complementZ: number;
  54045. /**
  54046. * Creates a new TransformBlock
  54047. * @param name defines the block name
  54048. */
  54049. constructor(name: string);
  54050. /**
  54051. * Gets the current class name
  54052. * @returns the class name
  54053. */
  54054. getClassName(): string;
  54055. /**
  54056. * Gets the vector input
  54057. */
  54058. readonly vector: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the output component
  54061. */
  54062. readonly output: NodeMaterialConnectionPoint;
  54063. /**
  54064. * Gets the matrix transform input
  54065. */
  54066. readonly transform: NodeMaterialConnectionPoint;
  54067. protected _buildBlock(state: NodeMaterialBuildState): this;
  54068. serialize(): any;
  54069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54070. }
  54071. }
  54072. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54076. /**
  54077. * Block used to output the vertex position
  54078. */
  54079. export class VertexOutputBlock extends NodeMaterialBlock {
  54080. /**
  54081. * Creates a new VertexOutputBlock
  54082. * @param name defines the block name
  54083. */
  54084. constructor(name: string);
  54085. /**
  54086. * Gets the current class name
  54087. * @returns the class name
  54088. */
  54089. getClassName(): string;
  54090. /**
  54091. * Gets the vector input component
  54092. */
  54093. readonly vector: NodeMaterialConnectionPoint;
  54094. protected _buildBlock(state: NodeMaterialBuildState): this;
  54095. }
  54096. }
  54097. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54101. /**
  54102. * Block used to output the final color
  54103. */
  54104. export class FragmentOutputBlock extends NodeMaterialBlock {
  54105. /**
  54106. * Create a new FragmentOutputBlock
  54107. * @param name defines the block name
  54108. */
  54109. constructor(name: string);
  54110. /**
  54111. * Gets the current class name
  54112. * @returns the class name
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Gets the rgba input component
  54117. */
  54118. readonly rgba: NodeMaterialConnectionPoint;
  54119. /**
  54120. * Gets the rgb input component
  54121. */
  54122. readonly rgb: NodeMaterialConnectionPoint;
  54123. /**
  54124. * Gets the a input component
  54125. */
  54126. readonly a: NodeMaterialConnectionPoint;
  54127. protected _buildBlock(state: NodeMaterialBuildState): this;
  54128. }
  54129. }
  54130. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54132. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54133. import { Scene } from "babylonjs/scene";
  54134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54135. import { Matrix } from "babylonjs/Maths/math.vector";
  54136. import { Mesh } from "babylonjs/Meshes/mesh";
  54137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54138. import { Observable } from "babylonjs/Misc/observable";
  54139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54140. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54141. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54142. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54143. import { Nullable } from "babylonjs/types";
  54144. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54145. /**
  54146. * Interface used to configure the node material editor
  54147. */
  54148. export interface INodeMaterialEditorOptions {
  54149. /** Define the URl to load node editor script */
  54150. editorURL?: string;
  54151. }
  54152. /** @hidden */
  54153. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54154. /** BONES */
  54155. NUM_BONE_INFLUENCERS: number;
  54156. BonesPerMesh: number;
  54157. BONETEXTURE: boolean;
  54158. /** MORPH TARGETS */
  54159. MORPHTARGETS: boolean;
  54160. MORPHTARGETS_NORMAL: boolean;
  54161. MORPHTARGETS_TANGENT: boolean;
  54162. MORPHTARGETS_UV: boolean;
  54163. NUM_MORPH_INFLUENCERS: number;
  54164. /** IMAGE PROCESSING */
  54165. IMAGEPROCESSING: boolean;
  54166. VIGNETTE: boolean;
  54167. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54168. VIGNETTEBLENDMODEOPAQUE: boolean;
  54169. TONEMAPPING: boolean;
  54170. TONEMAPPING_ACES: boolean;
  54171. CONTRAST: boolean;
  54172. EXPOSURE: boolean;
  54173. COLORCURVES: boolean;
  54174. COLORGRADING: boolean;
  54175. COLORGRADING3D: boolean;
  54176. SAMPLER3DGREENDEPTH: boolean;
  54177. SAMPLER3DBGRMAP: boolean;
  54178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54179. constructor();
  54180. setValue(name: string, value: boolean): void;
  54181. }
  54182. /**
  54183. * Class used to configure NodeMaterial
  54184. */
  54185. export interface INodeMaterialOptions {
  54186. /**
  54187. * Defines if blocks should emit comments
  54188. */
  54189. emitComments: boolean;
  54190. }
  54191. /**
  54192. * Class used to create a node based material built by assembling shader blocks
  54193. */
  54194. export class NodeMaterial extends PushMaterial {
  54195. private static _BuildIdGenerator;
  54196. private _options;
  54197. private _vertexCompilationState;
  54198. private _fragmentCompilationState;
  54199. private _sharedData;
  54200. private _buildId;
  54201. private _buildWasSuccessful;
  54202. private _cachedWorldViewMatrix;
  54203. private _cachedWorldViewProjectionMatrix;
  54204. private _optimizers;
  54205. private _animationFrame;
  54206. /** Define the URl to load node editor script */
  54207. static EditorURL: string;
  54208. private BJSNODEMATERIALEDITOR;
  54209. /** Get the inspector from bundle or global */
  54210. private _getGlobalNodeMaterialEditor;
  54211. /**
  54212. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54213. */
  54214. ignoreAlpha: boolean;
  54215. /**
  54216. * Defines the maximum number of lights that can be used in the material
  54217. */
  54218. maxSimultaneousLights: number;
  54219. /**
  54220. * Observable raised when the material is built
  54221. */
  54222. onBuildObservable: Observable<NodeMaterial>;
  54223. /**
  54224. * Gets or sets the root nodes of the material vertex shader
  54225. */
  54226. _vertexOutputNodes: NodeMaterialBlock[];
  54227. /**
  54228. * Gets or sets the root nodes of the material fragment (pixel) shader
  54229. */
  54230. _fragmentOutputNodes: NodeMaterialBlock[];
  54231. /** Gets or sets options to control the node material overall behavior */
  54232. options: INodeMaterialOptions;
  54233. /**
  54234. * Default configuration related to image processing available in the standard Material.
  54235. */
  54236. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54237. /**
  54238. * Gets the image processing configuration used either in this material.
  54239. */
  54240. /**
  54241. * Sets the Default image processing configuration used either in the this material.
  54242. *
  54243. * If sets to null, the scene one is in use.
  54244. */
  54245. imageProcessingConfiguration: ImageProcessingConfiguration;
  54246. /**
  54247. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54248. */
  54249. attachedBlocks: NodeMaterialBlock[];
  54250. /**
  54251. * Create a new node based material
  54252. * @param name defines the material name
  54253. * @param scene defines the hosting scene
  54254. * @param options defines creation option
  54255. */
  54256. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54257. /**
  54258. * Gets the current class name of the material e.g. "NodeMaterial"
  54259. * @returns the class name
  54260. */
  54261. getClassName(): string;
  54262. /**
  54263. * Keep track of the image processing observer to allow dispose and replace.
  54264. */
  54265. private _imageProcessingObserver;
  54266. /**
  54267. * Attaches a new image processing configuration to the Standard Material.
  54268. * @param configuration
  54269. */
  54270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54271. /**
  54272. * Get a block by its name
  54273. * @param name defines the name of the block to retrieve
  54274. * @returns the required block or null if not found
  54275. */
  54276. getBlockByName(name: string): NodeMaterialBlock | null;
  54277. /**
  54278. * Gets the list of input blocks attached to this material
  54279. * @returns an array of InputBlocks
  54280. */
  54281. getInputBlocks(): InputBlock[];
  54282. /**
  54283. * Adds a new optimizer to the list of optimizers
  54284. * @param optimizer defines the optimizers to add
  54285. * @returns the current material
  54286. */
  54287. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54288. /**
  54289. * Remove an optimizer from the list of optimizers
  54290. * @param optimizer defines the optimizers to remove
  54291. * @returns the current material
  54292. */
  54293. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54294. /**
  54295. * Add a new block to the list of output nodes
  54296. * @param node defines the node to add
  54297. * @returns the current material
  54298. */
  54299. addOutputNode(node: NodeMaterialBlock): this;
  54300. /**
  54301. * Remove a block from the list of root nodes
  54302. * @param node defines the node to remove
  54303. * @returns the current material
  54304. */
  54305. removeOutputNode(node: NodeMaterialBlock): this;
  54306. private _addVertexOutputNode;
  54307. private _removeVertexOutputNode;
  54308. private _addFragmentOutputNode;
  54309. private _removeFragmentOutputNode;
  54310. /**
  54311. * Specifies if the material will require alpha blending
  54312. * @returns a boolean specifying if alpha blending is needed
  54313. */
  54314. needAlphaBlending(): boolean;
  54315. /**
  54316. * Specifies if this material should be rendered in alpha test mode
  54317. * @returns a boolean specifying if an alpha test is needed.
  54318. */
  54319. needAlphaTesting(): boolean;
  54320. private _initializeBlock;
  54321. private _resetDualBlocks;
  54322. /**
  54323. * Build the material and generates the inner effect
  54324. * @param verbose defines if the build should log activity
  54325. */
  54326. build(verbose?: boolean): void;
  54327. /**
  54328. * Runs an otpimization phase to try to improve the shader code
  54329. */
  54330. optimize(): void;
  54331. private _prepareDefinesForAttributes;
  54332. /**
  54333. * Get if the submesh is ready to be used and all its information available.
  54334. * Child classes can use it to update shaders
  54335. * @param mesh defines the mesh to check
  54336. * @param subMesh defines which submesh to check
  54337. * @param useInstances specifies that instances should be used
  54338. * @returns a boolean indicating that the submesh is ready or not
  54339. */
  54340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54341. /**
  54342. * Get a string representing the shaders built by the current node graph
  54343. */
  54344. readonly compiledShaders: string;
  54345. /**
  54346. * Binds the world matrix to the material
  54347. * @param world defines the world transformation matrix
  54348. */
  54349. bindOnlyWorldMatrix(world: Matrix): void;
  54350. /**
  54351. * Binds the submesh to this material by preparing the effect and shader to draw
  54352. * @param world defines the world transformation matrix
  54353. * @param mesh defines the mesh containing the submesh
  54354. * @param subMesh defines the submesh to bind the material to
  54355. */
  54356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54357. /**
  54358. * Gets the active textures from the material
  54359. * @returns an array of textures
  54360. */
  54361. getActiveTextures(): BaseTexture[];
  54362. /**
  54363. * Specifies if the material uses a texture
  54364. * @param texture defines the texture to check against the material
  54365. * @returns a boolean specifying if the material uses the texture
  54366. */
  54367. hasTexture(texture: BaseTexture): boolean;
  54368. /**
  54369. * Disposes the material
  54370. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54371. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54372. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54373. */
  54374. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54375. /** Creates the node editor window. */
  54376. private _createNodeEditor;
  54377. /**
  54378. * Launch the node material editor
  54379. * @param config Define the configuration of the editor
  54380. * @return a promise fulfilled when the node editor is visible
  54381. */
  54382. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54383. /**
  54384. * Clear the current material
  54385. */
  54386. clear(): void;
  54387. /**
  54388. * Clear the current material and set it to a default state
  54389. */
  54390. setToDefault(): void;
  54391. private _gatherBlocks;
  54392. /**
  54393. * Serializes this material in a JSON representation
  54394. * @returns the serialized material object
  54395. */
  54396. serialize(): any;
  54397. /**
  54398. * Clear the current graph and load a new one from a serialization object
  54399. * @param source defines the JSON representation of the material
  54400. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54401. */
  54402. loadFromSerialization(source: any, rootUrl?: string): void;
  54403. /**
  54404. * Creates a node material from parsed material data
  54405. * @param source defines the JSON representation of the material
  54406. * @param scene defines the hosting scene
  54407. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54408. * @returns a new node material
  54409. */
  54410. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54411. /**
  54412. * Creates a new node material set to default basic configuration
  54413. * @param name defines the name of the material
  54414. * @param scene defines the hosting scene
  54415. * @returns a new NodeMaterial
  54416. */
  54417. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54418. }
  54419. }
  54420. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54427. import { Effect } from "babylonjs/Materials/effect";
  54428. import { Mesh } from "babylonjs/Meshes/mesh";
  54429. import { Nullable } from "babylonjs/types";
  54430. import { Scene } from "babylonjs/scene";
  54431. /**
  54432. * Block used to read a texture from a sampler
  54433. */
  54434. export class TextureBlock extends NodeMaterialBlock {
  54435. private _defineName;
  54436. private _samplerName;
  54437. private _transformedUVName;
  54438. private _textureTransformName;
  54439. private _textureInfoName;
  54440. private _mainUVName;
  54441. private _mainUVDefineName;
  54442. /**
  54443. * Gets or sets the texture associated with the node
  54444. */
  54445. texture: Nullable<BaseTexture>;
  54446. /**
  54447. * Create a new TextureBlock
  54448. * @param name defines the block name
  54449. */
  54450. constructor(name: string);
  54451. /**
  54452. * Gets the current class name
  54453. * @returns the class name
  54454. */
  54455. getClassName(): string;
  54456. /**
  54457. * Gets the uv input component
  54458. */
  54459. readonly uv: NodeMaterialConnectionPoint;
  54460. /**
  54461. * Gets the rgba output component
  54462. */
  54463. readonly rgba: NodeMaterialConnectionPoint;
  54464. /**
  54465. * Gets the rgb output component
  54466. */
  54467. readonly rgb: NodeMaterialConnectionPoint;
  54468. /**
  54469. * Gets the r output component
  54470. */
  54471. readonly r: NodeMaterialConnectionPoint;
  54472. /**
  54473. * Gets the g output component
  54474. */
  54475. readonly g: NodeMaterialConnectionPoint;
  54476. /**
  54477. * Gets the b output component
  54478. */
  54479. readonly b: NodeMaterialConnectionPoint;
  54480. /**
  54481. * Gets the a output component
  54482. */
  54483. readonly a: NodeMaterialConnectionPoint;
  54484. autoConfigure(): void;
  54485. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54487. isReady(): boolean;
  54488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54489. private _injectVertexCode;
  54490. private _writeOutput;
  54491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54492. serialize(): any;
  54493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54494. }
  54495. }
  54496. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54497. /**
  54498. * Enum used to define well known values e.g. values automatically provided by the system
  54499. */
  54500. export enum NodeMaterialWellKnownValues {
  54501. /** World */
  54502. World = 1,
  54503. /** View */
  54504. View = 2,
  54505. /** Projection */
  54506. Projection = 3,
  54507. /** ViewProjection */
  54508. ViewProjection = 4,
  54509. /** WorldView */
  54510. WorldView = 5,
  54511. /** WorldViewProjection */
  54512. WorldViewProjection = 6,
  54513. /** CameraPosition */
  54514. CameraPosition = 7,
  54515. /** Fog Color */
  54516. FogColor = 8
  54517. }
  54518. }
  54519. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54523. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54525. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54526. import { Effect } from "babylonjs/Materials/effect";
  54527. import { Mesh } from "babylonjs/Meshes/mesh";
  54528. import { Nullable } from "babylonjs/types";
  54529. import { Scene } from "babylonjs/scene";
  54530. /**
  54531. * Block used to read a reflection texture from a sampler
  54532. */
  54533. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54534. private _define3DName;
  54535. private _defineCubicName;
  54536. private _defineExplicitName;
  54537. private _defineProjectionName;
  54538. private _defineLocalCubicName;
  54539. private _defineSphericalName;
  54540. private _definePlanarName;
  54541. private _defineEquirectangularName;
  54542. private _defineMirroredEquirectangularFixedName;
  54543. private _defineEquirectangularFixedName;
  54544. private _defineSkyboxName;
  54545. private _cubeSamplerName;
  54546. private _2DSamplerName;
  54547. private _positionUVWName;
  54548. private _directionWName;
  54549. private _reflectionCoordsName;
  54550. private _reflection2DCoordsName;
  54551. private _reflectionColorName;
  54552. private _reflectionMatrixName;
  54553. /**
  54554. * Gets or sets the texture associated with the node
  54555. */
  54556. texture: Nullable<BaseTexture>;
  54557. /**
  54558. * Create a new TextureBlock
  54559. * @param name defines the block name
  54560. */
  54561. constructor(name: string);
  54562. /**
  54563. * Gets the current class name
  54564. * @returns the class name
  54565. */
  54566. getClassName(): string;
  54567. /**
  54568. * Gets the world position input component
  54569. */
  54570. readonly position: NodeMaterialConnectionPoint;
  54571. /**
  54572. * Gets the world position input component
  54573. */
  54574. readonly worldPosition: NodeMaterialConnectionPoint;
  54575. /**
  54576. * Gets the world normal input component
  54577. */
  54578. readonly worldNormal: NodeMaterialConnectionPoint;
  54579. /**
  54580. * Gets the world input component
  54581. */
  54582. readonly world: NodeMaterialConnectionPoint;
  54583. /**
  54584. * Gets the camera (or eye) position component
  54585. */
  54586. readonly cameraPosition: NodeMaterialConnectionPoint;
  54587. /**
  54588. * Gets the view input component
  54589. */
  54590. readonly view: NodeMaterialConnectionPoint;
  54591. /**
  54592. * Gets the rgb output component
  54593. */
  54594. readonly rgb: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Gets the r output component
  54597. */
  54598. readonly r: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the g output component
  54601. */
  54602. readonly g: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the b output component
  54605. */
  54606. readonly b: NodeMaterialConnectionPoint;
  54607. autoConfigure(): void;
  54608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54609. isReady(): boolean;
  54610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54611. private _injectVertexCode;
  54612. private _writeOutput;
  54613. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54614. serialize(): any;
  54615. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54616. }
  54617. }
  54618. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54621. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54622. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54623. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54624. /**
  54625. * Class used to store shared data between 2 NodeMaterialBuildState
  54626. */
  54627. export class NodeMaterialBuildStateSharedData {
  54628. /**
  54629. * Gets the list of emitted varyings
  54630. */
  54631. temps: string[];
  54632. /**
  54633. * Gets the list of emitted varyings
  54634. */
  54635. varyings: string[];
  54636. /**
  54637. * Gets the varying declaration string
  54638. */
  54639. varyingDeclaration: string;
  54640. /**
  54641. * Input blocks
  54642. */
  54643. inputBlocks: InputBlock[];
  54644. /**
  54645. * Input blocks
  54646. */
  54647. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  54648. /**
  54649. * Bindable blocks (Blocks that need to set data to the effect)
  54650. */
  54651. bindableBlocks: NodeMaterialBlock[];
  54652. /**
  54653. * List of blocks that can provide a compilation fallback
  54654. */
  54655. blocksWithFallbacks: NodeMaterialBlock[];
  54656. /**
  54657. * List of blocks that can provide a define update
  54658. */
  54659. blocksWithDefines: NodeMaterialBlock[];
  54660. /**
  54661. * List of blocks that can provide a repeatable content
  54662. */
  54663. repeatableContentBlocks: NodeMaterialBlock[];
  54664. /**
  54665. * List of blocks that can provide a dynamic list of uniforms
  54666. */
  54667. dynamicUniformBlocks: NodeMaterialBlock[];
  54668. /**
  54669. * List of blocks that can block the isReady function for the material
  54670. */
  54671. blockingBlocks: NodeMaterialBlock[];
  54672. /**
  54673. * Gets the list of animated inputs
  54674. */
  54675. animatedInputs: InputBlock[];
  54676. /**
  54677. * Build Id used to avoid multiple recompilations
  54678. */
  54679. buildId: number;
  54680. /** List of emitted variables */
  54681. variableNames: {
  54682. [key: string]: number;
  54683. };
  54684. /** List of emitted defines */
  54685. defineNames: {
  54686. [key: string]: number;
  54687. };
  54688. /** Should emit comments? */
  54689. emitComments: boolean;
  54690. /** Emit build activity */
  54691. verbose: boolean;
  54692. /**
  54693. * Gets the compilation hints emitted at compilation time
  54694. */
  54695. hints: {
  54696. needWorldViewMatrix: boolean;
  54697. needWorldViewProjectionMatrix: boolean;
  54698. needAlphaBlending: boolean;
  54699. needAlphaTesting: boolean;
  54700. };
  54701. /**
  54702. * List of compilation checks
  54703. */
  54704. checks: {
  54705. emitVertex: boolean;
  54706. emitFragment: boolean;
  54707. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54708. };
  54709. /** Creates a new shared data */
  54710. constructor();
  54711. /**
  54712. * Emits console errors and exceptions if there is a failing check
  54713. */
  54714. emitErrors(): void;
  54715. }
  54716. }
  54717. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54718. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54719. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54720. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54721. /**
  54722. * Class used to store node based material build state
  54723. */
  54724. export class NodeMaterialBuildState {
  54725. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54726. supportUniformBuffers: boolean;
  54727. /**
  54728. * Gets the list of emitted attributes
  54729. */
  54730. attributes: string[];
  54731. /**
  54732. * Gets the list of emitted uniforms
  54733. */
  54734. uniforms: string[];
  54735. /**
  54736. * Gets the list of emitted uniform buffers
  54737. */
  54738. uniformBuffers: string[];
  54739. /**
  54740. * Gets the list of emitted samplers
  54741. */
  54742. samplers: string[];
  54743. /**
  54744. * Gets the list of emitted functions
  54745. */
  54746. functions: {
  54747. [key: string]: string;
  54748. };
  54749. /**
  54750. * Gets the target of the compilation state
  54751. */
  54752. target: NodeMaterialBlockTargets;
  54753. /**
  54754. * Gets the list of emitted counters
  54755. */
  54756. counters: {
  54757. [key: string]: number;
  54758. };
  54759. /**
  54760. * Shared data between multiple NodeMaterialBuildState instances
  54761. */
  54762. sharedData: NodeMaterialBuildStateSharedData;
  54763. /** @hidden */
  54764. _vertexState: NodeMaterialBuildState;
  54765. /** @hidden */
  54766. _attributeDeclaration: string;
  54767. /** @hidden */
  54768. _uniformDeclaration: string;
  54769. /** @hidden */
  54770. _samplerDeclaration: string;
  54771. /** @hidden */
  54772. _varyingTransfer: string;
  54773. private _repeatableContentAnchorIndex;
  54774. /** @hidden */
  54775. _builtCompilationString: string;
  54776. /**
  54777. * Gets the emitted compilation strings
  54778. */
  54779. compilationString: string;
  54780. /**
  54781. * Finalize the compilation strings
  54782. * @param state defines the current compilation state
  54783. */
  54784. finalize(state: NodeMaterialBuildState): void;
  54785. /** @hidden */
  54786. readonly _repeatableContentAnchor: string;
  54787. /** @hidden */
  54788. _getFreeVariableName(prefix: string): string;
  54789. /** @hidden */
  54790. _getFreeDefineName(prefix: string): string;
  54791. /** @hidden */
  54792. _excludeVariableName(name: string): void;
  54793. /** @hidden */
  54794. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54795. /** @hidden */
  54796. _emitFunction(name: string, code: string, comments: string): void;
  54797. /** @hidden */
  54798. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54799. replaceStrings?: {
  54800. search: RegExp;
  54801. replace: string;
  54802. }[];
  54803. repeatKey?: string;
  54804. }): string;
  54805. /** @hidden */
  54806. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54807. repeatKey?: string;
  54808. removeAttributes?: boolean;
  54809. removeUniforms?: boolean;
  54810. removeVaryings?: boolean;
  54811. removeIfDef?: boolean;
  54812. replaceStrings?: {
  54813. search: RegExp;
  54814. replace: string;
  54815. }[];
  54816. }, storeKey?: string): void;
  54817. /** @hidden */
  54818. _registerTempVariable(name: string): boolean;
  54819. /** @hidden */
  54820. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54821. /** @hidden */
  54822. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54823. }
  54824. }
  54825. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54826. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54828. import { Nullable } from "babylonjs/types";
  54829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54830. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54831. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54833. import { Mesh } from "babylonjs/Meshes/mesh";
  54834. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54835. import { Scene } from "babylonjs/scene";
  54836. /**
  54837. * Defines a block that can be used inside a node based material
  54838. */
  54839. export class NodeMaterialBlock {
  54840. private _buildId;
  54841. private _buildTarget;
  54842. private _target;
  54843. private _isFinalMerger;
  54844. private _isInput;
  54845. /** @hidden */
  54846. _inputs: NodeMaterialConnectionPoint[];
  54847. /** @hidden */
  54848. _outputs: NodeMaterialConnectionPoint[];
  54849. /**
  54850. * Gets or sets the name of the block
  54851. */
  54852. name: string;
  54853. /**
  54854. * Gets or sets the unique id of the node
  54855. */
  54856. uniqueId: number;
  54857. /**
  54858. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54859. */
  54860. readonly isFinalMerger: boolean;
  54861. /**
  54862. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54863. */
  54864. readonly isInput: boolean;
  54865. /**
  54866. * Gets or sets the build Id
  54867. */
  54868. buildId: number;
  54869. /**
  54870. * Gets or sets the target of the block
  54871. */
  54872. target: NodeMaterialBlockTargets;
  54873. /**
  54874. * Gets the list of input points
  54875. */
  54876. readonly inputs: NodeMaterialConnectionPoint[];
  54877. /** Gets the list of output points */
  54878. readonly outputs: NodeMaterialConnectionPoint[];
  54879. /**
  54880. * Find an input by its name
  54881. * @param name defines the name of the input to look for
  54882. * @returns the input or null if not found
  54883. */
  54884. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54885. /**
  54886. * Find an output by its name
  54887. * @param name defines the name of the outputto look for
  54888. * @returns the output or null if not found
  54889. */
  54890. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54891. /**
  54892. * Creates a new NodeMaterialBlock
  54893. * @param name defines the block name
  54894. * @param target defines the target of that block (Vertex by default)
  54895. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54896. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54897. */
  54898. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54899. /**
  54900. * Initialize the block and prepare the context for build
  54901. * @param state defines the state that will be used for the build
  54902. */
  54903. initialize(state: NodeMaterialBuildState): void;
  54904. /**
  54905. * Bind data to effect. Will only be called for blocks with isBindable === true
  54906. * @param effect defines the effect to bind data to
  54907. * @param nodeMaterial defines the hosting NodeMaterial
  54908. * @param mesh defines the mesh that will be rendered
  54909. */
  54910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54911. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54912. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54913. protected _writeFloat(value: number): string;
  54914. /**
  54915. * Gets the current class name e.g. "NodeMaterialBlock"
  54916. * @returns the class name
  54917. */
  54918. getClassName(): string;
  54919. /**
  54920. * Register a new input. Must be called inside a block constructor
  54921. * @param name defines the connection point name
  54922. * @param type defines the connection point type
  54923. * @param isOptional defines a boolean indicating that this input can be omitted
  54924. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54925. * @returns the current block
  54926. */
  54927. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54928. /**
  54929. * Register a new output. Must be called inside a block constructor
  54930. * @param name defines the connection point name
  54931. * @param type defines the connection point type
  54932. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54933. * @returns the current block
  54934. */
  54935. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54936. /**
  54937. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54938. * @param forOutput defines an optional connection point to check compatibility with
  54939. * @returns the first available input or null
  54940. */
  54941. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54942. /**
  54943. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54944. * @param forBlock defines an optional block to check compatibility with
  54945. * @returns the first available input or null
  54946. */
  54947. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54948. /**
  54949. * Gets the sibling of the given output
  54950. * @param current defines the current output
  54951. * @returns the next output in the list or null
  54952. */
  54953. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54954. /**
  54955. * Connect current block with another block
  54956. * @param other defines the block to connect with
  54957. * @param options define the various options to help pick the right connections
  54958. * @returns the current block
  54959. */
  54960. connectTo(other: NodeMaterialBlock, options?: {
  54961. input?: string;
  54962. output?: string;
  54963. outputSwizzle?: string;
  54964. }): this | undefined;
  54965. protected _buildBlock(state: NodeMaterialBuildState): void;
  54966. /**
  54967. * Add uniforms, samplers and uniform buffers at compilation time
  54968. * @param state defines the state to update
  54969. * @param nodeMaterial defines the node material requesting the update
  54970. * @param defines defines the material defines to update
  54971. */
  54972. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54973. /**
  54974. * Add potential fallbacks if shader compilation fails
  54975. * @param mesh defines the mesh to be rendered
  54976. * @param fallbacks defines the current prioritized list of fallbacks
  54977. */
  54978. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54979. /**
  54980. * Update defines for shader compilation
  54981. * @param mesh defines the mesh to be rendered
  54982. * @param nodeMaterial defines the node material requesting the update
  54983. * @param defines defines the material defines to update
  54984. * @param useInstances specifies that instances should be used
  54985. */
  54986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54987. /**
  54988. * Initialize defines for shader compilation
  54989. * @param mesh defines the mesh to be rendered
  54990. * @param nodeMaterial defines the node material requesting the update
  54991. * @param defines defines the material defines to be prepared
  54992. * @param useInstances specifies that instances should be used
  54993. */
  54994. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54995. /**
  54996. * Lets the block try to connect some inputs automatically
  54997. */
  54998. autoConfigure(): void;
  54999. /**
  55000. * Function called when a block is declared as repeatable content generator
  55001. * @param vertexShaderState defines the current compilation state for the vertex shader
  55002. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55003. * @param mesh defines the mesh to be rendered
  55004. * @param defines defines the material defines to update
  55005. */
  55006. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55007. /**
  55008. * Checks if the block is ready
  55009. * @param mesh defines the mesh to be rendered
  55010. * @param nodeMaterial defines the node material requesting the update
  55011. * @param defines defines the material defines to update
  55012. * @param useInstances specifies that instances should be used
  55013. * @returns true if the block is ready
  55014. */
  55015. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55016. private _processBuild;
  55017. /**
  55018. * Compile the current node and generate the shader code
  55019. * @param state defines the current compilation state (uniforms, samplers, current string)
  55020. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  55021. * @returns true if already built
  55022. */
  55023. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  55024. /**
  55025. * Clone the current block to a new identical block
  55026. * @param scene defines the hosting scene
  55027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55028. * @returns a copy of the current block
  55029. */
  55030. clone(scene: Scene, rootUrl?: string): NodeMaterialBlock | null;
  55031. /**
  55032. * Serializes this block in a JSON representation
  55033. * @returns the serialized block object
  55034. */
  55035. serialize(): any;
  55036. /** @hidden */
  55037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55038. }
  55039. }
  55040. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55041. /**
  55042. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55043. */
  55044. export enum NodeMaterialBlockConnectionPointMode {
  55045. /** Value is an uniform */
  55046. Uniform = 0,
  55047. /** Value is a mesh attribute */
  55048. Attribute = 1,
  55049. /** Value is a varying between vertex and fragment shaders */
  55050. Varying = 2,
  55051. /** Mode is undefined */
  55052. Undefined = 3
  55053. }
  55054. }
  55055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55056. /**
  55057. * Enum defining the type of animations supported by InputBlock
  55058. */
  55059. export enum AnimatedInputBlockTypes {
  55060. /** No animation */
  55061. None = 0,
  55062. /** Time based animation. Will only work for floats */
  55063. Time = 1
  55064. }
  55065. }
  55066. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55068. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55069. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55070. import { Nullable } from "babylonjs/types";
  55071. import { Effect } from "babylonjs/Materials/effect";
  55072. import { Matrix } from "babylonjs/Maths/math.vector";
  55073. import { Scene } from "babylonjs/scene";
  55074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55076. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55077. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55078. /**
  55079. * Block used to expose an input value
  55080. */
  55081. export class InputBlock extends NodeMaterialBlock {
  55082. private _mode;
  55083. private _associatedVariableName;
  55084. private _storedValue;
  55085. private _valueCallback;
  55086. private _type;
  55087. private _animationType;
  55088. /** @hidden */
  55089. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55090. /** Gets or sets a boolean indicating that this input can be edited in the Inspector */
  55091. visibleInInspector: boolean;
  55092. /**
  55093. * Gets or sets the connection point type (default is float)
  55094. */
  55095. readonly type: NodeMaterialBlockConnectionPointTypes;
  55096. /**
  55097. * Creates a new InputBlock
  55098. * @param name defines the block name
  55099. * @param target defines the target of that block (Vertex by default)
  55100. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55101. */
  55102. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55103. /**
  55104. * Gets the output component
  55105. */
  55106. readonly output: NodeMaterialConnectionPoint;
  55107. /**
  55108. * Set the source of this connection point to a vertex attribute
  55109. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55110. * @returns the current connection point
  55111. */
  55112. setAsAttribute(attributeName?: string): InputBlock;
  55113. /**
  55114. * Set the source of this connection point to a well known value
  55115. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55116. * @returns the current connection point
  55117. */
  55118. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55119. /**
  55120. * Gets or sets the value of that point.
  55121. * Please note that this value will be ignored if valueCallback is defined
  55122. */
  55123. value: any;
  55124. /**
  55125. * Gets or sets a callback used to get the value of that point.
  55126. * Please note that setting this value will force the connection point to ignore the value property
  55127. */
  55128. valueCallback: () => any;
  55129. /**
  55130. * Gets or sets the associated variable name in the shader
  55131. */
  55132. associatedVariableName: string;
  55133. /** Gets or sets the type of animation applied to the input */
  55134. animationType: AnimatedInputBlockTypes;
  55135. /**
  55136. * Gets a boolean indicating that this connection point not defined yet
  55137. */
  55138. readonly isUndefined: boolean;
  55139. /**
  55140. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55141. * In this case the connection point name must be the name of the uniform to use.
  55142. * Can only be set on inputs
  55143. */
  55144. isUniform: boolean;
  55145. /**
  55146. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55147. * In this case the connection point name must be the name of the attribute to use
  55148. * Can only be set on inputs
  55149. */
  55150. isAttribute: boolean;
  55151. /**
  55152. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55153. * Can only be set on exit points
  55154. */
  55155. isVarying: boolean;
  55156. /**
  55157. * Gets a boolean indicating that the current connection point is a well known value
  55158. */
  55159. readonly isWellKnownValue: boolean;
  55160. /**
  55161. * Gets or sets the current well known value or null if not defined as well know value
  55162. */
  55163. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55164. /**
  55165. * Gets the current class name
  55166. * @returns the class name
  55167. */
  55168. getClassName(): string;
  55169. /**
  55170. * Animate the input if animationType !== None
  55171. * @param scene defines the rendering scene
  55172. */
  55173. animate(scene: Scene): void;
  55174. private _emitDefine;
  55175. /**
  55176. * Set the input block to its default value (based on its type)
  55177. */
  55178. setDefaultValue(): void;
  55179. private _emit;
  55180. /** @hidden */
  55181. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55182. /** @hidden */
  55183. _transmit(effect: Effect, scene: Scene): void;
  55184. protected _buildBlock(state: NodeMaterialBuildState): void;
  55185. serialize(): any;
  55186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55187. }
  55188. }
  55189. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55190. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55191. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55192. import { Nullable } from "babylonjs/types";
  55193. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55195. /**
  55196. * Defines a connection point for a block
  55197. */
  55198. export class NodeMaterialConnectionPoint {
  55199. /** @hidden */
  55200. _ownerBlock: NodeMaterialBlock;
  55201. /** @hidden */
  55202. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55203. private _endpoints;
  55204. private _associatedVariableName;
  55205. /** @hidden */
  55206. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55207. private _type;
  55208. /** @hidden */
  55209. _enforceAssociatedVariableName: boolean;
  55210. /**
  55211. * Gets or sets the additional types supported byt this connection point
  55212. */
  55213. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55214. /**
  55215. * Gets or sets the associated variable name in the shader
  55216. */
  55217. associatedVariableName: string;
  55218. /**
  55219. * Gets or sets the connection point type (default is float)
  55220. */
  55221. type: NodeMaterialBlockConnectionPointTypes;
  55222. /**
  55223. * Gets or sets the connection point name
  55224. */
  55225. name: string;
  55226. /**
  55227. * Gets or sets a boolean indicating that this connection point can be omitted
  55228. */
  55229. isOptional: boolean;
  55230. /**
  55231. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55232. */
  55233. define: string;
  55234. /** Gets or sets the target of that connection point */
  55235. target: NodeMaterialBlockTargets;
  55236. /**
  55237. * Gets a boolean indicating that the current point is connected
  55238. */
  55239. readonly isConnected: boolean;
  55240. /**
  55241. * Gets a boolean indicating that the current point is connected to an input block
  55242. */
  55243. readonly isConnectedToInputBlock: boolean;
  55244. /**
  55245. * Gets a the connected input block (if any)
  55246. */
  55247. readonly connectInputBlock: Nullable<InputBlock>;
  55248. /** Get the other side of the connection (if any) */
  55249. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55250. /** Get the block that owns this connection point */
  55251. readonly ownerBlock: NodeMaterialBlock;
  55252. /** Get the block connected on the other side of this connection (if any) */
  55253. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55254. /** Get the block connected on the endpoints of this connection (if any) */
  55255. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55256. /** Gets the list of connected endpoints */
  55257. readonly endpoints: NodeMaterialConnectionPoint[];
  55258. /** Gets a boolean indicating if that output point is connected to at least one input */
  55259. readonly hasEndpoints: boolean;
  55260. /**
  55261. * Creates a new connection point
  55262. * @param name defines the connection point name
  55263. * @param ownerBlock defines the block hosting this connection point
  55264. */
  55265. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55266. /**
  55267. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55268. * @returns the class name
  55269. */
  55270. getClassName(): string;
  55271. /**
  55272. * Gets an boolean indicating if the current point can be connected to another point
  55273. * @param connectionPoint defines the other connection point
  55274. * @returns true if the connection is possible
  55275. */
  55276. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55277. /**
  55278. * Connect this point to another connection point
  55279. * @param connectionPoint defines the other connection point
  55280. * @returns the current connection point
  55281. */
  55282. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55283. /**
  55284. * Disconnect this point from one of his endpoint
  55285. * @param endpoint defines the other connection point
  55286. * @returns the current connection point
  55287. */
  55288. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55289. /**
  55290. * Serializes this point in a JSON representation
  55291. * @returns the serialized point object
  55292. */
  55293. serialize(): any;
  55294. }
  55295. }
  55296. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55300. import { Mesh } from "babylonjs/Meshes/mesh";
  55301. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55304. /**
  55305. * Block used to add support for vertex skinning (bones)
  55306. */
  55307. export class BonesBlock extends NodeMaterialBlock {
  55308. /**
  55309. * Creates a new BonesBlock
  55310. * @param name defines the block name
  55311. */
  55312. constructor(name: string);
  55313. /**
  55314. * Initialize the block and prepare the context for build
  55315. * @param state defines the state that will be used for the build
  55316. */
  55317. initialize(state: NodeMaterialBuildState): void;
  55318. /**
  55319. * Gets the current class name
  55320. * @returns the class name
  55321. */
  55322. getClassName(): string;
  55323. /**
  55324. * Gets the matrix indices input component
  55325. */
  55326. readonly matricesIndices: NodeMaterialConnectionPoint;
  55327. /**
  55328. * Gets the matrix weights input component
  55329. */
  55330. readonly matricesWeights: NodeMaterialConnectionPoint;
  55331. /**
  55332. * Gets the extra matrix indices input component
  55333. */
  55334. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55335. /**
  55336. * Gets the extra matrix weights input component
  55337. */
  55338. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55339. /**
  55340. * Gets the world input component
  55341. */
  55342. readonly world: NodeMaterialConnectionPoint;
  55343. /**
  55344. * Gets the output component
  55345. */
  55346. readonly output: NodeMaterialConnectionPoint;
  55347. autoConfigure(): void;
  55348. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55351. protected _buildBlock(state: NodeMaterialBuildState): this;
  55352. }
  55353. }
  55354. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55359. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55360. /**
  55361. * Block used to add support for instances
  55362. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55363. */
  55364. export class InstancesBlock extends NodeMaterialBlock {
  55365. /**
  55366. * Creates a new InstancesBlock
  55367. * @param name defines the block name
  55368. */
  55369. constructor(name: string);
  55370. /**
  55371. * Gets the current class name
  55372. * @returns the class name
  55373. */
  55374. getClassName(): string;
  55375. /**
  55376. * Gets the first world row input component
  55377. */
  55378. readonly world0: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the second world row input component
  55381. */
  55382. readonly world1: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the third world row input component
  55385. */
  55386. readonly world2: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the forth world row input component
  55389. */
  55390. readonly world3: NodeMaterialConnectionPoint;
  55391. /**
  55392. * Gets the world input component
  55393. */
  55394. readonly world: NodeMaterialConnectionPoint;
  55395. /**
  55396. * Gets the output component
  55397. */
  55398. readonly output: NodeMaterialConnectionPoint;
  55399. autoConfigure(): void;
  55400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55401. protected _buildBlock(state: NodeMaterialBuildState): this;
  55402. }
  55403. }
  55404. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55410. import { Effect } from "babylonjs/Materials/effect";
  55411. import { Mesh } from "babylonjs/Meshes/mesh";
  55412. /**
  55413. * Block used to add morph targets support to vertex shader
  55414. */
  55415. export class MorphTargetsBlock extends NodeMaterialBlock {
  55416. private _repeatableContentAnchor;
  55417. private _repeatebleContentGenerated;
  55418. /**
  55419. * Create a new MorphTargetsBlock
  55420. * @param name defines the block name
  55421. */
  55422. constructor(name: string);
  55423. /**
  55424. * Gets the current class name
  55425. * @returns the class name
  55426. */
  55427. getClassName(): string;
  55428. /**
  55429. * Gets the position input component
  55430. */
  55431. readonly position: NodeMaterialConnectionPoint;
  55432. /**
  55433. * Gets the normal input component
  55434. */
  55435. readonly normal: NodeMaterialConnectionPoint;
  55436. /**
  55437. * Gets the tangent input component
  55438. */
  55439. readonly tangent: NodeMaterialConnectionPoint;
  55440. /**
  55441. * Gets the tangent input component
  55442. */
  55443. readonly uv: NodeMaterialConnectionPoint;
  55444. /**
  55445. * Gets the position output component
  55446. */
  55447. readonly positionOutput: NodeMaterialConnectionPoint;
  55448. /**
  55449. * Gets the normal output component
  55450. */
  55451. readonly normalOutput: NodeMaterialConnectionPoint;
  55452. /**
  55453. * Gets the tangent output component
  55454. */
  55455. readonly tangentOutput: NodeMaterialConnectionPoint;
  55456. /**
  55457. * Gets the tangent output component
  55458. */
  55459. readonly uvOutput: NodeMaterialConnectionPoint;
  55460. initialize(state: NodeMaterialBuildState): void;
  55461. autoConfigure(): void;
  55462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55464. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55465. protected _buildBlock(state: NodeMaterialBuildState): this;
  55466. }
  55467. }
  55468. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55469. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55470. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55471. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55472. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55473. }
  55474. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55478. /**
  55479. * Block used to add an alpha test in the fragment shader
  55480. */
  55481. export class AlphaTestBlock extends NodeMaterialBlock {
  55482. /**
  55483. * Gets or sets the alpha value where alpha testing happens
  55484. */
  55485. alphaCutOff: number;
  55486. /**
  55487. * Create a new AlphaTestBlock
  55488. * @param name defines the block name
  55489. */
  55490. constructor(name: string);
  55491. /**
  55492. * Gets the current class name
  55493. * @returns the class name
  55494. */
  55495. getClassName(): string;
  55496. /**
  55497. * Gets the color input component
  55498. */
  55499. readonly color: NodeMaterialConnectionPoint;
  55500. /**
  55501. * Gets the alpha input component
  55502. */
  55503. readonly alpha: NodeMaterialConnectionPoint;
  55504. protected _buildBlock(state: NodeMaterialBuildState): this;
  55505. }
  55506. }
  55507. declare module "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock" {
  55508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55511. /**
  55512. * Block used to compute fresnel value
  55513. */
  55514. export class FresnelBlock extends NodeMaterialBlock {
  55515. /**
  55516. * Create a new FresnelBlock
  55517. * @param name defines the block name
  55518. */
  55519. constructor(name: string);
  55520. /**
  55521. * Gets the current class name
  55522. * @returns the class name
  55523. */
  55524. getClassName(): string;
  55525. /**
  55526. * Gets the world position input component
  55527. */
  55528. readonly worldPosition: NodeMaterialConnectionPoint;
  55529. /**
  55530. * Gets the world normal input component
  55531. */
  55532. readonly worldNormal: NodeMaterialConnectionPoint;
  55533. /**
  55534. * Gets the camera (or eye) position component
  55535. */
  55536. readonly cameraPosition: NodeMaterialConnectionPoint;
  55537. /**
  55538. * Gets the bias input component
  55539. */
  55540. readonly bias: NodeMaterialConnectionPoint;
  55541. /**
  55542. * Gets the camera (or eye) position component
  55543. */
  55544. readonly power: NodeMaterialConnectionPoint;
  55545. /**
  55546. * Gets the fresnel output component
  55547. */
  55548. readonly fresnel: NodeMaterialConnectionPoint;
  55549. autoConfigure(): void;
  55550. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55551. }
  55552. }
  55553. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55558. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55559. import { Effect } from "babylonjs/Materials/effect";
  55560. import { Mesh } from "babylonjs/Meshes/mesh";
  55561. /**
  55562. * Block used to add image processing support to fragment shader
  55563. */
  55564. export class ImageProcessingBlock extends NodeMaterialBlock {
  55565. /**
  55566. * Create a new ImageProcessingBlock
  55567. * @param name defines the block name
  55568. */
  55569. constructor(name: string);
  55570. /**
  55571. * Gets the current class name
  55572. * @returns the class name
  55573. */
  55574. getClassName(): string;
  55575. /**
  55576. * Gets the color input component
  55577. */
  55578. readonly color: NodeMaterialConnectionPoint;
  55579. /**
  55580. * Gets the output component
  55581. */
  55582. readonly output: NodeMaterialConnectionPoint;
  55583. /**
  55584. * Initialize the block and prepare the context for build
  55585. * @param state defines the state that will be used for the build
  55586. */
  55587. initialize(state: NodeMaterialBuildState): void;
  55588. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55591. protected _buildBlock(state: NodeMaterialBuildState): this;
  55592. }
  55593. }
  55594. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55595. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55596. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55597. export * from "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock";
  55598. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55599. }
  55600. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55603. import { Mesh } from "babylonjs/Meshes/mesh";
  55604. import { Effect } from "babylonjs/Materials/effect";
  55605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55607. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55608. /**
  55609. * Block used to add support for scene fog
  55610. */
  55611. export class FogBlock extends NodeMaterialBlock {
  55612. private _fogDistanceName;
  55613. private _fogParameters;
  55614. /**
  55615. * Create a new FogBlock
  55616. * @param name defines the block name
  55617. */
  55618. constructor(name: string);
  55619. /**
  55620. * Gets the current class name
  55621. * @returns the class name
  55622. */
  55623. getClassName(): string;
  55624. /**
  55625. * Gets the world position input component
  55626. */
  55627. readonly worldPosition: NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the view input component
  55630. */
  55631. readonly view: NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the color input component
  55634. */
  55635. readonly color: NodeMaterialConnectionPoint;
  55636. /**
  55637. * Gets the fog color input component
  55638. */
  55639. readonly fogColor: NodeMaterialConnectionPoint;
  55640. /**
  55641. * Gets the output component
  55642. */
  55643. readonly output: NodeMaterialConnectionPoint;
  55644. autoConfigure(): void;
  55645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55647. protected _buildBlock(state: NodeMaterialBuildState): this;
  55648. }
  55649. }
  55650. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55655. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55656. import { Effect } from "babylonjs/Materials/effect";
  55657. import { Mesh } from "babylonjs/Meshes/mesh";
  55658. import { Light } from "babylonjs/Lights/light";
  55659. import { Nullable } from "babylonjs/types";
  55660. import { Scene } from "babylonjs/scene";
  55661. /**
  55662. * Block used to add light in the fragment shader
  55663. */
  55664. export class LightBlock extends NodeMaterialBlock {
  55665. private _lightId;
  55666. /**
  55667. * Gets or sets the light associated with this block
  55668. */
  55669. light: Nullable<Light>;
  55670. /**
  55671. * Create a new LightBlock
  55672. * @param name defines the block name
  55673. */
  55674. constructor(name: string);
  55675. /**
  55676. * Gets the current class name
  55677. * @returns the class name
  55678. */
  55679. getClassName(): string;
  55680. /**
  55681. * Gets the world position input component
  55682. */
  55683. readonly worldPosition: NodeMaterialConnectionPoint;
  55684. /**
  55685. * Gets the world normal input component
  55686. */
  55687. readonly worldNormal: NodeMaterialConnectionPoint;
  55688. /**
  55689. * Gets the camera (or eye) position component
  55690. */
  55691. readonly cameraPosition: NodeMaterialConnectionPoint;
  55692. /**
  55693. * Gets the diffuse output component
  55694. */
  55695. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55696. /**
  55697. * Gets the specular output component
  55698. */
  55699. readonly specularOutput: NodeMaterialConnectionPoint;
  55700. autoConfigure(): void;
  55701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55702. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55704. private _injectVertexCode;
  55705. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55706. serialize(): any;
  55707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55708. }
  55709. }
  55710. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55711. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55712. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55713. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55714. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55715. }
  55716. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55717. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55718. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55719. }
  55720. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55724. /**
  55725. * Block used to multiply 2 values
  55726. */
  55727. export class MultiplyBlock extends NodeMaterialBlock {
  55728. /**
  55729. * Creates a new MultiplyBlock
  55730. * @param name defines the block name
  55731. */
  55732. constructor(name: string);
  55733. /**
  55734. * Gets the current class name
  55735. * @returns the class name
  55736. */
  55737. getClassName(): string;
  55738. /**
  55739. * Gets the left operand input component
  55740. */
  55741. readonly left: NodeMaterialConnectionPoint;
  55742. /**
  55743. * Gets the right operand input component
  55744. */
  55745. readonly right: NodeMaterialConnectionPoint;
  55746. /**
  55747. * Gets the output component
  55748. */
  55749. readonly output: NodeMaterialConnectionPoint;
  55750. protected _buildBlock(state: NodeMaterialBuildState): this;
  55751. }
  55752. }
  55753. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55757. /**
  55758. * Block used to add 2 vectors
  55759. */
  55760. export class AddBlock extends NodeMaterialBlock {
  55761. /**
  55762. * Creates a new AddBlock
  55763. * @param name defines the block name
  55764. */
  55765. constructor(name: string);
  55766. /**
  55767. * Gets the current class name
  55768. * @returns the class name
  55769. */
  55770. getClassName(): string;
  55771. /**
  55772. * Gets the left operand input component
  55773. */
  55774. readonly left: NodeMaterialConnectionPoint;
  55775. /**
  55776. * Gets the right operand input component
  55777. */
  55778. readonly right: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the output component
  55781. */
  55782. readonly output: NodeMaterialConnectionPoint;
  55783. protected _buildBlock(state: NodeMaterialBuildState): this;
  55784. }
  55785. }
  55786. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55790. /**
  55791. * Block used to scale a vector by a float
  55792. */
  55793. export class ScaleBlock extends NodeMaterialBlock {
  55794. /**
  55795. * Creates a new ScaleBlock
  55796. * @param name defines the block name
  55797. */
  55798. constructor(name: string);
  55799. /**
  55800. * Gets the current class name
  55801. * @returns the class name
  55802. */
  55803. getClassName(): string;
  55804. /**
  55805. * Gets the input component
  55806. */
  55807. readonly input: NodeMaterialConnectionPoint;
  55808. /**
  55809. * Gets the factor input component
  55810. */
  55811. readonly factor: NodeMaterialConnectionPoint;
  55812. /**
  55813. * Gets the output component
  55814. */
  55815. readonly output: NodeMaterialConnectionPoint;
  55816. protected _buildBlock(state: NodeMaterialBuildState): this;
  55817. }
  55818. }
  55819. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55823. /**
  55824. * Block used to clamp a float
  55825. */
  55826. export class ClampBlock extends NodeMaterialBlock {
  55827. /** Gets or sets the minimum range */
  55828. minimum: number;
  55829. /** Gets or sets the maximum range */
  55830. maximum: number;
  55831. /**
  55832. * Creates a new ClampBlock
  55833. * @param name defines the block name
  55834. */
  55835. constructor(name: string);
  55836. /**
  55837. * Gets the current class name
  55838. * @returns the class name
  55839. */
  55840. getClassName(): string;
  55841. /**
  55842. * Gets the value input component
  55843. */
  55844. readonly value: NodeMaterialConnectionPoint;
  55845. /**
  55846. * Gets the output component
  55847. */
  55848. readonly output: NodeMaterialConnectionPoint;
  55849. protected _buildBlock(state: NodeMaterialBuildState): this;
  55850. }
  55851. }
  55852. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55856. /**
  55857. * Block used to apply a cross product between 2 vectors
  55858. */
  55859. export class CrossBlock extends NodeMaterialBlock {
  55860. /**
  55861. * Creates a new CrossBlock
  55862. * @param name defines the block name
  55863. */
  55864. constructor(name: string);
  55865. /**
  55866. * Gets the current class name
  55867. * @returns the class name
  55868. */
  55869. getClassName(): string;
  55870. /**
  55871. * Gets the left operand input component
  55872. */
  55873. readonly left: NodeMaterialConnectionPoint;
  55874. /**
  55875. * Gets the right operand input component
  55876. */
  55877. readonly right: NodeMaterialConnectionPoint;
  55878. /**
  55879. * Gets the output component
  55880. */
  55881. readonly output: NodeMaterialConnectionPoint;
  55882. protected _buildBlock(state: NodeMaterialBuildState): this;
  55883. }
  55884. }
  55885. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55889. /**
  55890. * Block used to apply a dot product between 2 vectors
  55891. */
  55892. export class DotBlock extends NodeMaterialBlock {
  55893. /**
  55894. * Creates a new DotBlock
  55895. * @param name defines the block name
  55896. */
  55897. constructor(name: string);
  55898. /**
  55899. * Gets the current class name
  55900. * @returns the class name
  55901. */
  55902. getClassName(): string;
  55903. /**
  55904. * Gets the left operand input component
  55905. */
  55906. readonly left: NodeMaterialConnectionPoint;
  55907. /**
  55908. * Gets the right operand input component
  55909. */
  55910. readonly right: NodeMaterialConnectionPoint;
  55911. /**
  55912. * Gets the output component
  55913. */
  55914. readonly output: NodeMaterialConnectionPoint;
  55915. protected _buildBlock(state: NodeMaterialBuildState): this;
  55916. }
  55917. }
  55918. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55922. import { Vector2 } from "babylonjs/Maths/math.vector";
  55923. /**
  55924. * Block used to remap a float from a range to a new one
  55925. */
  55926. export class RemapBlock extends NodeMaterialBlock {
  55927. /**
  55928. * Gets or sets the source range
  55929. */
  55930. sourceRange: Vector2;
  55931. /**
  55932. * Gets or sets the target range
  55933. */
  55934. targetRange: Vector2;
  55935. /**
  55936. * Creates a new RemapBlock
  55937. * @param name defines the block name
  55938. */
  55939. constructor(name: string);
  55940. /**
  55941. * Gets the current class name
  55942. * @returns the class name
  55943. */
  55944. getClassName(): string;
  55945. /**
  55946. * Gets the input component
  55947. */
  55948. readonly input: NodeMaterialConnectionPoint;
  55949. /**
  55950. * Gets the output component
  55951. */
  55952. readonly output: NodeMaterialConnectionPoint;
  55953. protected _buildBlock(state: NodeMaterialBuildState): this;
  55954. }
  55955. }
  55956. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55960. /**
  55961. * Block used to normalize a vector
  55962. */
  55963. export class NormalizeBlock extends NodeMaterialBlock {
  55964. /**
  55965. * Creates a new NormalizeBlock
  55966. * @param name defines the block name
  55967. */
  55968. constructor(name: string);
  55969. /**
  55970. * Gets the current class name
  55971. * @returns the class name
  55972. */
  55973. getClassName(): string;
  55974. /**
  55975. * Gets the input component
  55976. */
  55977. readonly input: NodeMaterialConnectionPoint;
  55978. /**
  55979. * Gets the output component
  55980. */
  55981. readonly output: NodeMaterialConnectionPoint;
  55982. protected _buildBlock(state: NodeMaterialBuildState): this;
  55983. }
  55984. }
  55985. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  55986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55989. /**
  55990. * Operations supported by the Trigonometry block
  55991. */
  55992. export enum TrigonometryBlockOperations {
  55993. /** Cos */
  55994. Cos = 0,
  55995. /** Sin */
  55996. Sin = 1,
  55997. /** Abs */
  55998. Abs = 2
  55999. }
  56000. /**
  56001. * Block used to apply trigonometry operation to floats
  56002. */
  56003. export class TrigonometryBlock extends NodeMaterialBlock {
  56004. /**
  56005. * Gets or sets the operation applied by the block
  56006. */
  56007. operation: TrigonometryBlockOperations;
  56008. /**
  56009. * Creates a new TrigonometryBlock
  56010. * @param name defines the block name
  56011. */
  56012. constructor(name: string);
  56013. /**
  56014. * Gets the current class name
  56015. * @returns the class name
  56016. */
  56017. getClassName(): string;
  56018. /**
  56019. * Gets the input component
  56020. */
  56021. readonly input: NodeMaterialConnectionPoint;
  56022. /**
  56023. * Gets the output component
  56024. */
  56025. readonly output: NodeMaterialConnectionPoint;
  56026. protected _buildBlock(state: NodeMaterialBuildState): this;
  56027. }
  56028. }
  56029. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56033. /**
  56034. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56035. */
  56036. export class ColorMergerBlock extends NodeMaterialBlock {
  56037. /**
  56038. * Create a new ColorMergerBlock
  56039. * @param name defines the block name
  56040. */
  56041. constructor(name: string);
  56042. /**
  56043. * Gets the current class name
  56044. * @returns the class name
  56045. */
  56046. getClassName(): string;
  56047. /**
  56048. * Gets the r component (input)
  56049. */
  56050. readonly r: NodeMaterialConnectionPoint;
  56051. /**
  56052. * Gets the g component (input)
  56053. */
  56054. readonly g: NodeMaterialConnectionPoint;
  56055. /**
  56056. * Gets the b component (input)
  56057. */
  56058. readonly b: NodeMaterialConnectionPoint;
  56059. /**
  56060. * Gets the a component (input)
  56061. */
  56062. readonly a: NodeMaterialConnectionPoint;
  56063. /**
  56064. * Gets the rgba component (output)
  56065. */
  56066. readonly rgba: NodeMaterialConnectionPoint;
  56067. /**
  56068. * Gets the rgb component (output)
  56069. */
  56070. readonly rgb: NodeMaterialConnectionPoint;
  56071. protected _buildBlock(state: NodeMaterialBuildState): this;
  56072. }
  56073. }
  56074. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56078. /**
  56079. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56080. */
  56081. export class VectorMergerBlock extends NodeMaterialBlock {
  56082. /**
  56083. * Create a new VectorMergerBlock
  56084. * @param name defines the block name
  56085. */
  56086. constructor(name: string);
  56087. /**
  56088. * Gets the current class name
  56089. * @returns the class name
  56090. */
  56091. getClassName(): string;
  56092. /**
  56093. * Gets the x component (input)
  56094. */
  56095. readonly x: NodeMaterialConnectionPoint;
  56096. /**
  56097. * Gets the y component (input)
  56098. */
  56099. readonly y: NodeMaterialConnectionPoint;
  56100. /**
  56101. * Gets the z component (input)
  56102. */
  56103. readonly z: NodeMaterialConnectionPoint;
  56104. /**
  56105. * Gets the w component (input)
  56106. */
  56107. readonly w: NodeMaterialConnectionPoint;
  56108. /**
  56109. * Gets the xyzw component (output)
  56110. */
  56111. readonly xyzw: NodeMaterialConnectionPoint;
  56112. /**
  56113. * Gets the xyz component (output)
  56114. */
  56115. readonly xyz: NodeMaterialConnectionPoint;
  56116. /**
  56117. * Gets the xy component (output)
  56118. */
  56119. readonly xy: NodeMaterialConnectionPoint;
  56120. protected _buildBlock(state: NodeMaterialBuildState): this;
  56121. }
  56122. }
  56123. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56127. /**
  56128. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56129. */
  56130. export class ColorSplitterBlock extends NodeMaterialBlock {
  56131. /**
  56132. * Create a new ColorSplitterBlock
  56133. * @param name defines the block name
  56134. */
  56135. constructor(name: string);
  56136. /**
  56137. * Gets the current class name
  56138. * @returns the class name
  56139. */
  56140. getClassName(): string;
  56141. /**
  56142. * Gets the rgba component (input)
  56143. */
  56144. readonly rgba: NodeMaterialConnectionPoint;
  56145. /**
  56146. * Gets the rgb component (input)
  56147. */
  56148. readonly rgbIn: NodeMaterialConnectionPoint;
  56149. /**
  56150. * Gets the rgb component (output)
  56151. */
  56152. readonly rgbOut: NodeMaterialConnectionPoint;
  56153. /**
  56154. * Gets the r component (output)
  56155. */
  56156. readonly r: NodeMaterialConnectionPoint;
  56157. /**
  56158. * Gets the g component (output)
  56159. */
  56160. readonly g: NodeMaterialConnectionPoint;
  56161. /**
  56162. * Gets the b component (output)
  56163. */
  56164. readonly b: NodeMaterialConnectionPoint;
  56165. /**
  56166. * Gets the a component (output)
  56167. */
  56168. readonly a: NodeMaterialConnectionPoint;
  56169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56170. }
  56171. }
  56172. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56176. /**
  56177. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56178. */
  56179. export class VectorSplitterBlock extends NodeMaterialBlock {
  56180. /**
  56181. * Create a new VectorSplitterBlock
  56182. * @param name defines the block name
  56183. */
  56184. constructor(name: string);
  56185. /**
  56186. * Gets the current class name
  56187. * @returns the class name
  56188. */
  56189. getClassName(): string;
  56190. /**
  56191. * Gets the xyzw component (input)
  56192. */
  56193. readonly xyzw: NodeMaterialConnectionPoint;
  56194. /**
  56195. * Gets the xyz component (input)
  56196. */
  56197. readonly xyzIn: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the xy component (input)
  56200. */
  56201. readonly xyIn: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the xyz component (output)
  56204. */
  56205. readonly xyzOut: NodeMaterialConnectionPoint;
  56206. /**
  56207. * Gets the xy component (output)
  56208. */
  56209. readonly xyOut: NodeMaterialConnectionPoint;
  56210. /**
  56211. * Gets the x component (output)
  56212. */
  56213. readonly x: NodeMaterialConnectionPoint;
  56214. /**
  56215. * Gets the y component (output)
  56216. */
  56217. readonly y: NodeMaterialConnectionPoint;
  56218. /**
  56219. * Gets the z component (output)
  56220. */
  56221. readonly z: NodeMaterialConnectionPoint;
  56222. /**
  56223. * Gets the w component (output)
  56224. */
  56225. readonly w: NodeMaterialConnectionPoint;
  56226. protected _buildBlock(state: NodeMaterialBuildState): this;
  56227. }
  56228. }
  56229. declare module "babylonjs/Materials/Node/Blocks/index" {
  56230. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56231. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56232. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56233. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56234. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56235. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56236. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56237. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56238. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56239. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56240. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56241. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56242. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56243. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56244. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  56245. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  56246. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  56247. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  56248. }
  56249. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56250. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56251. }
  56252. declare module "babylonjs/Materials/Node/index" {
  56253. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56254. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56255. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56256. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56257. export * from "babylonjs/Materials/Node/nodeMaterial";
  56258. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56259. export * from "babylonjs/Materials/Node/Blocks/index";
  56260. export * from "babylonjs/Materials/Node/Optimizers/index";
  56261. }
  56262. declare module "babylonjs/Materials/effectRenderer" {
  56263. import { Nullable } from "babylonjs/types";
  56264. import { Texture } from "babylonjs/Materials/Textures/texture";
  56265. import { Engine } from "babylonjs/Engines/engine";
  56266. import { Viewport } from "babylonjs/Maths/math.viewport";
  56267. import { Observable } from "babylonjs/Misc/observable";
  56268. import { Effect } from "babylonjs/Materials/effect";
  56269. import "babylonjs/Shaders/postprocess.vertex";
  56270. /**
  56271. * Effect Render Options
  56272. */
  56273. export interface IEffectRendererOptions {
  56274. /**
  56275. * Defines the vertices positions.
  56276. */
  56277. positions?: number[];
  56278. /**
  56279. * Defines the indices.
  56280. */
  56281. indices?: number[];
  56282. }
  56283. /**
  56284. * Helper class to render one or more effects
  56285. */
  56286. export class EffectRenderer {
  56287. private engine;
  56288. private static _DefaultOptions;
  56289. private _vertexBuffers;
  56290. private _indexBuffer;
  56291. private _ringBufferIndex;
  56292. private _ringScreenBuffer;
  56293. private _fullscreenViewport;
  56294. private _getNextFrameBuffer;
  56295. /**
  56296. * Creates an effect renderer
  56297. * @param engine the engine to use for rendering
  56298. * @param options defines the options of the effect renderer
  56299. */
  56300. constructor(engine: Engine, options?: IEffectRendererOptions);
  56301. /**
  56302. * Sets the current viewport in normalized coordinates 0-1
  56303. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56304. */
  56305. setViewport(viewport?: Viewport): void;
  56306. /**
  56307. * Sets the current effect wrapper to use during draw.
  56308. * The effect needs to be ready before calling this api.
  56309. * This also sets the default full screen position attribute.
  56310. * @param effectWrapper Defines the effect to draw with
  56311. */
  56312. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56313. /**
  56314. * Draws a full screen quad.
  56315. */
  56316. draw(): void;
  56317. /**
  56318. * renders one or more effects to a specified texture
  56319. * @param effectWrappers list of effects to renderer
  56320. * @param outputTexture texture to draw to, if null it will render to the screen
  56321. */
  56322. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56323. /**
  56324. * Disposes of the effect renderer
  56325. */
  56326. dispose(): void;
  56327. }
  56328. /**
  56329. * Options to create an EffectWrapper
  56330. */
  56331. interface EffectWrapperCreationOptions {
  56332. /**
  56333. * Engine to use to create the effect
  56334. */
  56335. engine: Engine;
  56336. /**
  56337. * Fragment shader for the effect
  56338. */
  56339. fragmentShader: string;
  56340. /**
  56341. * Vertex shader for the effect
  56342. */
  56343. vertexShader?: string;
  56344. /**
  56345. * Attributes to use in the shader
  56346. */
  56347. attributeNames?: Array<string>;
  56348. /**
  56349. * Uniforms to use in the shader
  56350. */
  56351. uniformNames?: Array<string>;
  56352. /**
  56353. * Texture sampler names to use in the shader
  56354. */
  56355. samplerNames?: Array<string>;
  56356. /**
  56357. * The friendly name of the effect displayed in Spector.
  56358. */
  56359. name?: string;
  56360. }
  56361. /**
  56362. * Wraps an effect to be used for rendering
  56363. */
  56364. export class EffectWrapper {
  56365. /**
  56366. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56367. */
  56368. onApplyObservable: Observable<{}>;
  56369. /**
  56370. * The underlying effect
  56371. */
  56372. effect: Effect;
  56373. /**
  56374. * Creates an effect to be renderer
  56375. * @param creationOptions options to create the effect
  56376. */
  56377. constructor(creationOptions: EffectWrapperCreationOptions);
  56378. /**
  56379. * Disposes of the effect wrapper
  56380. */
  56381. dispose(): void;
  56382. }
  56383. }
  56384. declare module "babylonjs/Materials/index" {
  56385. export * from "babylonjs/Materials/Background/index";
  56386. export * from "babylonjs/Materials/colorCurves";
  56387. export * from "babylonjs/Materials/effect";
  56388. export * from "babylonjs/Materials/fresnelParameters";
  56389. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56390. export * from "babylonjs/Materials/material";
  56391. export * from "babylonjs/Materials/materialDefines";
  56392. export * from "babylonjs/Materials/materialHelper";
  56393. export * from "babylonjs/Materials/multiMaterial";
  56394. export * from "babylonjs/Materials/PBR/index";
  56395. export * from "babylonjs/Materials/pushMaterial";
  56396. export * from "babylonjs/Materials/shaderMaterial";
  56397. export * from "babylonjs/Materials/standardMaterial";
  56398. export * from "babylonjs/Materials/Textures/index";
  56399. export * from "babylonjs/Materials/uniformBuffer";
  56400. export * from "babylonjs/Materials/materialFlags";
  56401. export * from "babylonjs/Materials/Node/index";
  56402. export * from "babylonjs/Materials/effectRenderer";
  56403. }
  56404. declare module "babylonjs/Maths/index" {
  56405. export * from "babylonjs/Maths/math.scalar";
  56406. export * from "babylonjs/Maths/math";
  56407. export * from "babylonjs/Maths/sphericalPolynomial";
  56408. }
  56409. declare module "babylonjs/Misc/workerPool" {
  56410. import { IDisposable } from "babylonjs/scene";
  56411. /**
  56412. * Helper class to push actions to a pool of workers.
  56413. */
  56414. export class WorkerPool implements IDisposable {
  56415. private _workerInfos;
  56416. private _pendingActions;
  56417. /**
  56418. * Constructor
  56419. * @param workers Array of workers to use for actions
  56420. */
  56421. constructor(workers: Array<Worker>);
  56422. /**
  56423. * Terminates all workers and clears any pending actions.
  56424. */
  56425. dispose(): void;
  56426. /**
  56427. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56428. * pended until a worker has completed its action.
  56429. * @param action The action to perform. Call onComplete when the action is complete.
  56430. */
  56431. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56432. private _execute;
  56433. }
  56434. }
  56435. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56436. import { IDisposable } from "babylonjs/scene";
  56437. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56438. /**
  56439. * Configuration for Draco compression
  56440. */
  56441. export interface IDracoCompressionConfiguration {
  56442. /**
  56443. * Configuration for the decoder.
  56444. */
  56445. decoder: {
  56446. /**
  56447. * The url to the WebAssembly module.
  56448. */
  56449. wasmUrl?: string;
  56450. /**
  56451. * The url to the WebAssembly binary.
  56452. */
  56453. wasmBinaryUrl?: string;
  56454. /**
  56455. * The url to the fallback JavaScript module.
  56456. */
  56457. fallbackUrl?: string;
  56458. };
  56459. }
  56460. /**
  56461. * Draco compression (https://google.github.io/draco/)
  56462. *
  56463. * This class wraps the Draco module.
  56464. *
  56465. * **Encoder**
  56466. *
  56467. * The encoder is not currently implemented.
  56468. *
  56469. * **Decoder**
  56470. *
  56471. * 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.
  56472. *
  56473. * To update the configuration, use the following code:
  56474. * ```javascript
  56475. * DracoCompression.Configuration = {
  56476. * decoder: {
  56477. * wasmUrl: "<url to the WebAssembly library>",
  56478. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56479. * fallbackUrl: "<url to the fallback JavaScript library>",
  56480. * }
  56481. * };
  56482. * ```
  56483. *
  56484. * 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.
  56485. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56486. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56487. *
  56488. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56489. * ```javascript
  56490. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56491. * ```
  56492. *
  56493. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56494. */
  56495. export class DracoCompression implements IDisposable {
  56496. private _workerPoolPromise?;
  56497. private _decoderModulePromise?;
  56498. /**
  56499. * The configuration. Defaults to the following urls:
  56500. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56501. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56502. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56503. */
  56504. static Configuration: IDracoCompressionConfiguration;
  56505. /**
  56506. * Returns true if the decoder configuration is available.
  56507. */
  56508. static readonly DecoderAvailable: boolean;
  56509. /**
  56510. * Default number of workers to create when creating the draco compression object.
  56511. */
  56512. static DefaultNumWorkers: number;
  56513. private static GetDefaultNumWorkers;
  56514. private static _Default;
  56515. /**
  56516. * Default instance for the draco compression object.
  56517. */
  56518. static readonly Default: DracoCompression;
  56519. /**
  56520. * Constructor
  56521. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56522. */
  56523. constructor(numWorkers?: number);
  56524. /**
  56525. * Stop all async operations and release resources.
  56526. */
  56527. dispose(): void;
  56528. /**
  56529. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56530. * @returns a promise that resolves when ready
  56531. */
  56532. whenReadyAsync(): Promise<void>;
  56533. /**
  56534. * Decode Draco compressed mesh data to vertex data.
  56535. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56536. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56537. * @returns A promise that resolves with the decoded vertex data
  56538. */
  56539. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56540. [kind: string]: number;
  56541. }): Promise<VertexData>;
  56542. }
  56543. }
  56544. declare module "babylonjs/Meshes/Compression/index" {
  56545. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56546. }
  56547. declare module "babylonjs/Meshes/csg" {
  56548. import { Nullable } from "babylonjs/types";
  56549. import { Scene } from "babylonjs/scene";
  56550. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56551. import { Mesh } from "babylonjs/Meshes/mesh";
  56552. import { Material } from "babylonjs/Materials/material";
  56553. /**
  56554. * Class for building Constructive Solid Geometry
  56555. */
  56556. export class CSG {
  56557. private polygons;
  56558. /**
  56559. * The world matrix
  56560. */
  56561. matrix: Matrix;
  56562. /**
  56563. * Stores the position
  56564. */
  56565. position: Vector3;
  56566. /**
  56567. * Stores the rotation
  56568. */
  56569. rotation: Vector3;
  56570. /**
  56571. * Stores the rotation quaternion
  56572. */
  56573. rotationQuaternion: Nullable<Quaternion>;
  56574. /**
  56575. * Stores the scaling vector
  56576. */
  56577. scaling: Vector3;
  56578. /**
  56579. * Convert the Mesh to CSG
  56580. * @param mesh The Mesh to convert to CSG
  56581. * @returns A new CSG from the Mesh
  56582. */
  56583. static FromMesh(mesh: Mesh): CSG;
  56584. /**
  56585. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56586. * @param polygons Polygons used to construct a CSG solid
  56587. */
  56588. private static FromPolygons;
  56589. /**
  56590. * Clones, or makes a deep copy, of the CSG
  56591. * @returns A new CSG
  56592. */
  56593. clone(): CSG;
  56594. /**
  56595. * Unions this CSG with another CSG
  56596. * @param csg The CSG to union against this CSG
  56597. * @returns The unioned CSG
  56598. */
  56599. union(csg: CSG): CSG;
  56600. /**
  56601. * Unions this CSG with another CSG in place
  56602. * @param csg The CSG to union against this CSG
  56603. */
  56604. unionInPlace(csg: CSG): void;
  56605. /**
  56606. * Subtracts this CSG with another CSG
  56607. * @param csg The CSG to subtract against this CSG
  56608. * @returns A new CSG
  56609. */
  56610. subtract(csg: CSG): CSG;
  56611. /**
  56612. * Subtracts this CSG with another CSG in place
  56613. * @param csg The CSG to subtact against this CSG
  56614. */
  56615. subtractInPlace(csg: CSG): void;
  56616. /**
  56617. * Intersect this CSG with another CSG
  56618. * @param csg The CSG to intersect against this CSG
  56619. * @returns A new CSG
  56620. */
  56621. intersect(csg: CSG): CSG;
  56622. /**
  56623. * Intersects this CSG with another CSG in place
  56624. * @param csg The CSG to intersect against this CSG
  56625. */
  56626. intersectInPlace(csg: CSG): void;
  56627. /**
  56628. * Return a new CSG solid with solid and empty space switched. This solid is
  56629. * not modified.
  56630. * @returns A new CSG solid with solid and empty space switched
  56631. */
  56632. inverse(): CSG;
  56633. /**
  56634. * Inverses the CSG in place
  56635. */
  56636. inverseInPlace(): void;
  56637. /**
  56638. * This is used to keep meshes transformations so they can be restored
  56639. * when we build back a Babylon Mesh
  56640. * NB : All CSG operations are performed in world coordinates
  56641. * @param csg The CSG to copy the transform attributes from
  56642. * @returns This CSG
  56643. */
  56644. copyTransformAttributes(csg: CSG): CSG;
  56645. /**
  56646. * Build Raw mesh from CSG
  56647. * Coordinates here are in world space
  56648. * @param name The name of the mesh geometry
  56649. * @param scene The Scene
  56650. * @param keepSubMeshes Specifies if the submeshes should be kept
  56651. * @returns A new Mesh
  56652. */
  56653. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56654. /**
  56655. * Build Mesh from CSG taking material and transforms into account
  56656. * @param name The name of the Mesh
  56657. * @param material The material of the Mesh
  56658. * @param scene The Scene
  56659. * @param keepSubMeshes Specifies if submeshes should be kept
  56660. * @returns The new Mesh
  56661. */
  56662. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56663. }
  56664. }
  56665. declare module "babylonjs/Meshes/trailMesh" {
  56666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56667. import { Mesh } from "babylonjs/Meshes/mesh";
  56668. import { Scene } from "babylonjs/scene";
  56669. /**
  56670. * Class used to create a trail following a mesh
  56671. */
  56672. export class TrailMesh extends Mesh {
  56673. private _generator;
  56674. private _autoStart;
  56675. private _running;
  56676. private _diameter;
  56677. private _length;
  56678. private _sectionPolygonPointsCount;
  56679. private _sectionVectors;
  56680. private _sectionNormalVectors;
  56681. private _beforeRenderObserver;
  56682. /**
  56683. * @constructor
  56684. * @param name The value used by scene.getMeshByName() to do a lookup.
  56685. * @param generator The mesh to generate a trail.
  56686. * @param scene The scene to add this mesh to.
  56687. * @param diameter Diameter of trailing mesh. Default is 1.
  56688. * @param length Length of trailing mesh. Default is 60.
  56689. * @param autoStart Automatically start trailing mesh. Default true.
  56690. */
  56691. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56692. /**
  56693. * "TrailMesh"
  56694. * @returns "TrailMesh"
  56695. */
  56696. getClassName(): string;
  56697. private _createMesh;
  56698. /**
  56699. * Start trailing mesh.
  56700. */
  56701. start(): void;
  56702. /**
  56703. * Stop trailing mesh.
  56704. */
  56705. stop(): void;
  56706. /**
  56707. * Update trailing mesh geometry.
  56708. */
  56709. update(): void;
  56710. /**
  56711. * Returns a new TrailMesh object.
  56712. * @param name is a string, the name given to the new mesh
  56713. * @param newGenerator use new generator object for cloned trail mesh
  56714. * @returns a new mesh
  56715. */
  56716. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56717. /**
  56718. * Serializes this trail mesh
  56719. * @param serializationObject object to write serialization to
  56720. */
  56721. serialize(serializationObject: any): void;
  56722. /**
  56723. * Parses a serialized trail mesh
  56724. * @param parsedMesh the serialized mesh
  56725. * @param scene the scene to create the trail mesh in
  56726. * @returns the created trail mesh
  56727. */
  56728. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56729. }
  56730. }
  56731. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56732. import { Nullable } from "babylonjs/types";
  56733. import { Scene } from "babylonjs/scene";
  56734. import { Vector4 } from "babylonjs/Maths/math.vector";
  56735. import { Color4 } from "babylonjs/Maths/math.color";
  56736. import { Mesh } from "babylonjs/Meshes/mesh";
  56737. /**
  56738. * Class containing static functions to help procedurally build meshes
  56739. */
  56740. export class TiledBoxBuilder {
  56741. /**
  56742. * Creates a box mesh
  56743. * 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)
  56744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56748. * @param name defines the name of the mesh
  56749. * @param options defines the options used to create the mesh
  56750. * @param scene defines the hosting scene
  56751. * @returns the box mesh
  56752. */
  56753. static CreateTiledBox(name: string, options: {
  56754. pattern?: number;
  56755. width?: number;
  56756. height?: number;
  56757. depth?: number;
  56758. tileSize?: number;
  56759. tileWidth?: number;
  56760. tileHeight?: number;
  56761. alignHorizontal?: number;
  56762. alignVertical?: number;
  56763. faceUV?: Vector4[];
  56764. faceColors?: Color4[];
  56765. sideOrientation?: number;
  56766. updatable?: boolean;
  56767. }, scene?: Nullable<Scene>): Mesh;
  56768. }
  56769. }
  56770. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56771. import { Vector4 } from "babylonjs/Maths/math.vector";
  56772. import { Mesh } from "babylonjs/Meshes/mesh";
  56773. /**
  56774. * Class containing static functions to help procedurally build meshes
  56775. */
  56776. export class TorusKnotBuilder {
  56777. /**
  56778. * Creates a torus knot mesh
  56779. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56780. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56781. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56782. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56786. * @param name defines the name of the mesh
  56787. * @param options defines the options used to create the mesh
  56788. * @param scene defines the hosting scene
  56789. * @returns the torus knot mesh
  56790. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56791. */
  56792. static CreateTorusKnot(name: string, options: {
  56793. radius?: number;
  56794. tube?: number;
  56795. radialSegments?: number;
  56796. tubularSegments?: number;
  56797. p?: number;
  56798. q?: number;
  56799. updatable?: boolean;
  56800. sideOrientation?: number;
  56801. frontUVs?: Vector4;
  56802. backUVs?: Vector4;
  56803. }, scene: any): Mesh;
  56804. }
  56805. }
  56806. declare module "babylonjs/Meshes/polygonMesh" {
  56807. import { Scene } from "babylonjs/scene";
  56808. import { Vector2 } from "babylonjs/Maths/math.vector";
  56809. import { Mesh } from "babylonjs/Meshes/mesh";
  56810. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56811. import { Path2 } from "babylonjs/Maths/math.path";
  56812. /**
  56813. * Polygon
  56814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56815. */
  56816. export class Polygon {
  56817. /**
  56818. * Creates a rectangle
  56819. * @param xmin bottom X coord
  56820. * @param ymin bottom Y coord
  56821. * @param xmax top X coord
  56822. * @param ymax top Y coord
  56823. * @returns points that make the resulting rectation
  56824. */
  56825. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56826. /**
  56827. * Creates a circle
  56828. * @param radius radius of circle
  56829. * @param cx scale in x
  56830. * @param cy scale in y
  56831. * @param numberOfSides number of sides that make up the circle
  56832. * @returns points that make the resulting circle
  56833. */
  56834. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56835. /**
  56836. * Creates a polygon from input string
  56837. * @param input Input polygon data
  56838. * @returns the parsed points
  56839. */
  56840. static Parse(input: string): Vector2[];
  56841. /**
  56842. * Starts building a polygon from x and y coordinates
  56843. * @param x x coordinate
  56844. * @param y y coordinate
  56845. * @returns the started path2
  56846. */
  56847. static StartingAt(x: number, y: number): Path2;
  56848. }
  56849. /**
  56850. * Builds a polygon
  56851. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56852. */
  56853. export class PolygonMeshBuilder {
  56854. private _points;
  56855. private _outlinepoints;
  56856. private _holes;
  56857. private _name;
  56858. private _scene;
  56859. private _epoints;
  56860. private _eholes;
  56861. private _addToepoint;
  56862. /**
  56863. * Babylon reference to the earcut plugin.
  56864. */
  56865. bjsEarcut: any;
  56866. /**
  56867. * Creates a PolygonMeshBuilder
  56868. * @param name name of the builder
  56869. * @param contours Path of the polygon
  56870. * @param scene scene to add to when creating the mesh
  56871. * @param earcutInjection can be used to inject your own earcut reference
  56872. */
  56873. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56874. /**
  56875. * Adds a whole within the polygon
  56876. * @param hole Array of points defining the hole
  56877. * @returns this
  56878. */
  56879. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56880. /**
  56881. * Creates the polygon
  56882. * @param updatable If the mesh should be updatable
  56883. * @param depth The depth of the mesh created
  56884. * @returns the created mesh
  56885. */
  56886. build(updatable?: boolean, depth?: number): Mesh;
  56887. /**
  56888. * Creates the polygon
  56889. * @param depth The depth of the mesh created
  56890. * @returns the created VertexData
  56891. */
  56892. buildVertexData(depth?: number): VertexData;
  56893. /**
  56894. * Adds a side to the polygon
  56895. * @param positions points that make the polygon
  56896. * @param normals normals of the polygon
  56897. * @param uvs uvs of the polygon
  56898. * @param indices indices of the polygon
  56899. * @param bounds bounds of the polygon
  56900. * @param points points of the polygon
  56901. * @param depth depth of the polygon
  56902. * @param flip flip of the polygon
  56903. */
  56904. private addSide;
  56905. }
  56906. }
  56907. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56908. import { Scene } from "babylonjs/scene";
  56909. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56910. import { Color4 } from "babylonjs/Maths/math.color";
  56911. import { Mesh } from "babylonjs/Meshes/mesh";
  56912. import { Nullable } from "babylonjs/types";
  56913. /**
  56914. * Class containing static functions to help procedurally build meshes
  56915. */
  56916. export class PolygonBuilder {
  56917. /**
  56918. * Creates a polygon mesh
  56919. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56920. * * 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
  56921. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56924. * * Remember you can only change the shape positions, not their number when updating a polygon
  56925. * @param name defines the name of the mesh
  56926. * @param options defines the options used to create the mesh
  56927. * @param scene defines the hosting scene
  56928. * @param earcutInjection can be used to inject your own earcut reference
  56929. * @returns the polygon mesh
  56930. */
  56931. static CreatePolygon(name: string, options: {
  56932. shape: Vector3[];
  56933. holes?: Vector3[][];
  56934. depth?: number;
  56935. faceUV?: Vector4[];
  56936. faceColors?: Color4[];
  56937. updatable?: boolean;
  56938. sideOrientation?: number;
  56939. frontUVs?: Vector4;
  56940. backUVs?: Vector4;
  56941. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56942. /**
  56943. * Creates an extruded polygon mesh, with depth in the Y direction.
  56944. * * 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)
  56945. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56946. * @param name defines the name of the mesh
  56947. * @param options defines the options used to create the mesh
  56948. * @param scene defines the hosting scene
  56949. * @param earcutInjection can be used to inject your own earcut reference
  56950. * @returns the polygon mesh
  56951. */
  56952. static ExtrudePolygon(name: string, options: {
  56953. shape: Vector3[];
  56954. holes?: Vector3[][];
  56955. depth?: number;
  56956. faceUV?: Vector4[];
  56957. faceColors?: Color4[];
  56958. updatable?: boolean;
  56959. sideOrientation?: number;
  56960. frontUVs?: Vector4;
  56961. backUVs?: Vector4;
  56962. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56963. }
  56964. }
  56965. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56966. import { Scene } from "babylonjs/scene";
  56967. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56968. import { Mesh } from "babylonjs/Meshes/mesh";
  56969. import { Nullable } from "babylonjs/types";
  56970. /**
  56971. * Class containing static functions to help procedurally build meshes
  56972. */
  56973. export class LatheBuilder {
  56974. /**
  56975. * Creates lathe mesh.
  56976. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56977. * * 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
  56978. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56979. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56980. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56981. * * 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
  56982. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56983. * * 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
  56984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56988. * @param name defines the name of the mesh
  56989. * @param options defines the options used to create the mesh
  56990. * @param scene defines the hosting scene
  56991. * @returns the lathe mesh
  56992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56993. */
  56994. static CreateLathe(name: string, options: {
  56995. shape: Vector3[];
  56996. radius?: number;
  56997. tessellation?: number;
  56998. clip?: number;
  56999. arc?: number;
  57000. closed?: boolean;
  57001. updatable?: boolean;
  57002. sideOrientation?: number;
  57003. frontUVs?: Vector4;
  57004. backUVs?: Vector4;
  57005. cap?: number;
  57006. invertUV?: boolean;
  57007. }, scene?: Nullable<Scene>): Mesh;
  57008. }
  57009. }
  57010. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57011. import { Nullable } from "babylonjs/types";
  57012. import { Scene } from "babylonjs/scene";
  57013. import { Vector4 } from "babylonjs/Maths/math.vector";
  57014. import { Mesh } from "babylonjs/Meshes/mesh";
  57015. /**
  57016. * Class containing static functions to help procedurally build meshes
  57017. */
  57018. export class TiledPlaneBuilder {
  57019. /**
  57020. * Creates a tiled plane mesh
  57021. * * The parameter `pattern` will, depending on value, do nothing or
  57022. * * * flip (reflect about central vertical) alternate tiles across and up
  57023. * * * flip every tile on alternate rows
  57024. * * * rotate (180 degs) alternate tiles across and up
  57025. * * * rotate every tile on alternate rows
  57026. * * * flip and rotate alternate tiles across and up
  57027. * * * flip and rotate every tile on alternate rows
  57028. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57029. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57032. * * 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)
  57033. * * 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)
  57034. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57035. * @param name defines the name of the mesh
  57036. * @param options defines the options used to create the mesh
  57037. * @param scene defines the hosting scene
  57038. * @returns the box mesh
  57039. */
  57040. static CreateTiledPlane(name: string, options: {
  57041. pattern?: number;
  57042. tileSize?: number;
  57043. tileWidth?: number;
  57044. tileHeight?: number;
  57045. size?: number;
  57046. width?: number;
  57047. height?: number;
  57048. alignHorizontal?: number;
  57049. alignVertical?: number;
  57050. sideOrientation?: number;
  57051. frontUVs?: Vector4;
  57052. backUVs?: Vector4;
  57053. updatable?: boolean;
  57054. }, scene?: Nullable<Scene>): Mesh;
  57055. }
  57056. }
  57057. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57058. import { Nullable } from "babylonjs/types";
  57059. import { Scene } from "babylonjs/scene";
  57060. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57061. import { Mesh } from "babylonjs/Meshes/mesh";
  57062. /**
  57063. * Class containing static functions to help procedurally build meshes
  57064. */
  57065. export class TubeBuilder {
  57066. /**
  57067. * Creates a tube mesh.
  57068. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57069. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57070. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57071. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57072. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57073. * * 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)
  57074. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57075. * * 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
  57076. * * 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
  57077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57081. * @param name defines the name of the mesh
  57082. * @param options defines the options used to create the mesh
  57083. * @param scene defines the hosting scene
  57084. * @returns the tube mesh
  57085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57086. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57087. */
  57088. static CreateTube(name: string, options: {
  57089. path: Vector3[];
  57090. radius?: number;
  57091. tessellation?: number;
  57092. radiusFunction?: {
  57093. (i: number, distance: number): number;
  57094. };
  57095. cap?: number;
  57096. arc?: number;
  57097. updatable?: boolean;
  57098. sideOrientation?: number;
  57099. frontUVs?: Vector4;
  57100. backUVs?: Vector4;
  57101. instance?: Mesh;
  57102. invertUV?: boolean;
  57103. }, scene?: Nullable<Scene>): Mesh;
  57104. }
  57105. }
  57106. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57107. import { Scene } from "babylonjs/scene";
  57108. import { Vector4 } from "babylonjs/Maths/math.vector";
  57109. import { Mesh } from "babylonjs/Meshes/mesh";
  57110. import { Nullable } from "babylonjs/types";
  57111. /**
  57112. * Class containing static functions to help procedurally build meshes
  57113. */
  57114. export class IcoSphereBuilder {
  57115. /**
  57116. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57117. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57118. * * 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`)
  57119. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57120. * * 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
  57121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57124. * @param name defines the name of the mesh
  57125. * @param options defines the options used to create the mesh
  57126. * @param scene defines the hosting scene
  57127. * @returns the icosahedron mesh
  57128. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57129. */
  57130. static CreateIcoSphere(name: string, options: {
  57131. radius?: number;
  57132. radiusX?: number;
  57133. radiusY?: number;
  57134. radiusZ?: number;
  57135. flat?: boolean;
  57136. subdivisions?: number;
  57137. sideOrientation?: number;
  57138. frontUVs?: Vector4;
  57139. backUVs?: Vector4;
  57140. updatable?: boolean;
  57141. }, scene?: Nullable<Scene>): Mesh;
  57142. }
  57143. }
  57144. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57145. import { Vector3 } from "babylonjs/Maths/math.vector";
  57146. import { Mesh } from "babylonjs/Meshes/mesh";
  57147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57148. /**
  57149. * Class containing static functions to help procedurally build meshes
  57150. */
  57151. export class DecalBuilder {
  57152. /**
  57153. * Creates a decal mesh.
  57154. * 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
  57155. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57156. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57157. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57158. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57159. * @param name defines the name of the mesh
  57160. * @param sourceMesh defines the mesh where the decal must be applied
  57161. * @param options defines the options used to create the mesh
  57162. * @param scene defines the hosting scene
  57163. * @returns the decal mesh
  57164. * @see https://doc.babylonjs.com/how_to/decals
  57165. */
  57166. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57167. position?: Vector3;
  57168. normal?: Vector3;
  57169. size?: Vector3;
  57170. angle?: number;
  57171. }): Mesh;
  57172. }
  57173. }
  57174. declare module "babylonjs/Meshes/meshBuilder" {
  57175. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57176. import { Nullable } from "babylonjs/types";
  57177. import { Scene } from "babylonjs/scene";
  57178. import { Mesh } from "babylonjs/Meshes/mesh";
  57179. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57180. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57182. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57183. import { Plane } from "babylonjs/Maths/math.plane";
  57184. /**
  57185. * Class containing static functions to help procedurally build meshes
  57186. */
  57187. export class MeshBuilder {
  57188. /**
  57189. * Creates a box mesh
  57190. * * The parameter `size` sets the size (float) of each box side (default 1)
  57191. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57192. * * 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)
  57193. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57197. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57198. * @param name defines the name of the mesh
  57199. * @param options defines the options used to create the mesh
  57200. * @param scene defines the hosting scene
  57201. * @returns the box mesh
  57202. */
  57203. static CreateBox(name: string, options: {
  57204. size?: number;
  57205. width?: number;
  57206. height?: number;
  57207. depth?: number;
  57208. faceUV?: Vector4[];
  57209. faceColors?: Color4[];
  57210. sideOrientation?: number;
  57211. frontUVs?: Vector4;
  57212. backUVs?: Vector4;
  57213. updatable?: boolean;
  57214. }, scene?: Nullable<Scene>): Mesh;
  57215. /**
  57216. * Creates a tiled box mesh
  57217. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57219. * @param name defines the name of the mesh
  57220. * @param options defines the options used to create the mesh
  57221. * @param scene defines the hosting scene
  57222. * @returns the tiled box mesh
  57223. */
  57224. static CreateTiledBox(name: string, options: {
  57225. pattern?: number;
  57226. size?: number;
  57227. width?: number;
  57228. height?: number;
  57229. depth: number;
  57230. tileSize?: number;
  57231. tileWidth?: number;
  57232. tileHeight?: number;
  57233. faceUV?: Vector4[];
  57234. faceColors?: Color4[];
  57235. alignHorizontal?: number;
  57236. alignVertical?: number;
  57237. sideOrientation?: number;
  57238. updatable?: boolean;
  57239. }, scene?: Nullable<Scene>): Mesh;
  57240. /**
  57241. * Creates a sphere mesh
  57242. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57243. * * 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`)
  57244. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57245. * * 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
  57246. * * 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)
  57247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57250. * @param name defines the name of the mesh
  57251. * @param options defines the options used to create the mesh
  57252. * @param scene defines the hosting scene
  57253. * @returns the sphere mesh
  57254. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57255. */
  57256. static CreateSphere(name: string, options: {
  57257. segments?: number;
  57258. diameter?: number;
  57259. diameterX?: number;
  57260. diameterY?: number;
  57261. diameterZ?: number;
  57262. arc?: number;
  57263. slice?: number;
  57264. sideOrientation?: number;
  57265. frontUVs?: Vector4;
  57266. backUVs?: Vector4;
  57267. updatable?: boolean;
  57268. }, scene?: Nullable<Scene>): Mesh;
  57269. /**
  57270. * Creates a plane polygonal mesh. By default, this is a disc
  57271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57272. * * 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
  57273. * * 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
  57274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57277. * @param name defines the name of the mesh
  57278. * @param options defines the options used to create the mesh
  57279. * @param scene defines the hosting scene
  57280. * @returns the plane polygonal mesh
  57281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57282. */
  57283. static CreateDisc(name: string, options: {
  57284. radius?: number;
  57285. tessellation?: number;
  57286. arc?: number;
  57287. updatable?: boolean;
  57288. sideOrientation?: number;
  57289. frontUVs?: Vector4;
  57290. backUVs?: Vector4;
  57291. }, scene?: Nullable<Scene>): Mesh;
  57292. /**
  57293. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57294. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57295. * * 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`)
  57296. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57297. * * 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
  57298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57301. * @param name defines the name of the mesh
  57302. * @param options defines the options used to create the mesh
  57303. * @param scene defines the hosting scene
  57304. * @returns the icosahedron mesh
  57305. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57306. */
  57307. static CreateIcoSphere(name: string, options: {
  57308. radius?: number;
  57309. radiusX?: number;
  57310. radiusY?: number;
  57311. radiusZ?: number;
  57312. flat?: boolean;
  57313. subdivisions?: number;
  57314. sideOrientation?: number;
  57315. frontUVs?: Vector4;
  57316. backUVs?: Vector4;
  57317. updatable?: boolean;
  57318. }, scene?: Nullable<Scene>): Mesh;
  57319. /**
  57320. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57321. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57322. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57323. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57324. * * 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
  57325. * * 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
  57326. * * 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
  57327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57330. * * The 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
  57331. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57332. * * 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
  57333. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57335. * @param name defines the name of the mesh
  57336. * @param options defines the options used to create the mesh
  57337. * @param scene defines the hosting scene
  57338. * @returns the ribbon mesh
  57339. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57341. */
  57342. static CreateRibbon(name: string, options: {
  57343. pathArray: Vector3[][];
  57344. closeArray?: boolean;
  57345. closePath?: boolean;
  57346. offset?: number;
  57347. updatable?: boolean;
  57348. sideOrientation?: number;
  57349. frontUVs?: Vector4;
  57350. backUVs?: Vector4;
  57351. instance?: Mesh;
  57352. invertUV?: boolean;
  57353. uvs?: Vector2[];
  57354. colors?: Color4[];
  57355. }, scene?: Nullable<Scene>): Mesh;
  57356. /**
  57357. * Creates a cylinder or a cone mesh
  57358. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57359. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57360. * * 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.
  57361. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57362. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57363. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57364. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57365. * * 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).
  57366. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57367. * * 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).
  57368. * * 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
  57369. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57370. * * 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
  57371. * * 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.
  57372. * * If `enclose` is false, a ring surface is one element.
  57373. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57374. * * 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
  57375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57378. * @param name defines the name of the mesh
  57379. * @param options defines the options used to create the mesh
  57380. * @param scene defines the hosting scene
  57381. * @returns the cylinder mesh
  57382. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57383. */
  57384. static CreateCylinder(name: string, options: {
  57385. height?: number;
  57386. diameterTop?: number;
  57387. diameterBottom?: number;
  57388. diameter?: number;
  57389. tessellation?: number;
  57390. subdivisions?: number;
  57391. arc?: number;
  57392. faceColors?: Color4[];
  57393. faceUV?: Vector4[];
  57394. updatable?: boolean;
  57395. hasRings?: boolean;
  57396. enclose?: boolean;
  57397. cap?: number;
  57398. sideOrientation?: number;
  57399. frontUVs?: Vector4;
  57400. backUVs?: Vector4;
  57401. }, scene?: Nullable<Scene>): Mesh;
  57402. /**
  57403. * Creates a torus mesh
  57404. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57405. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57406. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57410. * @param name defines the name of the mesh
  57411. * @param options defines the options used to create the mesh
  57412. * @param scene defines the hosting scene
  57413. * @returns the torus mesh
  57414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57415. */
  57416. static CreateTorus(name: string, options: {
  57417. diameter?: number;
  57418. thickness?: number;
  57419. tessellation?: number;
  57420. updatable?: boolean;
  57421. sideOrientation?: number;
  57422. frontUVs?: Vector4;
  57423. backUVs?: Vector4;
  57424. }, scene?: Nullable<Scene>): Mesh;
  57425. /**
  57426. * Creates a torus knot mesh
  57427. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57428. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57429. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57430. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57434. * @param name defines the name of the mesh
  57435. * @param options defines the options used to create the mesh
  57436. * @param scene defines the hosting scene
  57437. * @returns the torus knot mesh
  57438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57439. */
  57440. static CreateTorusKnot(name: string, options: {
  57441. radius?: number;
  57442. tube?: number;
  57443. radialSegments?: number;
  57444. tubularSegments?: number;
  57445. p?: number;
  57446. q?: number;
  57447. updatable?: boolean;
  57448. sideOrientation?: number;
  57449. frontUVs?: Vector4;
  57450. backUVs?: Vector4;
  57451. }, scene?: Nullable<Scene>): Mesh;
  57452. /**
  57453. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57454. * * 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
  57455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57456. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57457. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57458. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57460. * * 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
  57461. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57464. * @param name defines the name of the new line system
  57465. * @param options defines the options used to create the line system
  57466. * @param scene defines the hosting scene
  57467. * @returns a new line system mesh
  57468. */
  57469. static CreateLineSystem(name: string, options: {
  57470. lines: Vector3[][];
  57471. updatable?: boolean;
  57472. instance?: Nullable<LinesMesh>;
  57473. colors?: Nullable<Color4[][]>;
  57474. useVertexAlpha?: boolean;
  57475. }, scene: Nullable<Scene>): LinesMesh;
  57476. /**
  57477. * Creates a line mesh
  57478. * 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
  57479. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57480. * * The parameter `points` is an array successive Vector3
  57481. * * 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
  57482. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57484. * * When updating an instance, remember that only point positions can change, not the number of points
  57485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57487. * @param name defines the name of the new line system
  57488. * @param options defines the options used to create the line system
  57489. * @param scene defines the hosting scene
  57490. * @returns a new line mesh
  57491. */
  57492. static CreateLines(name: string, options: {
  57493. points: Vector3[];
  57494. updatable?: boolean;
  57495. instance?: Nullable<LinesMesh>;
  57496. colors?: Color4[];
  57497. useVertexAlpha?: boolean;
  57498. }, scene?: Nullable<Scene>): LinesMesh;
  57499. /**
  57500. * Creates a dashed line mesh
  57501. * * 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
  57502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57503. * * The parameter `points` is an array successive Vector3
  57504. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57505. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57506. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57507. * * 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
  57508. * * When updating an instance, remember that only point positions can change, not the number of points
  57509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57510. * @param name defines the name of the mesh
  57511. * @param options defines the options used to create the mesh
  57512. * @param scene defines the hosting scene
  57513. * @returns the dashed line mesh
  57514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57515. */
  57516. static CreateDashedLines(name: string, options: {
  57517. points: Vector3[];
  57518. dashSize?: number;
  57519. gapSize?: number;
  57520. dashNb?: number;
  57521. updatable?: boolean;
  57522. instance?: LinesMesh;
  57523. }, scene?: Nullable<Scene>): LinesMesh;
  57524. /**
  57525. * 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.
  57526. * * 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.
  57527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57528. * * 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.
  57529. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57530. * * 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
  57531. * * 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
  57532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57537. * @param name defines the name of the mesh
  57538. * @param options defines the options used to create the mesh
  57539. * @param scene defines the hosting scene
  57540. * @returns the extruded shape mesh
  57541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57543. */
  57544. static ExtrudeShape(name: string, options: {
  57545. shape: Vector3[];
  57546. path: Vector3[];
  57547. scale?: number;
  57548. rotation?: number;
  57549. cap?: number;
  57550. updatable?: boolean;
  57551. sideOrientation?: number;
  57552. frontUVs?: Vector4;
  57553. backUVs?: Vector4;
  57554. instance?: Mesh;
  57555. invertUV?: boolean;
  57556. }, scene?: Nullable<Scene>): Mesh;
  57557. /**
  57558. * Creates an custom extruded shape mesh.
  57559. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57560. * * 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.
  57561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57562. * * 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
  57563. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57564. * * 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
  57565. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57566. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57567. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57568. * * 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
  57569. * * 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
  57570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57575. * @param name defines the name of the mesh
  57576. * @param options defines the options used to create the mesh
  57577. * @param scene defines the hosting scene
  57578. * @returns the custom extruded shape mesh
  57579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57582. */
  57583. static ExtrudeShapeCustom(name: string, options: {
  57584. shape: Vector3[];
  57585. path: Vector3[];
  57586. scaleFunction?: any;
  57587. rotationFunction?: any;
  57588. ribbonCloseArray?: boolean;
  57589. ribbonClosePath?: boolean;
  57590. cap?: number;
  57591. updatable?: boolean;
  57592. sideOrientation?: number;
  57593. frontUVs?: Vector4;
  57594. backUVs?: Vector4;
  57595. instance?: Mesh;
  57596. invertUV?: boolean;
  57597. }, scene?: Nullable<Scene>): Mesh;
  57598. /**
  57599. * Creates lathe mesh.
  57600. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57601. * * 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
  57602. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57603. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57604. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57605. * * 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
  57606. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57607. * * 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
  57608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57612. * @param name defines the name of the mesh
  57613. * @param options defines the options used to create the mesh
  57614. * @param scene defines the hosting scene
  57615. * @returns the lathe mesh
  57616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57617. */
  57618. static CreateLathe(name: string, options: {
  57619. shape: Vector3[];
  57620. radius?: number;
  57621. tessellation?: number;
  57622. clip?: number;
  57623. arc?: number;
  57624. closed?: boolean;
  57625. updatable?: boolean;
  57626. sideOrientation?: number;
  57627. frontUVs?: Vector4;
  57628. backUVs?: Vector4;
  57629. cap?: number;
  57630. invertUV?: boolean;
  57631. }, scene?: Nullable<Scene>): Mesh;
  57632. /**
  57633. * Creates a tiled plane mesh
  57634. * * You can set a limited pattern arrangement with the tiles
  57635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57638. * @param name defines the name of the mesh
  57639. * @param options defines the options used to create the mesh
  57640. * @param scene defines the hosting scene
  57641. * @returns the plane mesh
  57642. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57643. */
  57644. static CreateTiledPlane(name: string, options: {
  57645. pattern?: number;
  57646. tileSize?: number;
  57647. tileWidth?: number;
  57648. tileHeight?: number;
  57649. size?: number;
  57650. width?: number;
  57651. height?: number;
  57652. alignHorizontal?: number;
  57653. alignVertical?: number;
  57654. sideOrientation?: number;
  57655. frontUVs?: Vector4;
  57656. backUVs?: Vector4;
  57657. updatable?: boolean;
  57658. }, scene?: Nullable<Scene>): Mesh;
  57659. /**
  57660. * Creates a plane mesh
  57661. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57662. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57663. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57667. * @param name defines the name of the mesh
  57668. * @param options defines the options used to create the mesh
  57669. * @param scene defines the hosting scene
  57670. * @returns the plane mesh
  57671. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57672. */
  57673. static CreatePlane(name: string, options: {
  57674. size?: number;
  57675. width?: number;
  57676. height?: number;
  57677. sideOrientation?: number;
  57678. frontUVs?: Vector4;
  57679. backUVs?: Vector4;
  57680. updatable?: boolean;
  57681. sourcePlane?: Plane;
  57682. }, scene?: Nullable<Scene>): Mesh;
  57683. /**
  57684. * Creates a ground mesh
  57685. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57686. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57688. * @param name defines the name of the mesh
  57689. * @param options defines the options used to create the mesh
  57690. * @param scene defines the hosting scene
  57691. * @returns the ground mesh
  57692. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57693. */
  57694. static CreateGround(name: string, options: {
  57695. width?: number;
  57696. height?: number;
  57697. subdivisions?: number;
  57698. subdivisionsX?: number;
  57699. subdivisionsY?: number;
  57700. updatable?: boolean;
  57701. }, scene?: Nullable<Scene>): Mesh;
  57702. /**
  57703. * Creates a tiled ground mesh
  57704. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57705. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57706. * * 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
  57707. * * 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
  57708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57709. * @param name defines the name of the mesh
  57710. * @param options defines the options used to create the mesh
  57711. * @param scene defines the hosting scene
  57712. * @returns the tiled ground mesh
  57713. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57714. */
  57715. static CreateTiledGround(name: string, options: {
  57716. xmin: number;
  57717. zmin: number;
  57718. xmax: number;
  57719. zmax: number;
  57720. subdivisions?: {
  57721. w: number;
  57722. h: number;
  57723. };
  57724. precision?: {
  57725. w: number;
  57726. h: number;
  57727. };
  57728. updatable?: boolean;
  57729. }, scene?: Nullable<Scene>): Mesh;
  57730. /**
  57731. * Creates a ground mesh from a height map
  57732. * * The parameter `url` sets the URL of the height map image resource.
  57733. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57734. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57735. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57736. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57737. * * 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.
  57738. * * 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).
  57739. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57741. * @param name defines the name of the mesh
  57742. * @param url defines the url to the height map
  57743. * @param options defines the options used to create the mesh
  57744. * @param scene defines the hosting scene
  57745. * @returns the ground mesh
  57746. * @see https://doc.babylonjs.com/babylon101/height_map
  57747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57748. */
  57749. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57750. width?: number;
  57751. height?: number;
  57752. subdivisions?: number;
  57753. minHeight?: number;
  57754. maxHeight?: number;
  57755. colorFilter?: Color3;
  57756. alphaFilter?: number;
  57757. updatable?: boolean;
  57758. onReady?: (mesh: GroundMesh) => void;
  57759. }, scene?: Nullable<Scene>): GroundMesh;
  57760. /**
  57761. * Creates a polygon mesh
  57762. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57763. * * 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
  57764. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57767. * * Remember you can only change the shape positions, not their number when updating a polygon
  57768. * @param name defines the name of the mesh
  57769. * @param options defines the options used to create the mesh
  57770. * @param scene defines the hosting scene
  57771. * @param earcutInjection can be used to inject your own earcut reference
  57772. * @returns the polygon mesh
  57773. */
  57774. static CreatePolygon(name: string, options: {
  57775. shape: Vector3[];
  57776. holes?: Vector3[][];
  57777. depth?: number;
  57778. faceUV?: Vector4[];
  57779. faceColors?: Color4[];
  57780. updatable?: boolean;
  57781. sideOrientation?: number;
  57782. frontUVs?: Vector4;
  57783. backUVs?: Vector4;
  57784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57785. /**
  57786. * Creates an extruded polygon mesh, with depth in the Y direction.
  57787. * * 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)
  57788. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57789. * @param name defines the name of the mesh
  57790. * @param options defines the options used to create the mesh
  57791. * @param scene defines the hosting scene
  57792. * @param earcutInjection can be used to inject your own earcut reference
  57793. * @returns the polygon mesh
  57794. */
  57795. static ExtrudePolygon(name: string, options: {
  57796. shape: Vector3[];
  57797. holes?: Vector3[][];
  57798. depth?: number;
  57799. faceUV?: Vector4[];
  57800. faceColors?: Color4[];
  57801. updatable?: boolean;
  57802. sideOrientation?: number;
  57803. frontUVs?: Vector4;
  57804. backUVs?: Vector4;
  57805. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57806. /**
  57807. * Creates a tube mesh.
  57808. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57809. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57810. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57811. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57812. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57813. * * 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)
  57814. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57815. * * 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
  57816. * * 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
  57817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57821. * @param name defines the name of the mesh
  57822. * @param options defines the options used to create the mesh
  57823. * @param scene defines the hosting scene
  57824. * @returns the tube mesh
  57825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57826. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57827. */
  57828. static CreateTube(name: string, options: {
  57829. path: Vector3[];
  57830. radius?: number;
  57831. tessellation?: number;
  57832. radiusFunction?: {
  57833. (i: number, distance: number): number;
  57834. };
  57835. cap?: number;
  57836. arc?: number;
  57837. updatable?: boolean;
  57838. sideOrientation?: number;
  57839. frontUVs?: Vector4;
  57840. backUVs?: Vector4;
  57841. instance?: Mesh;
  57842. invertUV?: boolean;
  57843. }, scene?: Nullable<Scene>): Mesh;
  57844. /**
  57845. * Creates a polyhedron mesh
  57846. * * 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
  57847. * * The parameter `size` (positive float, default 1) sets the polygon size
  57848. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57849. * * 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`
  57850. * * 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
  57851. * * 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)`)
  57852. * * 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
  57853. * * 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
  57854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57857. * @param name defines the name of the mesh
  57858. * @param options defines the options used to create the mesh
  57859. * @param scene defines the hosting scene
  57860. * @returns the polyhedron mesh
  57861. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57862. */
  57863. static CreatePolyhedron(name: string, options: {
  57864. type?: number;
  57865. size?: number;
  57866. sizeX?: number;
  57867. sizeY?: number;
  57868. sizeZ?: number;
  57869. custom?: any;
  57870. faceUV?: Vector4[];
  57871. faceColors?: Color4[];
  57872. flat?: boolean;
  57873. updatable?: boolean;
  57874. sideOrientation?: number;
  57875. frontUVs?: Vector4;
  57876. backUVs?: Vector4;
  57877. }, scene?: Nullable<Scene>): Mesh;
  57878. /**
  57879. * Creates a decal mesh.
  57880. * 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
  57881. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57882. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57883. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57884. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57885. * @param name defines the name of the mesh
  57886. * @param sourceMesh defines the mesh where the decal must be applied
  57887. * @param options defines the options used to create the mesh
  57888. * @param scene defines the hosting scene
  57889. * @returns the decal mesh
  57890. * @see https://doc.babylonjs.com/how_to/decals
  57891. */
  57892. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57893. position?: Vector3;
  57894. normal?: Vector3;
  57895. size?: Vector3;
  57896. angle?: number;
  57897. }): Mesh;
  57898. }
  57899. }
  57900. declare module "babylonjs/Meshes/meshSimplification" {
  57901. import { Mesh } from "babylonjs/Meshes/mesh";
  57902. /**
  57903. * A simplifier interface for future simplification implementations
  57904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57905. */
  57906. export interface ISimplifier {
  57907. /**
  57908. * Simplification of a given mesh according to the given settings.
  57909. * Since this requires computation, it is assumed that the function runs async.
  57910. * @param settings The settings of the simplification, including quality and distance
  57911. * @param successCallback A callback that will be called after the mesh was simplified.
  57912. * @param errorCallback in case of an error, this callback will be called. optional.
  57913. */
  57914. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57915. }
  57916. /**
  57917. * Expected simplification settings.
  57918. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57920. */
  57921. export interface ISimplificationSettings {
  57922. /**
  57923. * Gets or sets the expected quality
  57924. */
  57925. quality: number;
  57926. /**
  57927. * Gets or sets the distance when this optimized version should be used
  57928. */
  57929. distance: number;
  57930. /**
  57931. * Gets an already optimized mesh
  57932. */
  57933. optimizeMesh?: boolean;
  57934. }
  57935. /**
  57936. * Class used to specify simplification options
  57937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57938. */
  57939. export class SimplificationSettings implements ISimplificationSettings {
  57940. /** expected quality */
  57941. quality: number;
  57942. /** distance when this optimized version should be used */
  57943. distance: number;
  57944. /** already optimized mesh */
  57945. optimizeMesh?: boolean | undefined;
  57946. /**
  57947. * Creates a SimplificationSettings
  57948. * @param quality expected quality
  57949. * @param distance distance when this optimized version should be used
  57950. * @param optimizeMesh already optimized mesh
  57951. */
  57952. constructor(
  57953. /** expected quality */
  57954. quality: number,
  57955. /** distance when this optimized version should be used */
  57956. distance: number,
  57957. /** already optimized mesh */
  57958. optimizeMesh?: boolean | undefined);
  57959. }
  57960. /**
  57961. * Interface used to define a simplification task
  57962. */
  57963. export interface ISimplificationTask {
  57964. /**
  57965. * Array of settings
  57966. */
  57967. settings: Array<ISimplificationSettings>;
  57968. /**
  57969. * Simplification type
  57970. */
  57971. simplificationType: SimplificationType;
  57972. /**
  57973. * Mesh to simplify
  57974. */
  57975. mesh: Mesh;
  57976. /**
  57977. * Callback called on success
  57978. */
  57979. successCallback?: () => void;
  57980. /**
  57981. * Defines if parallel processing can be used
  57982. */
  57983. parallelProcessing: boolean;
  57984. }
  57985. /**
  57986. * Queue used to order the simplification tasks
  57987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57988. */
  57989. export class SimplificationQueue {
  57990. private _simplificationArray;
  57991. /**
  57992. * Gets a boolean indicating that the process is still running
  57993. */
  57994. running: boolean;
  57995. /**
  57996. * Creates a new queue
  57997. */
  57998. constructor();
  57999. /**
  58000. * Adds a new simplification task
  58001. * @param task defines a task to add
  58002. */
  58003. addTask(task: ISimplificationTask): void;
  58004. /**
  58005. * Execute next task
  58006. */
  58007. executeNext(): void;
  58008. /**
  58009. * Execute a simplification task
  58010. * @param task defines the task to run
  58011. */
  58012. runSimplification(task: ISimplificationTask): void;
  58013. private getSimplifier;
  58014. }
  58015. /**
  58016. * The implemented types of simplification
  58017. * At the moment only Quadratic Error Decimation is implemented
  58018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58019. */
  58020. export enum SimplificationType {
  58021. /** Quadratic error decimation */
  58022. QUADRATIC = 0
  58023. }
  58024. }
  58025. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58026. import { Scene } from "babylonjs/scene";
  58027. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58028. import { ISceneComponent } from "babylonjs/sceneComponent";
  58029. module "babylonjs/scene" {
  58030. interface Scene {
  58031. /** @hidden (Backing field) */
  58032. _simplificationQueue: SimplificationQueue;
  58033. /**
  58034. * Gets or sets the simplification queue attached to the scene
  58035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58036. */
  58037. simplificationQueue: SimplificationQueue;
  58038. }
  58039. }
  58040. module "babylonjs/Meshes/mesh" {
  58041. interface Mesh {
  58042. /**
  58043. * Simplify the mesh according to the given array of settings.
  58044. * Function will return immediately and will simplify async
  58045. * @param settings a collection of simplification settings
  58046. * @param parallelProcessing should all levels calculate parallel or one after the other
  58047. * @param simplificationType the type of simplification to run
  58048. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58049. * @returns the current mesh
  58050. */
  58051. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58052. }
  58053. }
  58054. /**
  58055. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58056. * created in a scene
  58057. */
  58058. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58059. /**
  58060. * The component name helpfull to identify the component in the list of scene components.
  58061. */
  58062. readonly name: string;
  58063. /**
  58064. * The scene the component belongs to.
  58065. */
  58066. scene: Scene;
  58067. /**
  58068. * Creates a new instance of the component for the given scene
  58069. * @param scene Defines the scene to register the component in
  58070. */
  58071. constructor(scene: Scene);
  58072. /**
  58073. * Registers the component in a given scene
  58074. */
  58075. register(): void;
  58076. /**
  58077. * Rebuilds the elements related to this component in case of
  58078. * context lost for instance.
  58079. */
  58080. rebuild(): void;
  58081. /**
  58082. * Disposes the component and the associated ressources
  58083. */
  58084. dispose(): void;
  58085. private _beforeCameraUpdate;
  58086. }
  58087. }
  58088. declare module "babylonjs/Meshes/Builders/index" {
  58089. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58090. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58091. export * from "babylonjs/Meshes/Builders/discBuilder";
  58092. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58093. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58094. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58095. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58096. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58097. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58098. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58099. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58100. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58101. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58102. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58103. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58104. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58105. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58106. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58107. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58108. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58109. }
  58110. declare module "babylonjs/Meshes/index" {
  58111. export * from "babylonjs/Meshes/abstractMesh";
  58112. export * from "babylonjs/Meshes/buffer";
  58113. export * from "babylonjs/Meshes/Compression/index";
  58114. export * from "babylonjs/Meshes/csg";
  58115. export * from "babylonjs/Meshes/geometry";
  58116. export * from "babylonjs/Meshes/groundMesh";
  58117. export * from "babylonjs/Meshes/trailMesh";
  58118. export * from "babylonjs/Meshes/instancedMesh";
  58119. export * from "babylonjs/Meshes/linesMesh";
  58120. export * from "babylonjs/Meshes/mesh";
  58121. export * from "babylonjs/Meshes/mesh.vertexData";
  58122. export * from "babylonjs/Meshes/meshBuilder";
  58123. export * from "babylonjs/Meshes/meshSimplification";
  58124. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58125. export * from "babylonjs/Meshes/polygonMesh";
  58126. export * from "babylonjs/Meshes/subMesh";
  58127. export * from "babylonjs/Meshes/meshLODLevel";
  58128. export * from "babylonjs/Meshes/transformNode";
  58129. export * from "babylonjs/Meshes/Builders/index";
  58130. export * from "babylonjs/Meshes/dataBuffer";
  58131. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58132. }
  58133. declare module "babylonjs/Morph/index" {
  58134. export * from "babylonjs/Morph/morphTarget";
  58135. export * from "babylonjs/Morph/morphTargetManager";
  58136. }
  58137. declare module "babylonjs/Navigation/INavigationEngine" {
  58138. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58139. import { Vector3 } from "babylonjs/Maths/math";
  58140. import { Mesh } from "babylonjs/Meshes/mesh";
  58141. import { Scene } from "babylonjs/scene";
  58142. /**
  58143. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58144. */
  58145. export interface INavigationEnginePlugin {
  58146. /**
  58147. * plugin name
  58148. */
  58149. name: string;
  58150. /**
  58151. * Creates a navigation mesh
  58152. * @param meshes array of all the geometry used to compute the navigatio mesh
  58153. * @param parameters bunch of parameters used to filter geometry
  58154. */
  58155. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58156. /**
  58157. * Create a navigation mesh debug mesh
  58158. * @param scene is where the mesh will be added
  58159. * @returns debug display mesh
  58160. */
  58161. createDebugNavMesh(scene: Scene): Mesh;
  58162. /**
  58163. * Get a navigation mesh constrained position, closest to the parameter position
  58164. * @param position world position
  58165. * @returns the closest point to position constrained by the navigation mesh
  58166. */
  58167. getClosestPoint(position: Vector3): Vector3;
  58168. /**
  58169. * Get a navigation mesh constrained position, within a particular radius
  58170. * @param position world position
  58171. * @param maxRadius the maximum distance to the constrained world position
  58172. * @returns the closest point to position constrained by the navigation mesh
  58173. */
  58174. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58175. /**
  58176. * Compute the final position from a segment made of destination-position
  58177. * @param position world position
  58178. * @param destination world position
  58179. * @returns the resulting point along the navmesh
  58180. */
  58181. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58182. /**
  58183. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58184. * @param start world position
  58185. * @param end world position
  58186. * @returns array containing world position composing the path
  58187. */
  58188. computePath(start: Vector3, end: Vector3): Vector3[];
  58189. /**
  58190. * If this plugin is supported
  58191. * @returns true if plugin is supported
  58192. */
  58193. isSupported(): boolean;
  58194. /**
  58195. * Create a new Crowd so you can add agents
  58196. * @param maxAgents the maximum agent count in the crowd
  58197. * @param maxAgentRadius the maximum radius an agent can have
  58198. * @param scene to attach the crowd to
  58199. * @returns the crowd you can add agents to
  58200. */
  58201. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58202. /**
  58203. * Release all resources
  58204. */
  58205. dispose(): void;
  58206. }
  58207. /**
  58208. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58209. */
  58210. export interface ICrowd {
  58211. /**
  58212. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58213. * You can attach anything to that node. The node position is updated in the scene update tick.
  58214. * @param pos world position that will be constrained by the navigation mesh
  58215. * @param parameters agent parameters
  58216. * @param transform hooked to the agent that will be update by the scene
  58217. * @returns agent index
  58218. */
  58219. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58220. /**
  58221. * Returns the agent position in world space
  58222. * @param index agent index returned by addAgent
  58223. * @returns world space position
  58224. */
  58225. getAgentPosition(index: number): Vector3;
  58226. /**
  58227. * Gets the agent velocity in world space
  58228. * @param index agent index returned by addAgent
  58229. * @returns world space velocity
  58230. */
  58231. getAgentVelocity(index: number): Vector3;
  58232. /**
  58233. * remove a particular agent previously created
  58234. * @param index agent index returned by addAgent
  58235. */
  58236. removeAgent(index: number): void;
  58237. /**
  58238. * get the list of all agents attached to this crowd
  58239. * @returns list of agent indices
  58240. */
  58241. getAgents(): number[];
  58242. /**
  58243. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58244. * @param deltaTime in seconds
  58245. */
  58246. update(deltaTime: number): void;
  58247. /**
  58248. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58249. * @param index agent index returned by addAgent
  58250. * @param destination targeted world position
  58251. */
  58252. agentGoto(index: number, destination: Vector3): void;
  58253. /**
  58254. * Release all resources
  58255. */
  58256. dispose(): void;
  58257. }
  58258. /**
  58259. * Configures an agent
  58260. */
  58261. export interface IAgentParameters {
  58262. /**
  58263. * Agent radius. [Limit: >= 0]
  58264. */
  58265. radius: number;
  58266. /**
  58267. * Agent height. [Limit: > 0]
  58268. */
  58269. height: number;
  58270. /**
  58271. * Maximum allowed acceleration. [Limit: >= 0]
  58272. */
  58273. maxAcceleration: number;
  58274. /**
  58275. * Maximum allowed speed. [Limit: >= 0]
  58276. */
  58277. maxSpeed: number;
  58278. /**
  58279. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58280. */
  58281. collisionQueryRange: number;
  58282. /**
  58283. * The path visibility optimization range. [Limit: > 0]
  58284. */
  58285. pathOptimizationRange: number;
  58286. /**
  58287. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58288. */
  58289. separationWeight: number;
  58290. }
  58291. /**
  58292. * Configures the navigation mesh creation
  58293. */
  58294. export interface INavMeshParameters {
  58295. /**
  58296. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58297. */
  58298. cs: number;
  58299. /**
  58300. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58301. */
  58302. ch: number;
  58303. /**
  58304. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58305. */
  58306. walkableSlopeAngle: number;
  58307. /**
  58308. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58309. * be considered walkable. [Limit: >= 3] [Units: vx]
  58310. */
  58311. walkableHeight: number;
  58312. /**
  58313. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58314. */
  58315. walkableClimb: number;
  58316. /**
  58317. * The distance to erode/shrink the walkable area of the heightfield away from
  58318. * obstructions. [Limit: >=0] [Units: vx]
  58319. */
  58320. walkableRadius: number;
  58321. /**
  58322. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58323. */
  58324. maxEdgeLen: number;
  58325. /**
  58326. * The maximum distance a simplfied contour's border edges should deviate
  58327. * the original raw contour. [Limit: >=0] [Units: vx]
  58328. */
  58329. maxSimplificationError: number;
  58330. /**
  58331. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58332. */
  58333. minRegionArea: number;
  58334. /**
  58335. * Any regions with a span count smaller than this value will, if possible,
  58336. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58337. */
  58338. mergeRegionArea: number;
  58339. /**
  58340. * The maximum number of vertices allowed for polygons generated during the
  58341. * contour to polygon conversion process. [Limit: >= 3]
  58342. */
  58343. maxVertsPerPoly: number;
  58344. /**
  58345. * Sets the sampling distance to use when generating the detail mesh.
  58346. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58347. */
  58348. detailSampleDist: number;
  58349. /**
  58350. * The maximum distance the detail mesh surface should deviate from heightfield
  58351. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58352. */
  58353. detailSampleMaxError: number;
  58354. }
  58355. }
  58356. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58357. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58358. import { Mesh } from "babylonjs/Meshes/mesh";
  58359. import { Scene } from "babylonjs/scene";
  58360. import { Vector3 } from "babylonjs/Maths/math";
  58361. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58362. /**
  58363. * RecastJS navigation plugin
  58364. */
  58365. export class RecastJSPlugin implements INavigationEnginePlugin {
  58366. /**
  58367. * Reference to the Recast library
  58368. */
  58369. bjsRECAST: any;
  58370. /**
  58371. * plugin name
  58372. */
  58373. name: string;
  58374. /**
  58375. * the first navmesh created. We might extend this to support multiple navmeshes
  58376. */
  58377. navMesh: any;
  58378. /**
  58379. * Initializes the recastJS plugin
  58380. * @param recastInjection can be used to inject your own recast reference
  58381. */
  58382. constructor(recastInjection?: any);
  58383. /**
  58384. * Creates a navigation mesh
  58385. * @param meshes array of all the geometry used to compute the navigatio mesh
  58386. * @param parameters bunch of parameters used to filter geometry
  58387. */
  58388. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58389. /**
  58390. * Create a navigation mesh debug mesh
  58391. * @param scene is where the mesh will be added
  58392. * @returns debug display mesh
  58393. */
  58394. createDebugNavMesh(scene: Scene): Mesh;
  58395. /**
  58396. * Get a navigation mesh constrained position, closest to the parameter position
  58397. * @param position world position
  58398. * @returns the closest point to position constrained by the navigation mesh
  58399. */
  58400. getClosestPoint(position: Vector3): Vector3;
  58401. /**
  58402. * Get a navigation mesh constrained position, within a particular radius
  58403. * @param position world position
  58404. * @param maxRadius the maximum distance to the constrained world position
  58405. * @returns the closest point to position constrained by the navigation mesh
  58406. */
  58407. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58408. /**
  58409. * Compute the final position from a segment made of destination-position
  58410. * @param position world position
  58411. * @param destination world position
  58412. * @returns the resulting point along the navmesh
  58413. */
  58414. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58415. /**
  58416. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58417. * @param start world position
  58418. * @param end world position
  58419. * @returns array containing world position composing the path
  58420. */
  58421. computePath(start: Vector3, end: Vector3): Vector3[];
  58422. /**
  58423. * Create a new Crowd so you can add agents
  58424. * @param maxAgents the maximum agent count in the crowd
  58425. * @param maxAgentRadius the maximum radius an agent can have
  58426. * @param scene to attach the crowd to
  58427. * @returns the crowd you can add agents to
  58428. */
  58429. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58430. /**
  58431. * Disposes
  58432. */
  58433. dispose(): void;
  58434. /**
  58435. * If this plugin is supported
  58436. * @returns true if plugin is supported
  58437. */
  58438. isSupported(): boolean;
  58439. }
  58440. /**
  58441. * Recast detour crowd implementation
  58442. */
  58443. export class RecastJSCrowd implements ICrowd {
  58444. /**
  58445. * Recast/detour plugin
  58446. */
  58447. bjsRECASTPlugin: RecastJSPlugin;
  58448. /**
  58449. * Link to the detour crowd
  58450. */
  58451. recastCrowd: any;
  58452. /**
  58453. * One transform per agent
  58454. */
  58455. transforms: TransformNode[];
  58456. /**
  58457. * All agents created
  58458. */
  58459. agents: number[];
  58460. /**
  58461. * Link to the scene is kept to unregister the crowd from the scene
  58462. */
  58463. private _scene;
  58464. /**
  58465. * Observer for crowd updates
  58466. */
  58467. private _onBeforeAnimationsObserver;
  58468. /**
  58469. * Constructor
  58470. * @param plugin recastJS plugin
  58471. * @param maxAgents the maximum agent count in the crowd
  58472. * @param maxAgentRadius the maximum radius an agent can have
  58473. * @param scene to attach the crowd to
  58474. * @returns the crowd you can add agents to
  58475. */
  58476. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58477. /**
  58478. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58479. * You can attach anything to that node. The node position is updated in the scene update tick.
  58480. * @param pos world position that will be constrained by the navigation mesh
  58481. * @param parameters agent parameters
  58482. * @param transform hooked to the agent that will be update by the scene
  58483. * @returns agent index
  58484. */
  58485. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58486. /**
  58487. * Returns the agent position in world space
  58488. * @param index agent index returned by addAgent
  58489. * @returns world space position
  58490. */
  58491. getAgentPosition(index: number): Vector3;
  58492. /**
  58493. * Returns the agent velocity in world space
  58494. * @param index agent index returned by addAgent
  58495. * @returns world space velocity
  58496. */
  58497. getAgentVelocity(index: number): Vector3;
  58498. /**
  58499. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58500. * @param index agent index returned by addAgent
  58501. * @param destination targeted world position
  58502. */
  58503. agentGoto(index: number, destination: Vector3): void;
  58504. /**
  58505. * remove a particular agent previously created
  58506. * @param index agent index returned by addAgent
  58507. */
  58508. removeAgent(index: number): void;
  58509. /**
  58510. * get the list of all agents attached to this crowd
  58511. * @returns list of agent indices
  58512. */
  58513. getAgents(): number[];
  58514. /**
  58515. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58516. * @param deltaTime in seconds
  58517. */
  58518. update(deltaTime: number): void;
  58519. /**
  58520. * Release all resources
  58521. */
  58522. dispose(): void;
  58523. }
  58524. }
  58525. declare module "babylonjs/Navigation/Plugins/index" {
  58526. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58527. }
  58528. declare module "babylonjs/Navigation/index" {
  58529. export * from "babylonjs/Navigation/INavigationEngine";
  58530. export * from "babylonjs/Navigation/Plugins/index";
  58531. }
  58532. declare module "babylonjs/Offline/database" {
  58533. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58534. /**
  58535. * Class used to enable access to IndexedDB
  58536. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58537. */
  58538. export class Database implements IOfflineProvider {
  58539. private _callbackManifestChecked;
  58540. private _currentSceneUrl;
  58541. private _db;
  58542. private _enableSceneOffline;
  58543. private _enableTexturesOffline;
  58544. private _manifestVersionFound;
  58545. private _mustUpdateRessources;
  58546. private _hasReachedQuota;
  58547. private _isSupported;
  58548. private _idbFactory;
  58549. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58550. private static IsUASupportingBlobStorage;
  58551. /**
  58552. * Gets a boolean indicating if Database storate is enabled (off by default)
  58553. */
  58554. static IDBStorageEnabled: boolean;
  58555. /**
  58556. * Gets a boolean indicating if scene must be saved in the database
  58557. */
  58558. readonly enableSceneOffline: boolean;
  58559. /**
  58560. * Gets a boolean indicating if textures must be saved in the database
  58561. */
  58562. readonly enableTexturesOffline: boolean;
  58563. /**
  58564. * Creates a new Database
  58565. * @param urlToScene defines the url to load the scene
  58566. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58567. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58568. */
  58569. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58570. private static _ParseURL;
  58571. private static _ReturnFullUrlLocation;
  58572. private _checkManifestFile;
  58573. /**
  58574. * Open the database and make it available
  58575. * @param successCallback defines the callback to call on success
  58576. * @param errorCallback defines the callback to call on error
  58577. */
  58578. open(successCallback: () => void, errorCallback: () => void): void;
  58579. /**
  58580. * Loads an image from the database
  58581. * @param url defines the url to load from
  58582. * @param image defines the target DOM image
  58583. */
  58584. loadImage(url: string, image: HTMLImageElement): void;
  58585. private _loadImageFromDBAsync;
  58586. private _saveImageIntoDBAsync;
  58587. private _checkVersionFromDB;
  58588. private _loadVersionFromDBAsync;
  58589. private _saveVersionIntoDBAsync;
  58590. /**
  58591. * Loads a file from database
  58592. * @param url defines the URL to load from
  58593. * @param sceneLoaded defines a callback to call on success
  58594. * @param progressCallBack defines a callback to call when progress changed
  58595. * @param errorCallback defines a callback to call on error
  58596. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58597. */
  58598. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58599. private _loadFileAsync;
  58600. private _saveFileAsync;
  58601. /**
  58602. * Validates if xhr data is correct
  58603. * @param xhr defines the request to validate
  58604. * @param dataType defines the expected data type
  58605. * @returns true if data is correct
  58606. */
  58607. private static _ValidateXHRData;
  58608. }
  58609. }
  58610. declare module "babylonjs/Offline/index" {
  58611. export * from "babylonjs/Offline/database";
  58612. export * from "babylonjs/Offline/IOfflineProvider";
  58613. }
  58614. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58615. /** @hidden */
  58616. export var gpuUpdateParticlesPixelShader: {
  58617. name: string;
  58618. shader: string;
  58619. };
  58620. }
  58621. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58622. /** @hidden */
  58623. export var gpuUpdateParticlesVertexShader: {
  58624. name: string;
  58625. shader: string;
  58626. };
  58627. }
  58628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58629. /** @hidden */
  58630. export var clipPlaneFragmentDeclaration2: {
  58631. name: string;
  58632. shader: string;
  58633. };
  58634. }
  58635. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58637. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58639. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58640. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58641. /** @hidden */
  58642. export var gpuRenderParticlesPixelShader: {
  58643. name: string;
  58644. shader: string;
  58645. };
  58646. }
  58647. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58648. /** @hidden */
  58649. export var clipPlaneVertexDeclaration2: {
  58650. name: string;
  58651. shader: string;
  58652. };
  58653. }
  58654. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58655. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58656. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58657. /** @hidden */
  58658. export var gpuRenderParticlesVertexShader: {
  58659. name: string;
  58660. shader: string;
  58661. };
  58662. }
  58663. declare module "babylonjs/Particles/gpuParticleSystem" {
  58664. import { Nullable } from "babylonjs/types";
  58665. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58666. import { Observable } from "babylonjs/Misc/observable";
  58667. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58669. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58670. import { Scene, IDisposable } from "babylonjs/scene";
  58671. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58673. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58674. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58675. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58676. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58677. /**
  58678. * This represents a GPU particle system in Babylon
  58679. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58680. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58681. */
  58682. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58683. /**
  58684. * The layer mask we are rendering the particles through.
  58685. */
  58686. layerMask: number;
  58687. private _capacity;
  58688. private _activeCount;
  58689. private _currentActiveCount;
  58690. private _accumulatedCount;
  58691. private _renderEffect;
  58692. private _updateEffect;
  58693. private _buffer0;
  58694. private _buffer1;
  58695. private _spriteBuffer;
  58696. private _updateVAO;
  58697. private _renderVAO;
  58698. private _targetIndex;
  58699. private _sourceBuffer;
  58700. private _targetBuffer;
  58701. private _engine;
  58702. private _currentRenderId;
  58703. private _started;
  58704. private _stopped;
  58705. private _timeDelta;
  58706. private _randomTexture;
  58707. private _randomTexture2;
  58708. private _attributesStrideSize;
  58709. private _updateEffectOptions;
  58710. private _randomTextureSize;
  58711. private _actualFrame;
  58712. private readonly _rawTextureWidth;
  58713. /**
  58714. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58715. */
  58716. static readonly IsSupported: boolean;
  58717. /**
  58718. * An event triggered when the system is disposed.
  58719. */
  58720. onDisposeObservable: Observable<GPUParticleSystem>;
  58721. /**
  58722. * Gets the maximum number of particles active at the same time.
  58723. * @returns The max number of active particles.
  58724. */
  58725. getCapacity(): number;
  58726. /**
  58727. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58728. * to override the particles.
  58729. */
  58730. forceDepthWrite: boolean;
  58731. /**
  58732. * Gets or set the number of active particles
  58733. */
  58734. activeParticleCount: number;
  58735. private _preWarmDone;
  58736. /**
  58737. * Is this system ready to be used/rendered
  58738. * @return true if the system is ready
  58739. */
  58740. isReady(): boolean;
  58741. /**
  58742. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58743. * @returns True if it has been started, otherwise false.
  58744. */
  58745. isStarted(): boolean;
  58746. /**
  58747. * Starts the particle system and begins to emit
  58748. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58749. */
  58750. start(delay?: number): void;
  58751. /**
  58752. * Stops the particle system.
  58753. */
  58754. stop(): void;
  58755. /**
  58756. * Remove all active particles
  58757. */
  58758. reset(): void;
  58759. /**
  58760. * Returns the string "GPUParticleSystem"
  58761. * @returns a string containing the class name
  58762. */
  58763. getClassName(): string;
  58764. private _colorGradientsTexture;
  58765. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58766. /**
  58767. * Adds a new color gradient
  58768. * @param gradient defines the gradient to use (between 0 and 1)
  58769. * @param color1 defines the color to affect to the specified gradient
  58770. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58771. * @returns the current particle system
  58772. */
  58773. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58774. /**
  58775. * Remove a specific color gradient
  58776. * @param gradient defines the gradient to remove
  58777. * @returns the current particle system
  58778. */
  58779. removeColorGradient(gradient: number): GPUParticleSystem;
  58780. private _angularSpeedGradientsTexture;
  58781. private _sizeGradientsTexture;
  58782. private _velocityGradientsTexture;
  58783. private _limitVelocityGradientsTexture;
  58784. private _dragGradientsTexture;
  58785. private _addFactorGradient;
  58786. /**
  58787. * Adds a new size gradient
  58788. * @param gradient defines the gradient to use (between 0 and 1)
  58789. * @param factor defines the size factor to affect to the specified gradient
  58790. * @returns the current particle system
  58791. */
  58792. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58793. /**
  58794. * Remove a specific size gradient
  58795. * @param gradient defines the gradient to remove
  58796. * @returns the current particle system
  58797. */
  58798. removeSizeGradient(gradient: number): GPUParticleSystem;
  58799. /**
  58800. * Adds a new angular speed gradient
  58801. * @param gradient defines the gradient to use (between 0 and 1)
  58802. * @param factor defines the angular speed to affect to the specified gradient
  58803. * @returns the current particle system
  58804. */
  58805. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58806. /**
  58807. * Remove a specific angular speed gradient
  58808. * @param gradient defines the gradient to remove
  58809. * @returns the current particle system
  58810. */
  58811. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58812. /**
  58813. * Adds a new velocity gradient
  58814. * @param gradient defines the gradient to use (between 0 and 1)
  58815. * @param factor defines the velocity to affect to the specified gradient
  58816. * @returns the current particle system
  58817. */
  58818. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58819. /**
  58820. * Remove a specific velocity gradient
  58821. * @param gradient defines the gradient to remove
  58822. * @returns the current particle system
  58823. */
  58824. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58825. /**
  58826. * Adds a new limit velocity gradient
  58827. * @param gradient defines the gradient to use (between 0 and 1)
  58828. * @param factor defines the limit velocity value to affect to the specified gradient
  58829. * @returns the current particle system
  58830. */
  58831. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58832. /**
  58833. * Remove a specific limit velocity gradient
  58834. * @param gradient defines the gradient to remove
  58835. * @returns the current particle system
  58836. */
  58837. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58838. /**
  58839. * Adds a new drag gradient
  58840. * @param gradient defines the gradient to use (between 0 and 1)
  58841. * @param factor defines the drag value to affect to the specified gradient
  58842. * @returns the current particle system
  58843. */
  58844. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58845. /**
  58846. * Remove a specific drag gradient
  58847. * @param gradient defines the gradient to remove
  58848. * @returns the current particle system
  58849. */
  58850. removeDragGradient(gradient: number): GPUParticleSystem;
  58851. /**
  58852. * Not supported by GPUParticleSystem
  58853. * @param gradient defines the gradient to use (between 0 and 1)
  58854. * @param factor defines the emit rate value to affect to the specified gradient
  58855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58856. * @returns the current particle system
  58857. */
  58858. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58859. /**
  58860. * Not supported by GPUParticleSystem
  58861. * @param gradient defines the gradient to remove
  58862. * @returns the current particle system
  58863. */
  58864. removeEmitRateGradient(gradient: number): IParticleSystem;
  58865. /**
  58866. * Not supported by GPUParticleSystem
  58867. * @param gradient defines the gradient to use (between 0 and 1)
  58868. * @param factor defines the start size value to affect to the specified gradient
  58869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58870. * @returns the current particle system
  58871. */
  58872. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58873. /**
  58874. * Not supported by GPUParticleSystem
  58875. * @param gradient defines the gradient to remove
  58876. * @returns the current particle system
  58877. */
  58878. removeStartSizeGradient(gradient: number): IParticleSystem;
  58879. /**
  58880. * Not supported by GPUParticleSystem
  58881. * @param gradient defines the gradient to use (between 0 and 1)
  58882. * @param min defines the color remap minimal range
  58883. * @param max defines the color remap maximal range
  58884. * @returns the current particle system
  58885. */
  58886. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58887. /**
  58888. * Not supported by GPUParticleSystem
  58889. * @param gradient defines the gradient to remove
  58890. * @returns the current particle system
  58891. */
  58892. removeColorRemapGradient(): IParticleSystem;
  58893. /**
  58894. * Not supported by GPUParticleSystem
  58895. * @param gradient defines the gradient to use (between 0 and 1)
  58896. * @param min defines the alpha remap minimal range
  58897. * @param max defines the alpha remap maximal range
  58898. * @returns the current particle system
  58899. */
  58900. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58901. /**
  58902. * Not supported by GPUParticleSystem
  58903. * @param gradient defines the gradient to remove
  58904. * @returns the current particle system
  58905. */
  58906. removeAlphaRemapGradient(): IParticleSystem;
  58907. /**
  58908. * Not supported by GPUParticleSystem
  58909. * @param gradient defines the gradient to use (between 0 and 1)
  58910. * @param color defines the color to affect to the specified gradient
  58911. * @returns the current particle system
  58912. */
  58913. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58914. /**
  58915. * Not supported by GPUParticleSystem
  58916. * @param gradient defines the gradient to remove
  58917. * @returns the current particle system
  58918. */
  58919. removeRampGradient(): IParticleSystem;
  58920. /**
  58921. * Not supported by GPUParticleSystem
  58922. * @returns the list of ramp gradients
  58923. */
  58924. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58925. /**
  58926. * Not supported by GPUParticleSystem
  58927. * Gets or sets a boolean indicating that ramp gradients must be used
  58928. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58929. */
  58930. useRampGradients: boolean;
  58931. /**
  58932. * Not supported by GPUParticleSystem
  58933. * @param gradient defines the gradient to use (between 0 and 1)
  58934. * @param factor defines the life time factor to affect to the specified gradient
  58935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58936. * @returns the current particle system
  58937. */
  58938. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58939. /**
  58940. * Not supported by GPUParticleSystem
  58941. * @param gradient defines the gradient to remove
  58942. * @returns the current particle system
  58943. */
  58944. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58945. /**
  58946. * Instantiates a GPU particle system.
  58947. * 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.
  58948. * @param name The name of the particle system
  58949. * @param options The options used to create the system
  58950. * @param scene The scene the particle system belongs to
  58951. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58952. */
  58953. constructor(name: string, options: Partial<{
  58954. capacity: number;
  58955. randomTextureSize: number;
  58956. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58957. protected _reset(): void;
  58958. private _createUpdateVAO;
  58959. private _createRenderVAO;
  58960. private _initialize;
  58961. /** @hidden */
  58962. _recreateUpdateEffect(): void;
  58963. /** @hidden */
  58964. _recreateRenderEffect(): void;
  58965. /**
  58966. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58967. * @param preWarm defines if we are in the pre-warmimg phase
  58968. */
  58969. animate(preWarm?: boolean): void;
  58970. private _createFactorGradientTexture;
  58971. private _createSizeGradientTexture;
  58972. private _createAngularSpeedGradientTexture;
  58973. private _createVelocityGradientTexture;
  58974. private _createLimitVelocityGradientTexture;
  58975. private _createDragGradientTexture;
  58976. private _createColorGradientTexture;
  58977. /**
  58978. * Renders the particle system in its current state
  58979. * @param preWarm defines if the system should only update the particles but not render them
  58980. * @returns the current number of particles
  58981. */
  58982. render(preWarm?: boolean): number;
  58983. /**
  58984. * Rebuilds the particle system
  58985. */
  58986. rebuild(): void;
  58987. private _releaseBuffers;
  58988. private _releaseVAOs;
  58989. /**
  58990. * Disposes the particle system and free the associated resources
  58991. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58992. */
  58993. dispose(disposeTexture?: boolean): void;
  58994. /**
  58995. * Clones the particle system.
  58996. * @param name The name of the cloned object
  58997. * @param newEmitter The new emitter to use
  58998. * @returns the cloned particle system
  58999. */
  59000. clone(name: string, newEmitter: any): GPUParticleSystem;
  59001. /**
  59002. * Serializes the particle system to a JSON object.
  59003. * @returns the JSON object
  59004. */
  59005. serialize(): any;
  59006. /**
  59007. * Parses a JSON object to create a GPU particle system.
  59008. * @param parsedParticleSystem The JSON object to parse
  59009. * @param scene The scene to create the particle system in
  59010. * @param rootUrl The root url to use to load external dependencies like texture
  59011. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59012. * @returns the parsed GPU particle system
  59013. */
  59014. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59015. }
  59016. }
  59017. declare module "babylonjs/Particles/particleSystemSet" {
  59018. import { Nullable } from "babylonjs/types";
  59019. import { Color3 } from "babylonjs/Maths/math.color";
  59020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59022. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59023. import { Scene, IDisposable } from "babylonjs/scene";
  59024. /**
  59025. * Represents a set of particle systems working together to create a specific effect
  59026. */
  59027. export class ParticleSystemSet implements IDisposable {
  59028. private _emitterCreationOptions;
  59029. private _emitterNode;
  59030. /**
  59031. * Gets the particle system list
  59032. */
  59033. systems: IParticleSystem[];
  59034. /**
  59035. * Gets the emitter node used with this set
  59036. */
  59037. readonly emitterNode: Nullable<TransformNode>;
  59038. /**
  59039. * Creates a new emitter mesh as a sphere
  59040. * @param options defines the options used to create the sphere
  59041. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59042. * @param scene defines the hosting scene
  59043. */
  59044. setEmitterAsSphere(options: {
  59045. diameter: number;
  59046. segments: number;
  59047. color: Color3;
  59048. }, renderingGroupId: number, scene: Scene): void;
  59049. /**
  59050. * Starts all particle systems of the set
  59051. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59052. */
  59053. start(emitter?: AbstractMesh): void;
  59054. /**
  59055. * Release all associated resources
  59056. */
  59057. dispose(): void;
  59058. /**
  59059. * Serialize the set into a JSON compatible object
  59060. * @returns a JSON compatible representation of the set
  59061. */
  59062. serialize(): any;
  59063. /**
  59064. * Parse a new ParticleSystemSet from a serialized source
  59065. * @param data defines a JSON compatible representation of the set
  59066. * @param scene defines the hosting scene
  59067. * @param gpu defines if we want GPU particles or CPU particles
  59068. * @returns a new ParticleSystemSet
  59069. */
  59070. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59071. }
  59072. }
  59073. declare module "babylonjs/Particles/particleHelper" {
  59074. import { Nullable } from "babylonjs/types";
  59075. import { Scene } from "babylonjs/scene";
  59076. import { Vector3 } from "babylonjs/Maths/math.vector";
  59077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59079. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59080. /**
  59081. * This class is made for on one-liner static method to help creating particle system set.
  59082. */
  59083. export class ParticleHelper {
  59084. /**
  59085. * Gets or sets base Assets URL
  59086. */
  59087. static BaseAssetsUrl: string;
  59088. /**
  59089. * Create a default particle system that you can tweak
  59090. * @param emitter defines the emitter to use
  59091. * @param capacity defines the system capacity (default is 500 particles)
  59092. * @param scene defines the hosting scene
  59093. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59094. * @returns the new Particle system
  59095. */
  59096. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59097. /**
  59098. * This is the main static method (one-liner) of this helper to create different particle systems
  59099. * @param type This string represents the type to the particle system to create
  59100. * @param scene The scene where the particle system should live
  59101. * @param gpu If the system will use gpu
  59102. * @returns the ParticleSystemSet created
  59103. */
  59104. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59105. /**
  59106. * Static function used to export a particle system to a ParticleSystemSet variable.
  59107. * Please note that the emitter shape is not exported
  59108. * @param systems defines the particle systems to export
  59109. * @returns the created particle system set
  59110. */
  59111. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59112. }
  59113. }
  59114. declare module "babylonjs/Particles/particleSystemComponent" {
  59115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59116. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59117. import "babylonjs/Shaders/particles.vertex";
  59118. module "babylonjs/Engines/engine" {
  59119. interface Engine {
  59120. /**
  59121. * Create an effect to use with particle systems.
  59122. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59123. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59124. * @param uniformsNames defines a list of attribute names
  59125. * @param samplers defines an array of string used to represent textures
  59126. * @param defines defines the string containing the defines to use to compile the shaders
  59127. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59128. * @param onCompiled defines a function to call when the effect creation is successful
  59129. * @param onError defines a function to call when the effect creation has failed
  59130. * @returns the new Effect
  59131. */
  59132. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59133. }
  59134. }
  59135. module "babylonjs/Meshes/mesh" {
  59136. interface Mesh {
  59137. /**
  59138. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59139. * @returns an array of IParticleSystem
  59140. */
  59141. getEmittedParticleSystems(): IParticleSystem[];
  59142. /**
  59143. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59144. * @returns an array of IParticleSystem
  59145. */
  59146. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59147. }
  59148. }
  59149. /**
  59150. * @hidden
  59151. */
  59152. export var _IDoNeedToBeInTheBuild: number;
  59153. }
  59154. declare module "babylonjs/Particles/index" {
  59155. export * from "babylonjs/Particles/baseParticleSystem";
  59156. export * from "babylonjs/Particles/EmitterTypes/index";
  59157. export * from "babylonjs/Particles/gpuParticleSystem";
  59158. export * from "babylonjs/Particles/IParticleSystem";
  59159. export * from "babylonjs/Particles/particle";
  59160. export * from "babylonjs/Particles/particleHelper";
  59161. export * from "babylonjs/Particles/particleSystem";
  59162. export * from "babylonjs/Particles/particleSystemComponent";
  59163. export * from "babylonjs/Particles/particleSystemSet";
  59164. export * from "babylonjs/Particles/solidParticle";
  59165. export * from "babylonjs/Particles/solidParticleSystem";
  59166. export * from "babylonjs/Particles/subEmitter";
  59167. }
  59168. declare module "babylonjs/Physics/physicsEngineComponent" {
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Observable, Observer } from "babylonjs/Misc/observable";
  59171. import { Vector3 } from "babylonjs/Maths/math.vector";
  59172. import { Mesh } from "babylonjs/Meshes/mesh";
  59173. import { ISceneComponent } from "babylonjs/sceneComponent";
  59174. import { Scene } from "babylonjs/scene";
  59175. import { Node } from "babylonjs/node";
  59176. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59177. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59178. module "babylonjs/scene" {
  59179. interface Scene {
  59180. /** @hidden (Backing field) */
  59181. _physicsEngine: Nullable<IPhysicsEngine>;
  59182. /**
  59183. * Gets the current physics engine
  59184. * @returns a IPhysicsEngine or null if none attached
  59185. */
  59186. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59187. /**
  59188. * Enables physics to the current scene
  59189. * @param gravity defines the scene's gravity for the physics engine
  59190. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59191. * @return a boolean indicating if the physics engine was initialized
  59192. */
  59193. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59194. /**
  59195. * Disables and disposes the physics engine associated with the scene
  59196. */
  59197. disablePhysicsEngine(): void;
  59198. /**
  59199. * Gets a boolean indicating if there is an active physics engine
  59200. * @returns a boolean indicating if there is an active physics engine
  59201. */
  59202. isPhysicsEnabled(): boolean;
  59203. /**
  59204. * Deletes a physics compound impostor
  59205. * @param compound defines the compound to delete
  59206. */
  59207. deleteCompoundImpostor(compound: any): void;
  59208. /**
  59209. * An event triggered when physic simulation is about to be run
  59210. */
  59211. onBeforePhysicsObservable: Observable<Scene>;
  59212. /**
  59213. * An event triggered when physic simulation has been done
  59214. */
  59215. onAfterPhysicsObservable: Observable<Scene>;
  59216. }
  59217. }
  59218. module "babylonjs/Meshes/abstractMesh" {
  59219. interface AbstractMesh {
  59220. /** @hidden */
  59221. _physicsImpostor: Nullable<PhysicsImpostor>;
  59222. /**
  59223. * Gets or sets impostor used for physic simulation
  59224. * @see http://doc.babylonjs.com/features/physics_engine
  59225. */
  59226. physicsImpostor: Nullable<PhysicsImpostor>;
  59227. /**
  59228. * Gets the current physics impostor
  59229. * @see http://doc.babylonjs.com/features/physics_engine
  59230. * @returns a physics impostor or null
  59231. */
  59232. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59233. /** Apply a physic impulse to the mesh
  59234. * @param force defines the force to apply
  59235. * @param contactPoint defines where to apply the force
  59236. * @returns the current mesh
  59237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59238. */
  59239. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59240. /**
  59241. * Creates a physic joint between two meshes
  59242. * @param otherMesh defines the other mesh to use
  59243. * @param pivot1 defines the pivot to use on this mesh
  59244. * @param pivot2 defines the pivot to use on the other mesh
  59245. * @param options defines additional options (can be plugin dependent)
  59246. * @returns the current mesh
  59247. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59248. */
  59249. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59250. /** @hidden */
  59251. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59252. }
  59253. }
  59254. /**
  59255. * Defines the physics engine scene component responsible to manage a physics engine
  59256. */
  59257. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59258. /**
  59259. * The component name helpful to identify the component in the list of scene components.
  59260. */
  59261. readonly name: string;
  59262. /**
  59263. * The scene the component belongs to.
  59264. */
  59265. scene: Scene;
  59266. /**
  59267. * Creates a new instance of the component for the given scene
  59268. * @param scene Defines the scene to register the component in
  59269. */
  59270. constructor(scene: Scene);
  59271. /**
  59272. * Registers the component in a given scene
  59273. */
  59274. register(): void;
  59275. /**
  59276. * Rebuilds the elements related to this component in case of
  59277. * context lost for instance.
  59278. */
  59279. rebuild(): void;
  59280. /**
  59281. * Disposes the component and the associated ressources
  59282. */
  59283. dispose(): void;
  59284. }
  59285. }
  59286. declare module "babylonjs/Physics/physicsHelper" {
  59287. import { Nullable } from "babylonjs/types";
  59288. import { Vector3 } from "babylonjs/Maths/math.vector";
  59289. import { Mesh } from "babylonjs/Meshes/mesh";
  59290. import { Scene } from "babylonjs/scene";
  59291. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59292. /**
  59293. * A helper for physics simulations
  59294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59295. */
  59296. export class PhysicsHelper {
  59297. private _scene;
  59298. private _physicsEngine;
  59299. /**
  59300. * Initializes the Physics helper
  59301. * @param scene Babylon.js scene
  59302. */
  59303. constructor(scene: Scene);
  59304. /**
  59305. * Applies a radial explosion impulse
  59306. * @param origin the origin of the explosion
  59307. * @param radiusOrEventOptions the radius or the options of radial explosion
  59308. * @param strength the explosion strength
  59309. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59310. * @returns A physics radial explosion event, or null
  59311. */
  59312. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59313. /**
  59314. * Applies a radial explosion force
  59315. * @param origin the origin of the explosion
  59316. * @param radiusOrEventOptions the radius or the options of radial explosion
  59317. * @param strength the explosion strength
  59318. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59319. * @returns A physics radial explosion event, or null
  59320. */
  59321. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59322. /**
  59323. * Creates a gravitational field
  59324. * @param origin the origin of the explosion
  59325. * @param radiusOrEventOptions the radius or the options of radial explosion
  59326. * @param strength the explosion strength
  59327. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59328. * @returns A physics gravitational field event, or null
  59329. */
  59330. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59331. /**
  59332. * Creates a physics updraft event
  59333. * @param origin the origin of the updraft
  59334. * @param radiusOrEventOptions the radius or the options of the updraft
  59335. * @param strength the strength of the updraft
  59336. * @param height the height of the updraft
  59337. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59338. * @returns A physics updraft event, or null
  59339. */
  59340. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59341. /**
  59342. * Creates a physics vortex event
  59343. * @param origin the of the vortex
  59344. * @param radiusOrEventOptions the radius or the options of the vortex
  59345. * @param strength the strength of the vortex
  59346. * @param height the height of the vortex
  59347. * @returns a Physics vortex event, or null
  59348. * A physics vortex event or null
  59349. */
  59350. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59351. }
  59352. /**
  59353. * Represents a physics radial explosion event
  59354. */
  59355. class PhysicsRadialExplosionEvent {
  59356. private _scene;
  59357. private _options;
  59358. private _sphere;
  59359. private _dataFetched;
  59360. /**
  59361. * Initializes a radial explosioin event
  59362. * @param _scene BabylonJS scene
  59363. * @param _options The options for the vortex event
  59364. */
  59365. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59366. /**
  59367. * Returns the data related to the radial explosion event (sphere).
  59368. * @returns The radial explosion event data
  59369. */
  59370. getData(): PhysicsRadialExplosionEventData;
  59371. /**
  59372. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59373. * @param impostor A physics imposter
  59374. * @param origin the origin of the explosion
  59375. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59376. */
  59377. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59378. /**
  59379. * Triggers affecterd impostors callbacks
  59380. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59381. */
  59382. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59383. /**
  59384. * Disposes the sphere.
  59385. * @param force Specifies if the sphere should be disposed by force
  59386. */
  59387. dispose(force?: boolean): void;
  59388. /*** Helpers ***/
  59389. private _prepareSphere;
  59390. private _intersectsWithSphere;
  59391. }
  59392. /**
  59393. * Represents a gravitational field event
  59394. */
  59395. class PhysicsGravitationalFieldEvent {
  59396. private _physicsHelper;
  59397. private _scene;
  59398. private _origin;
  59399. private _options;
  59400. private _tickCallback;
  59401. private _sphere;
  59402. private _dataFetched;
  59403. /**
  59404. * Initializes the physics gravitational field event
  59405. * @param _physicsHelper A physics helper
  59406. * @param _scene BabylonJS scene
  59407. * @param _origin The origin position of the gravitational field event
  59408. * @param _options The options for the vortex event
  59409. */
  59410. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59411. /**
  59412. * Returns the data related to the gravitational field event (sphere).
  59413. * @returns A gravitational field event
  59414. */
  59415. getData(): PhysicsGravitationalFieldEventData;
  59416. /**
  59417. * Enables the gravitational field.
  59418. */
  59419. enable(): void;
  59420. /**
  59421. * Disables the gravitational field.
  59422. */
  59423. disable(): void;
  59424. /**
  59425. * Disposes the sphere.
  59426. * @param force The force to dispose from the gravitational field event
  59427. */
  59428. dispose(force?: boolean): void;
  59429. private _tick;
  59430. }
  59431. /**
  59432. * Represents a physics updraft event
  59433. */
  59434. class PhysicsUpdraftEvent {
  59435. private _scene;
  59436. private _origin;
  59437. private _options;
  59438. private _physicsEngine;
  59439. private _originTop;
  59440. private _originDirection;
  59441. private _tickCallback;
  59442. private _cylinder;
  59443. private _cylinderPosition;
  59444. private _dataFetched;
  59445. /**
  59446. * Initializes the physics updraft event
  59447. * @param _scene BabylonJS scene
  59448. * @param _origin The origin position of the updraft
  59449. * @param _options The options for the updraft event
  59450. */
  59451. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59452. /**
  59453. * Returns the data related to the updraft event (cylinder).
  59454. * @returns A physics updraft event
  59455. */
  59456. getData(): PhysicsUpdraftEventData;
  59457. /**
  59458. * Enables the updraft.
  59459. */
  59460. enable(): void;
  59461. /**
  59462. * Disables the updraft.
  59463. */
  59464. disable(): void;
  59465. /**
  59466. * Disposes the cylinder.
  59467. * @param force Specifies if the updraft should be disposed by force
  59468. */
  59469. dispose(force?: boolean): void;
  59470. private getImpostorHitData;
  59471. private _tick;
  59472. /*** Helpers ***/
  59473. private _prepareCylinder;
  59474. private _intersectsWithCylinder;
  59475. }
  59476. /**
  59477. * Represents a physics vortex event
  59478. */
  59479. class PhysicsVortexEvent {
  59480. private _scene;
  59481. private _origin;
  59482. private _options;
  59483. private _physicsEngine;
  59484. private _originTop;
  59485. private _tickCallback;
  59486. private _cylinder;
  59487. private _cylinderPosition;
  59488. private _dataFetched;
  59489. /**
  59490. * Initializes the physics vortex event
  59491. * @param _scene The BabylonJS scene
  59492. * @param _origin The origin position of the vortex
  59493. * @param _options The options for the vortex event
  59494. */
  59495. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59496. /**
  59497. * Returns the data related to the vortex event (cylinder).
  59498. * @returns The physics vortex event data
  59499. */
  59500. getData(): PhysicsVortexEventData;
  59501. /**
  59502. * Enables the vortex.
  59503. */
  59504. enable(): void;
  59505. /**
  59506. * Disables the cortex.
  59507. */
  59508. disable(): void;
  59509. /**
  59510. * Disposes the sphere.
  59511. * @param force
  59512. */
  59513. dispose(force?: boolean): void;
  59514. private getImpostorHitData;
  59515. private _tick;
  59516. /*** Helpers ***/
  59517. private _prepareCylinder;
  59518. private _intersectsWithCylinder;
  59519. }
  59520. /**
  59521. * Options fot the radial explosion event
  59522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59523. */
  59524. export class PhysicsRadialExplosionEventOptions {
  59525. /**
  59526. * The radius of the sphere for the radial explosion.
  59527. */
  59528. radius: number;
  59529. /**
  59530. * The strenth of the explosion.
  59531. */
  59532. strength: number;
  59533. /**
  59534. * The strenght of the force in correspondence to the distance of the affected object
  59535. */
  59536. falloff: PhysicsRadialImpulseFalloff;
  59537. /**
  59538. * Sphere options for the radial explosion.
  59539. */
  59540. sphere: {
  59541. segments: number;
  59542. diameter: number;
  59543. };
  59544. /**
  59545. * Sphere options for the radial explosion.
  59546. */
  59547. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59548. }
  59549. /**
  59550. * Options fot the updraft event
  59551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59552. */
  59553. export class PhysicsUpdraftEventOptions {
  59554. /**
  59555. * The radius of the cylinder for the vortex
  59556. */
  59557. radius: number;
  59558. /**
  59559. * The strenth of the updraft.
  59560. */
  59561. strength: number;
  59562. /**
  59563. * The height of the cylinder for the updraft.
  59564. */
  59565. height: number;
  59566. /**
  59567. * The mode for the the updraft.
  59568. */
  59569. updraftMode: PhysicsUpdraftMode;
  59570. }
  59571. /**
  59572. * Options fot the vortex event
  59573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59574. */
  59575. export class PhysicsVortexEventOptions {
  59576. /**
  59577. * The radius of the cylinder for the vortex
  59578. */
  59579. radius: number;
  59580. /**
  59581. * The strenth of the vortex.
  59582. */
  59583. strength: number;
  59584. /**
  59585. * The height of the cylinder for the vortex.
  59586. */
  59587. height: number;
  59588. /**
  59589. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59590. */
  59591. centripetalForceThreshold: number;
  59592. /**
  59593. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59594. */
  59595. centripetalForceMultiplier: number;
  59596. /**
  59597. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59598. */
  59599. centrifugalForceMultiplier: number;
  59600. /**
  59601. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59602. */
  59603. updraftForceMultiplier: number;
  59604. }
  59605. /**
  59606. * The strenght of the force in correspondence to the distance of the affected object
  59607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59608. */
  59609. export enum PhysicsRadialImpulseFalloff {
  59610. /** Defines that impulse is constant in strength across it's whole radius */
  59611. Constant = 0,
  59612. /** Defines that impulse gets weaker if it's further from the origin */
  59613. Linear = 1
  59614. }
  59615. /**
  59616. * The strength of the force in correspondence to the distance of the affected object
  59617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59618. */
  59619. export enum PhysicsUpdraftMode {
  59620. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59621. Center = 0,
  59622. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59623. Perpendicular = 1
  59624. }
  59625. /**
  59626. * Interface for a physics hit data
  59627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59628. */
  59629. export interface PhysicsHitData {
  59630. /**
  59631. * The force applied at the contact point
  59632. */
  59633. force: Vector3;
  59634. /**
  59635. * The contact point
  59636. */
  59637. contactPoint: Vector3;
  59638. /**
  59639. * The distance from the origin to the contact point
  59640. */
  59641. distanceFromOrigin: number;
  59642. }
  59643. /**
  59644. * Interface for radial explosion event data
  59645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59646. */
  59647. export interface PhysicsRadialExplosionEventData {
  59648. /**
  59649. * A sphere used for the radial explosion event
  59650. */
  59651. sphere: Mesh;
  59652. }
  59653. /**
  59654. * Interface for gravitational field event data
  59655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59656. */
  59657. export interface PhysicsGravitationalFieldEventData {
  59658. /**
  59659. * A sphere mesh used for the gravitational field event
  59660. */
  59661. sphere: Mesh;
  59662. }
  59663. /**
  59664. * Interface for updraft event data
  59665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59666. */
  59667. export interface PhysicsUpdraftEventData {
  59668. /**
  59669. * A cylinder used for the updraft event
  59670. */
  59671. cylinder: Mesh;
  59672. }
  59673. /**
  59674. * Interface for vortex event data
  59675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59676. */
  59677. export interface PhysicsVortexEventData {
  59678. /**
  59679. * A cylinder used for the vortex event
  59680. */
  59681. cylinder: Mesh;
  59682. }
  59683. /**
  59684. * Interface for an affected physics impostor
  59685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59686. */
  59687. export interface PhysicsAffectedImpostorWithData {
  59688. /**
  59689. * The impostor affected by the effect
  59690. */
  59691. impostor: PhysicsImpostor;
  59692. /**
  59693. * The data about the hit/horce from the explosion
  59694. */
  59695. hitData: PhysicsHitData;
  59696. }
  59697. }
  59698. declare module "babylonjs/Physics/Plugins/index" {
  59699. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59700. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59701. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59702. }
  59703. declare module "babylonjs/Physics/index" {
  59704. export * from "babylonjs/Physics/IPhysicsEngine";
  59705. export * from "babylonjs/Physics/physicsEngine";
  59706. export * from "babylonjs/Physics/physicsEngineComponent";
  59707. export * from "babylonjs/Physics/physicsHelper";
  59708. export * from "babylonjs/Physics/physicsImpostor";
  59709. export * from "babylonjs/Physics/physicsJoint";
  59710. export * from "babylonjs/Physics/Plugins/index";
  59711. }
  59712. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59713. /** @hidden */
  59714. export var blackAndWhitePixelShader: {
  59715. name: string;
  59716. shader: string;
  59717. };
  59718. }
  59719. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59720. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59721. import { Camera } from "babylonjs/Cameras/camera";
  59722. import { Engine } from "babylonjs/Engines/engine";
  59723. import "babylonjs/Shaders/blackAndWhite.fragment";
  59724. /**
  59725. * Post process used to render in black and white
  59726. */
  59727. export class BlackAndWhitePostProcess extends PostProcess {
  59728. /**
  59729. * Linear about to convert he result to black and white (default: 1)
  59730. */
  59731. degree: number;
  59732. /**
  59733. * Creates a black and white post process
  59734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59735. * @param name The name of the effect.
  59736. * @param options The required width/height ratio to downsize to before computing the render pass.
  59737. * @param camera The camera to apply the render pass to.
  59738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59739. * @param engine The engine which the post process will be applied. (default: current engine)
  59740. * @param reusable If the post process can be reused on the same frame. (default: false)
  59741. */
  59742. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59743. }
  59744. }
  59745. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59746. import { Nullable } from "babylonjs/types";
  59747. import { Camera } from "babylonjs/Cameras/camera";
  59748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59749. import { Engine } from "babylonjs/Engines/engine";
  59750. /**
  59751. * This represents a set of one or more post processes in Babylon.
  59752. * A post process can be used to apply a shader to a texture after it is rendered.
  59753. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59754. */
  59755. export class PostProcessRenderEffect {
  59756. private _postProcesses;
  59757. private _getPostProcesses;
  59758. private _singleInstance;
  59759. private _cameras;
  59760. private _indicesForCamera;
  59761. /**
  59762. * Name of the effect
  59763. * @hidden
  59764. */
  59765. _name: string;
  59766. /**
  59767. * Instantiates a post process render effect.
  59768. * A post process can be used to apply a shader to a texture after it is rendered.
  59769. * @param engine The engine the effect is tied to
  59770. * @param name The name of the effect
  59771. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59772. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59773. */
  59774. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59775. /**
  59776. * Checks if all the post processes in the effect are supported.
  59777. */
  59778. readonly isSupported: boolean;
  59779. /**
  59780. * Updates the current state of the effect
  59781. * @hidden
  59782. */
  59783. _update(): void;
  59784. /**
  59785. * Attaches the effect on cameras
  59786. * @param cameras The camera to attach to.
  59787. * @hidden
  59788. */
  59789. _attachCameras(cameras: Camera): void;
  59790. /**
  59791. * Attaches the effect on cameras
  59792. * @param cameras The camera to attach to.
  59793. * @hidden
  59794. */
  59795. _attachCameras(cameras: Camera[]): void;
  59796. /**
  59797. * Detaches the effect on cameras
  59798. * @param cameras The camera to detatch from.
  59799. * @hidden
  59800. */
  59801. _detachCameras(cameras: Camera): void;
  59802. /**
  59803. * Detatches the effect on cameras
  59804. * @param cameras The camera to detatch from.
  59805. * @hidden
  59806. */
  59807. _detachCameras(cameras: Camera[]): void;
  59808. /**
  59809. * Enables the effect on given cameras
  59810. * @param cameras The camera to enable.
  59811. * @hidden
  59812. */
  59813. _enable(cameras: Camera): void;
  59814. /**
  59815. * Enables the effect on given cameras
  59816. * @param cameras The camera to enable.
  59817. * @hidden
  59818. */
  59819. _enable(cameras: Nullable<Camera[]>): void;
  59820. /**
  59821. * Disables the effect on the given cameras
  59822. * @param cameras The camera to disable.
  59823. * @hidden
  59824. */
  59825. _disable(cameras: Camera): void;
  59826. /**
  59827. * Disables the effect on the given cameras
  59828. * @param cameras The camera to disable.
  59829. * @hidden
  59830. */
  59831. _disable(cameras: Nullable<Camera[]>): void;
  59832. /**
  59833. * Gets a list of the post processes contained in the effect.
  59834. * @param camera The camera to get the post processes on.
  59835. * @returns The list of the post processes in the effect.
  59836. */
  59837. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59838. }
  59839. }
  59840. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59841. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59842. /** @hidden */
  59843. export var extractHighlightsPixelShader: {
  59844. name: string;
  59845. shader: string;
  59846. };
  59847. }
  59848. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59849. import { Nullable } from "babylonjs/types";
  59850. import { Camera } from "babylonjs/Cameras/camera";
  59851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59852. import { Engine } from "babylonjs/Engines/engine";
  59853. import "babylonjs/Shaders/extractHighlights.fragment";
  59854. /**
  59855. * 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.
  59856. */
  59857. export class ExtractHighlightsPostProcess extends PostProcess {
  59858. /**
  59859. * The luminance threshold, pixels below this value will be set to black.
  59860. */
  59861. threshold: number;
  59862. /** @hidden */
  59863. _exposure: number;
  59864. /**
  59865. * Post process which has the input texture to be used when performing highlight extraction
  59866. * @hidden
  59867. */
  59868. _inputPostProcess: Nullable<PostProcess>;
  59869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59870. }
  59871. }
  59872. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59873. /** @hidden */
  59874. export var bloomMergePixelShader: {
  59875. name: string;
  59876. shader: string;
  59877. };
  59878. }
  59879. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59881. import { Nullable } from "babylonjs/types";
  59882. import { Engine } from "babylonjs/Engines/engine";
  59883. import { Camera } from "babylonjs/Cameras/camera";
  59884. import "babylonjs/Shaders/bloomMerge.fragment";
  59885. /**
  59886. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59887. */
  59888. export class BloomMergePostProcess extends PostProcess {
  59889. /** Weight of the bloom to be added to the original input. */
  59890. weight: number;
  59891. /**
  59892. * Creates a new instance of @see BloomMergePostProcess
  59893. * @param name The name of the effect.
  59894. * @param originalFromInput Post process which's input will be used for the merge.
  59895. * @param blurred Blurred highlights post process which's output will be used.
  59896. * @param weight Weight of the bloom to be added to the original input.
  59897. * @param options The required width/height ratio to downsize to before computing the render pass.
  59898. * @param camera The camera to apply the render pass to.
  59899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59900. * @param engine The engine which the post process will be applied. (default: current engine)
  59901. * @param reusable If the post process can be reused on the same frame. (default: false)
  59902. * @param textureType Type of textures used when performing the post process. (default: 0)
  59903. * @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)
  59904. */
  59905. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59906. /** Weight of the bloom to be added to the original input. */
  59907. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59908. }
  59909. }
  59910. declare module "babylonjs/PostProcesses/bloomEffect" {
  59911. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59913. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59914. import { Camera } from "babylonjs/Cameras/camera";
  59915. import { Scene } from "babylonjs/scene";
  59916. /**
  59917. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59918. */
  59919. export class BloomEffect extends PostProcessRenderEffect {
  59920. private bloomScale;
  59921. /**
  59922. * @hidden Internal
  59923. */
  59924. _effects: Array<PostProcess>;
  59925. /**
  59926. * @hidden Internal
  59927. */
  59928. _downscale: ExtractHighlightsPostProcess;
  59929. private _blurX;
  59930. private _blurY;
  59931. private _merge;
  59932. /**
  59933. * The luminance threshold to find bright areas of the image to bloom.
  59934. */
  59935. threshold: number;
  59936. /**
  59937. * The strength of the bloom.
  59938. */
  59939. weight: number;
  59940. /**
  59941. * Specifies the size of the bloom blur kernel, relative to the final output size
  59942. */
  59943. kernel: number;
  59944. /**
  59945. * Creates a new instance of @see BloomEffect
  59946. * @param scene The scene the effect belongs to.
  59947. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59948. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59949. * @param bloomWeight The the strength of bloom.
  59950. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59951. * @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)
  59952. */
  59953. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59954. /**
  59955. * Disposes each of the internal effects for a given camera.
  59956. * @param camera The camera to dispose the effect on.
  59957. */
  59958. disposeEffects(camera: Camera): void;
  59959. /**
  59960. * @hidden Internal
  59961. */
  59962. _updateEffects(): void;
  59963. /**
  59964. * Internal
  59965. * @returns if all the contained post processes are ready.
  59966. * @hidden
  59967. */
  59968. _isReady(): boolean;
  59969. }
  59970. }
  59971. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59972. /** @hidden */
  59973. export var chromaticAberrationPixelShader: {
  59974. name: string;
  59975. shader: string;
  59976. };
  59977. }
  59978. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59979. import { Vector2 } from "babylonjs/Maths/math.vector";
  59980. import { Nullable } from "babylonjs/types";
  59981. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59982. import { Camera } from "babylonjs/Cameras/camera";
  59983. import { Engine } from "babylonjs/Engines/engine";
  59984. import "babylonjs/Shaders/chromaticAberration.fragment";
  59985. /**
  59986. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59987. */
  59988. export class ChromaticAberrationPostProcess extends PostProcess {
  59989. /**
  59990. * The amount of seperation of rgb channels (default: 30)
  59991. */
  59992. aberrationAmount: number;
  59993. /**
  59994. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59995. */
  59996. radialIntensity: number;
  59997. /**
  59998. * 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))
  59999. */
  60000. direction: Vector2;
  60001. /**
  60002. * 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))
  60003. */
  60004. centerPosition: Vector2;
  60005. /**
  60006. * Creates a new instance ChromaticAberrationPostProcess
  60007. * @param name The name of the effect.
  60008. * @param screenWidth The width of the screen to apply the effect on.
  60009. * @param screenHeight The height of the screen to apply the effect on.
  60010. * @param options The required width/height ratio to downsize to before computing the render pass.
  60011. * @param camera The camera to apply the render pass to.
  60012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60013. * @param engine The engine which the post process will be applied. (default: current engine)
  60014. * @param reusable If the post process can be reused on the same frame. (default: false)
  60015. * @param textureType Type of textures used when performing the post process. (default: 0)
  60016. * @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)
  60017. */
  60018. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60019. }
  60020. }
  60021. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60022. /** @hidden */
  60023. export var circleOfConfusionPixelShader: {
  60024. name: string;
  60025. shader: string;
  60026. };
  60027. }
  60028. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60029. import { Nullable } from "babylonjs/types";
  60030. import { Engine } from "babylonjs/Engines/engine";
  60031. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60033. import { Camera } from "babylonjs/Cameras/camera";
  60034. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60035. /**
  60036. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60037. */
  60038. export class CircleOfConfusionPostProcess extends PostProcess {
  60039. /**
  60040. * 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.
  60041. */
  60042. lensSize: number;
  60043. /**
  60044. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60045. */
  60046. fStop: number;
  60047. /**
  60048. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60049. */
  60050. focusDistance: number;
  60051. /**
  60052. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60053. */
  60054. focalLength: number;
  60055. private _depthTexture;
  60056. /**
  60057. * Creates a new instance CircleOfConfusionPostProcess
  60058. * @param name The name of the effect.
  60059. * @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.
  60060. * @param options The required width/height ratio to downsize to before computing the render pass.
  60061. * @param camera The camera to apply the render pass to.
  60062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60063. * @param engine The engine which the post process will be applied. (default: current engine)
  60064. * @param reusable If the post process can be reused on the same frame. (default: false)
  60065. * @param textureType Type of textures used when performing the post process. (default: 0)
  60066. * @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)
  60067. */
  60068. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60069. /**
  60070. * 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.
  60071. */
  60072. depthTexture: RenderTargetTexture;
  60073. }
  60074. }
  60075. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60076. /** @hidden */
  60077. export var colorCorrectionPixelShader: {
  60078. name: string;
  60079. shader: string;
  60080. };
  60081. }
  60082. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60084. import { Engine } from "babylonjs/Engines/engine";
  60085. import { Camera } from "babylonjs/Cameras/camera";
  60086. import "babylonjs/Shaders/colorCorrection.fragment";
  60087. /**
  60088. *
  60089. * This post-process allows the modification of rendered colors by using
  60090. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60091. *
  60092. * The object needs to be provided an url to a texture containing the color
  60093. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60094. * Use an image editing software to tweak the LUT to match your needs.
  60095. *
  60096. * For an example of a color LUT, see here:
  60097. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60098. * For explanations on color grading, see here:
  60099. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60100. *
  60101. */
  60102. export class ColorCorrectionPostProcess extends PostProcess {
  60103. private _colorTableTexture;
  60104. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60105. }
  60106. }
  60107. declare module "babylonjs/Shaders/convolution.fragment" {
  60108. /** @hidden */
  60109. export var convolutionPixelShader: {
  60110. name: string;
  60111. shader: string;
  60112. };
  60113. }
  60114. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60116. import { Nullable } from "babylonjs/types";
  60117. import { Camera } from "babylonjs/Cameras/camera";
  60118. import { Engine } from "babylonjs/Engines/engine";
  60119. import "babylonjs/Shaders/convolution.fragment";
  60120. /**
  60121. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60122. * input texture to perform effects such as edge detection or sharpening
  60123. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60124. */
  60125. export class ConvolutionPostProcess extends PostProcess {
  60126. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60127. kernel: number[];
  60128. /**
  60129. * Creates a new instance ConvolutionPostProcess
  60130. * @param name The name of the effect.
  60131. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60132. * @param options The required width/height ratio to downsize to before computing the render pass.
  60133. * @param camera The camera to apply the render pass to.
  60134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60135. * @param engine The engine which the post process will be applied. (default: current engine)
  60136. * @param reusable If the post process can be reused on the same frame. (default: false)
  60137. * @param textureType Type of textures used when performing the post process. (default: 0)
  60138. */
  60139. constructor(name: string,
  60140. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60141. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60142. /**
  60143. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60144. */
  60145. static EdgeDetect0Kernel: number[];
  60146. /**
  60147. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60148. */
  60149. static EdgeDetect1Kernel: number[];
  60150. /**
  60151. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60152. */
  60153. static EdgeDetect2Kernel: number[];
  60154. /**
  60155. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60156. */
  60157. static SharpenKernel: number[];
  60158. /**
  60159. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60160. */
  60161. static EmbossKernel: number[];
  60162. /**
  60163. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60164. */
  60165. static GaussianKernel: number[];
  60166. }
  60167. }
  60168. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60169. import { Nullable } from "babylonjs/types";
  60170. import { Vector2 } from "babylonjs/Maths/math.vector";
  60171. import { Camera } from "babylonjs/Cameras/camera";
  60172. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60173. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60174. import { Engine } from "babylonjs/Engines/engine";
  60175. import { Scene } from "babylonjs/scene";
  60176. /**
  60177. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60178. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60179. * based on samples that have a large difference in distance than the center pixel.
  60180. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60181. */
  60182. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60183. direction: Vector2;
  60184. /**
  60185. * Creates a new instance CircleOfConfusionPostProcess
  60186. * @param name The name of the effect.
  60187. * @param scene The scene the effect belongs to.
  60188. * @param direction The direction the blur should be applied.
  60189. * @param kernel The size of the kernel used to blur.
  60190. * @param options The required width/height ratio to downsize to before computing the render pass.
  60191. * @param camera The camera to apply the render pass to.
  60192. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60193. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60195. * @param engine The engine which the post process will be applied. (default: current engine)
  60196. * @param reusable If the post process can be reused on the same frame. (default: false)
  60197. * @param textureType Type of textures used when performing the post process. (default: 0)
  60198. * @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)
  60199. */
  60200. 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);
  60201. }
  60202. }
  60203. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60204. /** @hidden */
  60205. export var depthOfFieldMergePixelShader: {
  60206. name: string;
  60207. shader: string;
  60208. };
  60209. }
  60210. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60211. import { Nullable } from "babylonjs/types";
  60212. import { Camera } from "babylonjs/Cameras/camera";
  60213. import { Effect } from "babylonjs/Materials/effect";
  60214. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60215. import { Engine } from "babylonjs/Engines/engine";
  60216. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60217. /**
  60218. * Options to be set when merging outputs from the default pipeline.
  60219. */
  60220. export class DepthOfFieldMergePostProcessOptions {
  60221. /**
  60222. * The original image to merge on top of
  60223. */
  60224. originalFromInput: PostProcess;
  60225. /**
  60226. * Parameters to perform the merge of the depth of field effect
  60227. */
  60228. depthOfField?: {
  60229. circleOfConfusion: PostProcess;
  60230. blurSteps: Array<PostProcess>;
  60231. };
  60232. /**
  60233. * Parameters to perform the merge of bloom effect
  60234. */
  60235. bloom?: {
  60236. blurred: PostProcess;
  60237. weight: number;
  60238. };
  60239. }
  60240. /**
  60241. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60242. */
  60243. export class DepthOfFieldMergePostProcess extends PostProcess {
  60244. private blurSteps;
  60245. /**
  60246. * Creates a new instance of DepthOfFieldMergePostProcess
  60247. * @param name The name of the effect.
  60248. * @param originalFromInput Post process which's input will be used for the merge.
  60249. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60250. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60251. * @param options The required width/height ratio to downsize to before computing the render pass.
  60252. * @param camera The camera to apply the render pass to.
  60253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60254. * @param engine The engine which the post process will be applied. (default: current engine)
  60255. * @param reusable If the post process can be reused on the same frame. (default: false)
  60256. * @param textureType Type of textures used when performing the post process. (default: 0)
  60257. * @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)
  60258. */
  60259. 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);
  60260. /**
  60261. * Updates the effect with the current post process compile time values and recompiles the shader.
  60262. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60263. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60264. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60265. * @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
  60266. * @param onCompiled Called when the shader has been compiled.
  60267. * @param onError Called if there is an error when compiling a shader.
  60268. */
  60269. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60270. }
  60271. }
  60272. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60273. import { Nullable } from "babylonjs/types";
  60274. import { Camera } from "babylonjs/Cameras/camera";
  60275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60276. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60277. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60278. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60279. import { Scene } from "babylonjs/scene";
  60280. /**
  60281. * Specifies the level of max blur that should be applied when using the depth of field effect
  60282. */
  60283. export enum DepthOfFieldEffectBlurLevel {
  60284. /**
  60285. * Subtle blur
  60286. */
  60287. Low = 0,
  60288. /**
  60289. * Medium blur
  60290. */
  60291. Medium = 1,
  60292. /**
  60293. * Large blur
  60294. */
  60295. High = 2
  60296. }
  60297. /**
  60298. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60299. */
  60300. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60301. private _circleOfConfusion;
  60302. /**
  60303. * @hidden Internal, blurs from high to low
  60304. */
  60305. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60306. private _depthOfFieldBlurY;
  60307. private _dofMerge;
  60308. /**
  60309. * @hidden Internal post processes in depth of field effect
  60310. */
  60311. _effects: Array<PostProcess>;
  60312. /**
  60313. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60314. */
  60315. focalLength: number;
  60316. /**
  60317. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60318. */
  60319. fStop: number;
  60320. /**
  60321. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60322. */
  60323. focusDistance: number;
  60324. /**
  60325. * 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.
  60326. */
  60327. lensSize: number;
  60328. /**
  60329. * Creates a new instance DepthOfFieldEffect
  60330. * @param scene The scene the effect belongs to.
  60331. * @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.
  60332. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60333. * @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)
  60334. */
  60335. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60336. /**
  60337. * Get the current class name of the current effet
  60338. * @returns "DepthOfFieldEffect"
  60339. */
  60340. getClassName(): string;
  60341. /**
  60342. * 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.
  60343. */
  60344. depthTexture: RenderTargetTexture;
  60345. /**
  60346. * Disposes each of the internal effects for a given camera.
  60347. * @param camera The camera to dispose the effect on.
  60348. */
  60349. disposeEffects(camera: Camera): void;
  60350. /**
  60351. * @hidden Internal
  60352. */
  60353. _updateEffects(): void;
  60354. /**
  60355. * Internal
  60356. * @returns if all the contained post processes are ready.
  60357. * @hidden
  60358. */
  60359. _isReady(): boolean;
  60360. }
  60361. }
  60362. declare module "babylonjs/Shaders/displayPass.fragment" {
  60363. /** @hidden */
  60364. export var displayPassPixelShader: {
  60365. name: string;
  60366. shader: string;
  60367. };
  60368. }
  60369. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60370. import { Nullable } from "babylonjs/types";
  60371. import { Camera } from "babylonjs/Cameras/camera";
  60372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60373. import { Engine } from "babylonjs/Engines/engine";
  60374. import "babylonjs/Shaders/displayPass.fragment";
  60375. /**
  60376. * DisplayPassPostProcess which produces an output the same as it's input
  60377. */
  60378. export class DisplayPassPostProcess extends PostProcess {
  60379. /**
  60380. * Creates the DisplayPassPostProcess
  60381. * @param name The name of the effect.
  60382. * @param options The required width/height ratio to downsize to before computing the render pass.
  60383. * @param camera The camera to apply the render pass to.
  60384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60385. * @param engine The engine which the post process will be applied. (default: current engine)
  60386. * @param reusable If the post process can be reused on the same frame. (default: false)
  60387. */
  60388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60389. }
  60390. }
  60391. declare module "babylonjs/Shaders/filter.fragment" {
  60392. /** @hidden */
  60393. export var filterPixelShader: {
  60394. name: string;
  60395. shader: string;
  60396. };
  60397. }
  60398. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60399. import { Nullable } from "babylonjs/types";
  60400. import { Matrix } from "babylonjs/Maths/math.vector";
  60401. import { Camera } from "babylonjs/Cameras/camera";
  60402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60403. import { Engine } from "babylonjs/Engines/engine";
  60404. import "babylonjs/Shaders/filter.fragment";
  60405. /**
  60406. * Applies a kernel filter to the image
  60407. */
  60408. export class FilterPostProcess extends PostProcess {
  60409. /** The matrix to be applied to the image */
  60410. kernelMatrix: Matrix;
  60411. /**
  60412. *
  60413. * @param name The name of the effect.
  60414. * @param kernelMatrix The matrix to be applied to the image
  60415. * @param options The required width/height ratio to downsize to before computing the render pass.
  60416. * @param camera The camera to apply the render pass to.
  60417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60418. * @param engine The engine which the post process will be applied. (default: current engine)
  60419. * @param reusable If the post process can be reused on the same frame. (default: false)
  60420. */
  60421. constructor(name: string,
  60422. /** The matrix to be applied to the image */
  60423. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60424. }
  60425. }
  60426. declare module "babylonjs/Shaders/fxaa.fragment" {
  60427. /** @hidden */
  60428. export var fxaaPixelShader: {
  60429. name: string;
  60430. shader: string;
  60431. };
  60432. }
  60433. declare module "babylonjs/Shaders/fxaa.vertex" {
  60434. /** @hidden */
  60435. export var fxaaVertexShader: {
  60436. name: string;
  60437. shader: string;
  60438. };
  60439. }
  60440. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60441. import { Nullable } from "babylonjs/types";
  60442. import { Camera } from "babylonjs/Cameras/camera";
  60443. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60444. import { Engine } from "babylonjs/Engines/engine";
  60445. import "babylonjs/Shaders/fxaa.fragment";
  60446. import "babylonjs/Shaders/fxaa.vertex";
  60447. /**
  60448. * Fxaa post process
  60449. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60450. */
  60451. export class FxaaPostProcess extends PostProcess {
  60452. /** @hidden */
  60453. texelWidth: number;
  60454. /** @hidden */
  60455. texelHeight: number;
  60456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60457. private _getDefines;
  60458. }
  60459. }
  60460. declare module "babylonjs/Shaders/grain.fragment" {
  60461. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60462. /** @hidden */
  60463. export var grainPixelShader: {
  60464. name: string;
  60465. shader: string;
  60466. };
  60467. }
  60468. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60469. import { Nullable } from "babylonjs/types";
  60470. import { Camera } from "babylonjs/Cameras/camera";
  60471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60472. import { Engine } from "babylonjs/Engines/engine";
  60473. import "babylonjs/Shaders/grain.fragment";
  60474. /**
  60475. * The GrainPostProcess adds noise to the image at mid luminance levels
  60476. */
  60477. export class GrainPostProcess extends PostProcess {
  60478. /**
  60479. * The intensity of the grain added (default: 30)
  60480. */
  60481. intensity: number;
  60482. /**
  60483. * If the grain should be randomized on every frame
  60484. */
  60485. animated: boolean;
  60486. /**
  60487. * Creates a new instance of @see GrainPostProcess
  60488. * @param name The name of the effect.
  60489. * @param options The required width/height ratio to downsize to before computing the render pass.
  60490. * @param camera The camera to apply the render pass to.
  60491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60492. * @param engine The engine which the post process will be applied. (default: current engine)
  60493. * @param reusable If the post process can be reused on the same frame. (default: false)
  60494. * @param textureType Type of textures used when performing the post process. (default: 0)
  60495. * @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)
  60496. */
  60497. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60498. }
  60499. }
  60500. declare module "babylonjs/Shaders/highlights.fragment" {
  60501. /** @hidden */
  60502. export var highlightsPixelShader: {
  60503. name: string;
  60504. shader: string;
  60505. };
  60506. }
  60507. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Camera } from "babylonjs/Cameras/camera";
  60510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60511. import { Engine } from "babylonjs/Engines/engine";
  60512. import "babylonjs/Shaders/highlights.fragment";
  60513. /**
  60514. * Extracts highlights from the image
  60515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60516. */
  60517. export class HighlightsPostProcess extends PostProcess {
  60518. /**
  60519. * Extracts highlights from the image
  60520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60521. * @param name The name of the effect.
  60522. * @param options The required width/height ratio to downsize to before computing the render pass.
  60523. * @param camera The camera to apply the render pass to.
  60524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60525. * @param engine The engine which the post process will be applied. (default: current engine)
  60526. * @param reusable If the post process can be reused on the same frame. (default: false)
  60527. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60528. */
  60529. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60530. }
  60531. }
  60532. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60533. /** @hidden */
  60534. export var mrtFragmentDeclaration: {
  60535. name: string;
  60536. shader: string;
  60537. };
  60538. }
  60539. declare module "babylonjs/Shaders/geometry.fragment" {
  60540. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60541. /** @hidden */
  60542. export var geometryPixelShader: {
  60543. name: string;
  60544. shader: string;
  60545. };
  60546. }
  60547. declare module "babylonjs/Shaders/geometry.vertex" {
  60548. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60551. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60555. /** @hidden */
  60556. export var geometryVertexShader: {
  60557. name: string;
  60558. shader: string;
  60559. };
  60560. }
  60561. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60562. import { Matrix } from "babylonjs/Maths/math.vector";
  60563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60564. import { Mesh } from "babylonjs/Meshes/mesh";
  60565. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60566. import { Effect } from "babylonjs/Materials/effect";
  60567. import { Scene } from "babylonjs/scene";
  60568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60569. import "babylonjs/Shaders/geometry.fragment";
  60570. import "babylonjs/Shaders/geometry.vertex";
  60571. /** @hidden */
  60572. interface ISavedTransformationMatrix {
  60573. world: Matrix;
  60574. viewProjection: Matrix;
  60575. }
  60576. /**
  60577. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60578. */
  60579. export class GeometryBufferRenderer {
  60580. /**
  60581. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60582. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60583. */
  60584. static readonly POSITION_TEXTURE_TYPE: number;
  60585. /**
  60586. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60587. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60588. */
  60589. static readonly VELOCITY_TEXTURE_TYPE: number;
  60590. /**
  60591. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60592. * in order to compute objects velocities when enableVelocity is set to "true"
  60593. * @hidden
  60594. */
  60595. _previousTransformationMatrices: {
  60596. [index: number]: ISavedTransformationMatrix;
  60597. };
  60598. /**
  60599. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60600. * in order to compute objects velocities when enableVelocity is set to "true"
  60601. * @hidden
  60602. */
  60603. _previousBonesTransformationMatrices: {
  60604. [index: number]: Float32Array;
  60605. };
  60606. /**
  60607. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60608. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60609. */
  60610. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60611. private _scene;
  60612. private _multiRenderTarget;
  60613. private _ratio;
  60614. private _enablePosition;
  60615. private _enableVelocity;
  60616. private _positionIndex;
  60617. private _velocityIndex;
  60618. protected _effect: Effect;
  60619. protected _cachedDefines: string;
  60620. /**
  60621. * Set the render list (meshes to be rendered) used in the G buffer.
  60622. */
  60623. renderList: Mesh[];
  60624. /**
  60625. * Gets wether or not G buffer are supported by the running hardware.
  60626. * This requires draw buffer supports
  60627. */
  60628. readonly isSupported: boolean;
  60629. /**
  60630. * Returns the index of the given texture type in the G-Buffer textures array
  60631. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60632. * @returns the index of the given texture type in the G-Buffer textures array
  60633. */
  60634. getTextureIndex(textureType: number): number;
  60635. /**
  60636. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60637. */
  60638. /**
  60639. * Sets whether or not objects positions are enabled for the G buffer.
  60640. */
  60641. enablePosition: boolean;
  60642. /**
  60643. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60644. */
  60645. /**
  60646. * Sets wether or not objects velocities are enabled for the G buffer.
  60647. */
  60648. enableVelocity: boolean;
  60649. /**
  60650. * Gets the scene associated with the buffer.
  60651. */
  60652. readonly scene: Scene;
  60653. /**
  60654. * Gets the ratio used by the buffer during its creation.
  60655. * How big is the buffer related to the main canvas.
  60656. */
  60657. readonly ratio: number;
  60658. /** @hidden */
  60659. static _SceneComponentInitialization: (scene: Scene) => void;
  60660. /**
  60661. * Creates a new G Buffer for the scene
  60662. * @param scene The scene the buffer belongs to
  60663. * @param ratio How big is the buffer related to the main canvas.
  60664. */
  60665. constructor(scene: Scene, ratio?: number);
  60666. /**
  60667. * Checks wether everything is ready to render a submesh to the G buffer.
  60668. * @param subMesh the submesh to check readiness for
  60669. * @param useInstances is the mesh drawn using instance or not
  60670. * @returns true if ready otherwise false
  60671. */
  60672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60673. /**
  60674. * Gets the current underlying G Buffer.
  60675. * @returns the buffer
  60676. */
  60677. getGBuffer(): MultiRenderTarget;
  60678. /**
  60679. * Gets the number of samples used to render the buffer (anti aliasing).
  60680. */
  60681. /**
  60682. * Sets the number of samples used to render the buffer (anti aliasing).
  60683. */
  60684. samples: number;
  60685. /**
  60686. * Disposes the renderer and frees up associated resources.
  60687. */
  60688. dispose(): void;
  60689. protected _createRenderTargets(): void;
  60690. private _copyBonesTransformationMatrices;
  60691. }
  60692. }
  60693. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60694. import { Nullable } from "babylonjs/types";
  60695. import { Scene } from "babylonjs/scene";
  60696. import { ISceneComponent } from "babylonjs/sceneComponent";
  60697. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60698. module "babylonjs/scene" {
  60699. interface Scene {
  60700. /** @hidden (Backing field) */
  60701. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60702. /**
  60703. * Gets or Sets the current geometry buffer associated to the scene.
  60704. */
  60705. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60706. /**
  60707. * Enables a GeometryBufferRender and associates it with the scene
  60708. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60709. * @returns the GeometryBufferRenderer
  60710. */
  60711. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60712. /**
  60713. * Disables the GeometryBufferRender associated with the scene
  60714. */
  60715. disableGeometryBufferRenderer(): void;
  60716. }
  60717. }
  60718. /**
  60719. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60720. * in several rendering techniques.
  60721. */
  60722. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60723. /**
  60724. * The component name helpful to identify the component in the list of scene components.
  60725. */
  60726. readonly name: string;
  60727. /**
  60728. * The scene the component belongs to.
  60729. */
  60730. scene: Scene;
  60731. /**
  60732. * Creates a new instance of the component for the given scene
  60733. * @param scene Defines the scene to register the component in
  60734. */
  60735. constructor(scene: Scene);
  60736. /**
  60737. * Registers the component in a given scene
  60738. */
  60739. register(): void;
  60740. /**
  60741. * Rebuilds the elements related to this component in case of
  60742. * context lost for instance.
  60743. */
  60744. rebuild(): void;
  60745. /**
  60746. * Disposes the component and the associated ressources
  60747. */
  60748. dispose(): void;
  60749. private _gatherRenderTargets;
  60750. }
  60751. }
  60752. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60753. /** @hidden */
  60754. export var motionBlurPixelShader: {
  60755. name: string;
  60756. shader: string;
  60757. };
  60758. }
  60759. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60760. import { Nullable } from "babylonjs/types";
  60761. import { Camera } from "babylonjs/Cameras/camera";
  60762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60763. import { Scene } from "babylonjs/scene";
  60764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60765. import "babylonjs/Animations/animatable";
  60766. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60767. import "babylonjs/Shaders/motionBlur.fragment";
  60768. import { Engine } from "babylonjs/Engines/engine";
  60769. /**
  60770. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60771. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60772. * As an example, all you have to do is to create the post-process:
  60773. * var mb = new BABYLON.MotionBlurPostProcess(
  60774. * 'mb', // The name of the effect.
  60775. * scene, // The scene containing the objects to blur according to their velocity.
  60776. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60777. * camera // The camera to apply the render pass to.
  60778. * );
  60779. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60780. */
  60781. export class MotionBlurPostProcess extends PostProcess {
  60782. /**
  60783. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60784. */
  60785. motionStrength: number;
  60786. /**
  60787. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60788. */
  60789. /**
  60790. * Sets the number of iterations to be used for motion blur quality
  60791. */
  60792. motionBlurSamples: number;
  60793. private _motionBlurSamples;
  60794. private _geometryBufferRenderer;
  60795. /**
  60796. * Creates a new instance MotionBlurPostProcess
  60797. * @param name The name of the effect.
  60798. * @param scene The scene containing the objects to blur according to their velocity.
  60799. * @param options The required width/height ratio to downsize to before computing the render pass.
  60800. * @param camera The camera to apply the render pass to.
  60801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60802. * @param engine The engine which the post process will be applied. (default: current engine)
  60803. * @param reusable If the post process can be reused on the same frame. (default: false)
  60804. * @param textureType Type of textures used when performing the post process. (default: 0)
  60805. * @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)
  60806. */
  60807. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60808. /**
  60809. * Excludes the given skinned mesh from computing bones velocities.
  60810. * 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.
  60811. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60812. */
  60813. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60814. /**
  60815. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60816. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60817. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60818. */
  60819. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60820. /**
  60821. * Disposes the post process.
  60822. * @param camera The camera to dispose the post process on.
  60823. */
  60824. dispose(camera?: Camera): void;
  60825. }
  60826. }
  60827. declare module "babylonjs/Shaders/refraction.fragment" {
  60828. /** @hidden */
  60829. export var refractionPixelShader: {
  60830. name: string;
  60831. shader: string;
  60832. };
  60833. }
  60834. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60835. import { Color3 } from "babylonjs/Maths/math.color";
  60836. import { Camera } from "babylonjs/Cameras/camera";
  60837. import { Texture } from "babylonjs/Materials/Textures/texture";
  60838. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60839. import { Engine } from "babylonjs/Engines/engine";
  60840. import "babylonjs/Shaders/refraction.fragment";
  60841. /**
  60842. * Post process which applies a refractin texture
  60843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60844. */
  60845. export class RefractionPostProcess extends PostProcess {
  60846. /** the base color of the refraction (used to taint the rendering) */
  60847. color: Color3;
  60848. /** simulated refraction depth */
  60849. depth: number;
  60850. /** the coefficient of the base color (0 to remove base color tainting) */
  60851. colorLevel: number;
  60852. private _refTexture;
  60853. private _ownRefractionTexture;
  60854. /**
  60855. * Gets or sets the refraction texture
  60856. * Please note that you are responsible for disposing the texture if you set it manually
  60857. */
  60858. refractionTexture: Texture;
  60859. /**
  60860. * Initializes the RefractionPostProcess
  60861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60862. * @param name The name of the effect.
  60863. * @param refractionTextureUrl Url of the refraction texture to use
  60864. * @param color the base color of the refraction (used to taint the rendering)
  60865. * @param depth simulated refraction depth
  60866. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60867. * @param camera The camera to apply the render pass to.
  60868. * @param options The required width/height ratio to downsize to before computing the render pass.
  60869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60870. * @param engine The engine which the post process will be applied. (default: current engine)
  60871. * @param reusable If the post process can be reused on the same frame. (default: false)
  60872. */
  60873. constructor(name: string, refractionTextureUrl: string,
  60874. /** the base color of the refraction (used to taint the rendering) */
  60875. color: Color3,
  60876. /** simulated refraction depth */
  60877. depth: number,
  60878. /** the coefficient of the base color (0 to remove base color tainting) */
  60879. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60880. /**
  60881. * Disposes of the post process
  60882. * @param camera Camera to dispose post process on
  60883. */
  60884. dispose(camera: Camera): void;
  60885. }
  60886. }
  60887. declare module "babylonjs/Shaders/sharpen.fragment" {
  60888. /** @hidden */
  60889. export var sharpenPixelShader: {
  60890. name: string;
  60891. shader: string;
  60892. };
  60893. }
  60894. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60895. import { Nullable } from "babylonjs/types";
  60896. import { Camera } from "babylonjs/Cameras/camera";
  60897. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60898. import "babylonjs/Shaders/sharpen.fragment";
  60899. import { Engine } from "babylonjs/Engines/engine";
  60900. /**
  60901. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60902. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60903. */
  60904. export class SharpenPostProcess extends PostProcess {
  60905. /**
  60906. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60907. */
  60908. colorAmount: number;
  60909. /**
  60910. * How much sharpness should be applied (default: 0.3)
  60911. */
  60912. edgeAmount: number;
  60913. /**
  60914. * Creates a new instance ConvolutionPostProcess
  60915. * @param name The name of the effect.
  60916. * @param options The required width/height ratio to downsize to before computing the render pass.
  60917. * @param camera The camera to apply the render pass to.
  60918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60919. * @param engine The engine which the post process will be applied. (default: current engine)
  60920. * @param reusable If the post process can be reused on the same frame. (default: false)
  60921. * @param textureType Type of textures used when performing the post process. (default: 0)
  60922. * @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)
  60923. */
  60924. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60925. }
  60926. }
  60927. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60928. import { Nullable } from "babylonjs/types";
  60929. import { Camera } from "babylonjs/Cameras/camera";
  60930. import { Engine } from "babylonjs/Engines/engine";
  60931. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60932. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60933. /**
  60934. * PostProcessRenderPipeline
  60935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60936. */
  60937. export class PostProcessRenderPipeline {
  60938. private engine;
  60939. private _renderEffects;
  60940. private _renderEffectsForIsolatedPass;
  60941. /**
  60942. * List of inspectable custom properties (used by the Inspector)
  60943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60944. */
  60945. inspectableCustomProperties: IInspectable[];
  60946. /**
  60947. * @hidden
  60948. */
  60949. protected _cameras: Camera[];
  60950. /** @hidden */
  60951. _name: string;
  60952. /**
  60953. * Gets pipeline name
  60954. */
  60955. readonly name: string;
  60956. /**
  60957. * Initializes a PostProcessRenderPipeline
  60958. * @param engine engine to add the pipeline to
  60959. * @param name name of the pipeline
  60960. */
  60961. constructor(engine: Engine, name: string);
  60962. /**
  60963. * Gets the class name
  60964. * @returns "PostProcessRenderPipeline"
  60965. */
  60966. getClassName(): string;
  60967. /**
  60968. * If all the render effects in the pipeline are supported
  60969. */
  60970. readonly isSupported: boolean;
  60971. /**
  60972. * Adds an effect to the pipeline
  60973. * @param renderEffect the effect to add
  60974. */
  60975. addEffect(renderEffect: PostProcessRenderEffect): void;
  60976. /** @hidden */
  60977. _rebuild(): void;
  60978. /** @hidden */
  60979. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60980. /** @hidden */
  60981. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60982. /** @hidden */
  60983. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60984. /** @hidden */
  60985. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60986. /** @hidden */
  60987. _attachCameras(cameras: Camera, unique: boolean): void;
  60988. /** @hidden */
  60989. _attachCameras(cameras: Camera[], unique: boolean): void;
  60990. /** @hidden */
  60991. _detachCameras(cameras: Camera): void;
  60992. /** @hidden */
  60993. _detachCameras(cameras: Nullable<Camera[]>): void;
  60994. /** @hidden */
  60995. _update(): void;
  60996. /** @hidden */
  60997. _reset(): void;
  60998. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60999. /**
  61000. * Disposes of the pipeline
  61001. */
  61002. dispose(): void;
  61003. }
  61004. }
  61005. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61006. import { Camera } from "babylonjs/Cameras/camera";
  61007. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61008. /**
  61009. * PostProcessRenderPipelineManager class
  61010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61011. */
  61012. export class PostProcessRenderPipelineManager {
  61013. private _renderPipelines;
  61014. /**
  61015. * Initializes a PostProcessRenderPipelineManager
  61016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61017. */
  61018. constructor();
  61019. /**
  61020. * Gets the list of supported render pipelines
  61021. */
  61022. readonly supportedPipelines: PostProcessRenderPipeline[];
  61023. /**
  61024. * Adds a pipeline to the manager
  61025. * @param renderPipeline The pipeline to add
  61026. */
  61027. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61028. /**
  61029. * Attaches a camera to the pipeline
  61030. * @param renderPipelineName The name of the pipeline to attach to
  61031. * @param cameras the camera to attach
  61032. * @param unique if the camera can be attached multiple times to the pipeline
  61033. */
  61034. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61035. /**
  61036. * Detaches a camera from the pipeline
  61037. * @param renderPipelineName The name of the pipeline to detach from
  61038. * @param cameras the camera to detach
  61039. */
  61040. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61041. /**
  61042. * Enables an effect by name on a pipeline
  61043. * @param renderPipelineName the name of the pipeline to enable the effect in
  61044. * @param renderEffectName the name of the effect to enable
  61045. * @param cameras the cameras that the effect should be enabled on
  61046. */
  61047. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61048. /**
  61049. * Disables an effect by name on a pipeline
  61050. * @param renderPipelineName the name of the pipeline to disable the effect in
  61051. * @param renderEffectName the name of the effect to disable
  61052. * @param cameras the cameras that the effect should be disabled on
  61053. */
  61054. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61055. /**
  61056. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61057. */
  61058. update(): void;
  61059. /** @hidden */
  61060. _rebuild(): void;
  61061. /**
  61062. * Disposes of the manager and pipelines
  61063. */
  61064. dispose(): void;
  61065. }
  61066. }
  61067. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61068. import { ISceneComponent } from "babylonjs/sceneComponent";
  61069. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61070. import { Scene } from "babylonjs/scene";
  61071. module "babylonjs/scene" {
  61072. interface Scene {
  61073. /** @hidden (Backing field) */
  61074. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61075. /**
  61076. * Gets the postprocess render pipeline manager
  61077. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61078. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61079. */
  61080. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61081. }
  61082. }
  61083. /**
  61084. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61085. */
  61086. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61087. /**
  61088. * The component name helpfull to identify the component in the list of scene components.
  61089. */
  61090. readonly name: string;
  61091. /**
  61092. * The scene the component belongs to.
  61093. */
  61094. scene: Scene;
  61095. /**
  61096. * Creates a new instance of the component for the given scene
  61097. * @param scene Defines the scene to register the component in
  61098. */
  61099. constructor(scene: Scene);
  61100. /**
  61101. * Registers the component in a given scene
  61102. */
  61103. register(): void;
  61104. /**
  61105. * Rebuilds the elements related to this component in case of
  61106. * context lost for instance.
  61107. */
  61108. rebuild(): void;
  61109. /**
  61110. * Disposes the component and the associated ressources
  61111. */
  61112. dispose(): void;
  61113. private _gatherRenderTargets;
  61114. }
  61115. }
  61116. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61117. import { Nullable } from "babylonjs/types";
  61118. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61119. import { Camera } from "babylonjs/Cameras/camera";
  61120. import { IDisposable } from "babylonjs/scene";
  61121. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61122. import { Scene } from "babylonjs/scene";
  61123. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61124. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61125. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61126. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61127. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61128. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61129. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61130. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61131. import { Animation } from "babylonjs/Animations/animation";
  61132. /**
  61133. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61134. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61135. */
  61136. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61137. private _scene;
  61138. private _camerasToBeAttached;
  61139. /**
  61140. * ID of the sharpen post process,
  61141. */
  61142. private readonly SharpenPostProcessId;
  61143. /**
  61144. * @ignore
  61145. * ID of the image processing post process;
  61146. */
  61147. readonly ImageProcessingPostProcessId: string;
  61148. /**
  61149. * @ignore
  61150. * ID of the Fast Approximate Anti-Aliasing post process;
  61151. */
  61152. readonly FxaaPostProcessId: string;
  61153. /**
  61154. * ID of the chromatic aberration post process,
  61155. */
  61156. private readonly ChromaticAberrationPostProcessId;
  61157. /**
  61158. * ID of the grain post process
  61159. */
  61160. private readonly GrainPostProcessId;
  61161. /**
  61162. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61163. */
  61164. sharpen: SharpenPostProcess;
  61165. private _sharpenEffect;
  61166. private bloom;
  61167. /**
  61168. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61169. */
  61170. depthOfField: DepthOfFieldEffect;
  61171. /**
  61172. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61173. */
  61174. fxaa: FxaaPostProcess;
  61175. /**
  61176. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61177. */
  61178. imageProcessing: ImageProcessingPostProcess;
  61179. /**
  61180. * Chromatic aberration post process which will shift rgb colors in the image
  61181. */
  61182. chromaticAberration: ChromaticAberrationPostProcess;
  61183. private _chromaticAberrationEffect;
  61184. /**
  61185. * Grain post process which add noise to the image
  61186. */
  61187. grain: GrainPostProcess;
  61188. private _grainEffect;
  61189. /**
  61190. * Glow post process which adds a glow to emissive areas of the image
  61191. */
  61192. private _glowLayer;
  61193. /**
  61194. * Animations which can be used to tweak settings over a period of time
  61195. */
  61196. animations: Animation[];
  61197. private _imageProcessingConfigurationObserver;
  61198. private _sharpenEnabled;
  61199. private _bloomEnabled;
  61200. private _depthOfFieldEnabled;
  61201. private _depthOfFieldBlurLevel;
  61202. private _fxaaEnabled;
  61203. private _imageProcessingEnabled;
  61204. private _defaultPipelineTextureType;
  61205. private _bloomScale;
  61206. private _chromaticAberrationEnabled;
  61207. private _grainEnabled;
  61208. private _buildAllowed;
  61209. /**
  61210. * Gets active scene
  61211. */
  61212. readonly scene: Scene;
  61213. /**
  61214. * Enable or disable the sharpen process from the pipeline
  61215. */
  61216. sharpenEnabled: boolean;
  61217. private _resizeObserver;
  61218. private _hardwareScaleLevel;
  61219. private _bloomKernel;
  61220. /**
  61221. * Specifies the size of the bloom blur kernel, relative to the final output size
  61222. */
  61223. bloomKernel: number;
  61224. /**
  61225. * Specifies the weight of the bloom in the final rendering
  61226. */
  61227. private _bloomWeight;
  61228. /**
  61229. * Specifies the luma threshold for the area that will be blurred by the bloom
  61230. */
  61231. private _bloomThreshold;
  61232. private _hdr;
  61233. /**
  61234. * The strength of the bloom.
  61235. */
  61236. bloomWeight: number;
  61237. /**
  61238. * The strength of the bloom.
  61239. */
  61240. bloomThreshold: number;
  61241. /**
  61242. * The scale of the bloom, lower value will provide better performance.
  61243. */
  61244. bloomScale: number;
  61245. /**
  61246. * Enable or disable the bloom from the pipeline
  61247. */
  61248. bloomEnabled: boolean;
  61249. private _rebuildBloom;
  61250. /**
  61251. * If the depth of field is enabled.
  61252. */
  61253. depthOfFieldEnabled: boolean;
  61254. /**
  61255. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61256. */
  61257. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61258. /**
  61259. * If the anti aliasing is enabled.
  61260. */
  61261. fxaaEnabled: boolean;
  61262. private _samples;
  61263. /**
  61264. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61265. */
  61266. samples: number;
  61267. /**
  61268. * If image processing is enabled.
  61269. */
  61270. imageProcessingEnabled: boolean;
  61271. /**
  61272. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61273. */
  61274. glowLayerEnabled: boolean;
  61275. /**
  61276. * Gets the glow layer (or null if not defined)
  61277. */
  61278. readonly glowLayer: Nullable<GlowLayer>;
  61279. /**
  61280. * Enable or disable the chromaticAberration process from the pipeline
  61281. */
  61282. chromaticAberrationEnabled: boolean;
  61283. /**
  61284. * Enable or disable the grain process from the pipeline
  61285. */
  61286. grainEnabled: boolean;
  61287. /**
  61288. * @constructor
  61289. * @param name - The rendering pipeline name (default: "")
  61290. * @param hdr - If high dynamic range textures should be used (default: true)
  61291. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61292. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61293. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61294. */
  61295. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61296. /**
  61297. * Get the class name
  61298. * @returns "DefaultRenderingPipeline"
  61299. */
  61300. getClassName(): string;
  61301. /**
  61302. * Force the compilation of the entire pipeline.
  61303. */
  61304. prepare(): void;
  61305. private _hasCleared;
  61306. private _prevPostProcess;
  61307. private _prevPrevPostProcess;
  61308. private _setAutoClearAndTextureSharing;
  61309. private _depthOfFieldSceneObserver;
  61310. private _buildPipeline;
  61311. private _disposePostProcesses;
  61312. /**
  61313. * Adds a camera to the pipeline
  61314. * @param camera the camera to be added
  61315. */
  61316. addCamera(camera: Camera): void;
  61317. /**
  61318. * Removes a camera from the pipeline
  61319. * @param camera the camera to remove
  61320. */
  61321. removeCamera(camera: Camera): void;
  61322. /**
  61323. * Dispose of the pipeline and stop all post processes
  61324. */
  61325. dispose(): void;
  61326. /**
  61327. * Serialize the rendering pipeline (Used when exporting)
  61328. * @returns the serialized object
  61329. */
  61330. serialize(): any;
  61331. /**
  61332. * Parse the serialized pipeline
  61333. * @param source Source pipeline.
  61334. * @param scene The scene to load the pipeline to.
  61335. * @param rootUrl The URL of the serialized pipeline.
  61336. * @returns An instantiated pipeline from the serialized object.
  61337. */
  61338. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61339. }
  61340. }
  61341. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61342. /** @hidden */
  61343. export var lensHighlightsPixelShader: {
  61344. name: string;
  61345. shader: string;
  61346. };
  61347. }
  61348. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61349. /** @hidden */
  61350. export var depthOfFieldPixelShader: {
  61351. name: string;
  61352. shader: string;
  61353. };
  61354. }
  61355. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61356. import { Camera } from "babylonjs/Cameras/camera";
  61357. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61358. import { Scene } from "babylonjs/scene";
  61359. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61360. import "babylonjs/Shaders/chromaticAberration.fragment";
  61361. import "babylonjs/Shaders/lensHighlights.fragment";
  61362. import "babylonjs/Shaders/depthOfField.fragment";
  61363. /**
  61364. * BABYLON.JS Chromatic Aberration GLSL Shader
  61365. * Author: Olivier Guyot
  61366. * Separates very slightly R, G and B colors on the edges of the screen
  61367. * Inspired by Francois Tarlier & Martins Upitis
  61368. */
  61369. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61370. /**
  61371. * @ignore
  61372. * The chromatic aberration PostProcess id in the pipeline
  61373. */
  61374. LensChromaticAberrationEffect: string;
  61375. /**
  61376. * @ignore
  61377. * The highlights enhancing PostProcess id in the pipeline
  61378. */
  61379. HighlightsEnhancingEffect: string;
  61380. /**
  61381. * @ignore
  61382. * The depth-of-field PostProcess id in the pipeline
  61383. */
  61384. LensDepthOfFieldEffect: string;
  61385. private _scene;
  61386. private _depthTexture;
  61387. private _grainTexture;
  61388. private _chromaticAberrationPostProcess;
  61389. private _highlightsPostProcess;
  61390. private _depthOfFieldPostProcess;
  61391. private _edgeBlur;
  61392. private _grainAmount;
  61393. private _chromaticAberration;
  61394. private _distortion;
  61395. private _highlightsGain;
  61396. private _highlightsThreshold;
  61397. private _dofDistance;
  61398. private _dofAperture;
  61399. private _dofDarken;
  61400. private _dofPentagon;
  61401. private _blurNoise;
  61402. /**
  61403. * @constructor
  61404. *
  61405. * Effect parameters are as follow:
  61406. * {
  61407. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61408. * edge_blur: number; // from 0 to x (1 for realism)
  61409. * distortion: number; // from 0 to x (1 for realism)
  61410. * grain_amount: number; // from 0 to 1
  61411. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61412. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61413. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61414. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61415. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61416. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61417. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61418. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61419. * }
  61420. * Note: if an effect parameter is unset, effect is disabled
  61421. *
  61422. * @param name The rendering pipeline name
  61423. * @param parameters - An object containing all parameters (see above)
  61424. * @param scene The scene linked to this pipeline
  61425. * @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)
  61426. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61427. */
  61428. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61429. /**
  61430. * Get the class name
  61431. * @returns "LensRenderingPipeline"
  61432. */
  61433. getClassName(): string;
  61434. /**
  61435. * Gets associated scene
  61436. */
  61437. readonly scene: Scene;
  61438. /**
  61439. * Gets or sets the edge blur
  61440. */
  61441. edgeBlur: number;
  61442. /**
  61443. * Gets or sets the grain amount
  61444. */
  61445. grainAmount: number;
  61446. /**
  61447. * Gets or sets the chromatic aberration amount
  61448. */
  61449. chromaticAberration: number;
  61450. /**
  61451. * Gets or sets the depth of field aperture
  61452. */
  61453. dofAperture: number;
  61454. /**
  61455. * Gets or sets the edge distortion
  61456. */
  61457. edgeDistortion: number;
  61458. /**
  61459. * Gets or sets the depth of field distortion
  61460. */
  61461. dofDistortion: number;
  61462. /**
  61463. * Gets or sets the darken out of focus amount
  61464. */
  61465. darkenOutOfFocus: number;
  61466. /**
  61467. * Gets or sets a boolean indicating if blur noise is enabled
  61468. */
  61469. blurNoise: boolean;
  61470. /**
  61471. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61472. */
  61473. pentagonBokeh: boolean;
  61474. /**
  61475. * Gets or sets the highlight grain amount
  61476. */
  61477. highlightsGain: number;
  61478. /**
  61479. * Gets or sets the highlight threshold
  61480. */
  61481. highlightsThreshold: number;
  61482. /**
  61483. * Sets the amount of blur at the edges
  61484. * @param amount blur amount
  61485. */
  61486. setEdgeBlur(amount: number): void;
  61487. /**
  61488. * Sets edge blur to 0
  61489. */
  61490. disableEdgeBlur(): void;
  61491. /**
  61492. * Sets the amout of grain
  61493. * @param amount Amount of grain
  61494. */
  61495. setGrainAmount(amount: number): void;
  61496. /**
  61497. * Set grain amount to 0
  61498. */
  61499. disableGrain(): void;
  61500. /**
  61501. * Sets the chromatic aberration amount
  61502. * @param amount amount of chromatic aberration
  61503. */
  61504. setChromaticAberration(amount: number): void;
  61505. /**
  61506. * Sets chromatic aberration amount to 0
  61507. */
  61508. disableChromaticAberration(): void;
  61509. /**
  61510. * Sets the EdgeDistortion amount
  61511. * @param amount amount of EdgeDistortion
  61512. */
  61513. setEdgeDistortion(amount: number): void;
  61514. /**
  61515. * Sets edge distortion to 0
  61516. */
  61517. disableEdgeDistortion(): void;
  61518. /**
  61519. * Sets the FocusDistance amount
  61520. * @param amount amount of FocusDistance
  61521. */
  61522. setFocusDistance(amount: number): void;
  61523. /**
  61524. * Disables depth of field
  61525. */
  61526. disableDepthOfField(): void;
  61527. /**
  61528. * Sets the Aperture amount
  61529. * @param amount amount of Aperture
  61530. */
  61531. setAperture(amount: number): void;
  61532. /**
  61533. * Sets the DarkenOutOfFocus amount
  61534. * @param amount amount of DarkenOutOfFocus
  61535. */
  61536. setDarkenOutOfFocus(amount: number): void;
  61537. private _pentagonBokehIsEnabled;
  61538. /**
  61539. * Creates a pentagon bokeh effect
  61540. */
  61541. enablePentagonBokeh(): void;
  61542. /**
  61543. * Disables the pentagon bokeh effect
  61544. */
  61545. disablePentagonBokeh(): void;
  61546. /**
  61547. * Enables noise blur
  61548. */
  61549. enableNoiseBlur(): void;
  61550. /**
  61551. * Disables noise blur
  61552. */
  61553. disableNoiseBlur(): void;
  61554. /**
  61555. * Sets the HighlightsGain amount
  61556. * @param amount amount of HighlightsGain
  61557. */
  61558. setHighlightsGain(amount: number): void;
  61559. /**
  61560. * Sets the HighlightsThreshold amount
  61561. * @param amount amount of HighlightsThreshold
  61562. */
  61563. setHighlightsThreshold(amount: number): void;
  61564. /**
  61565. * Disables highlights
  61566. */
  61567. disableHighlights(): void;
  61568. /**
  61569. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61570. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61571. */
  61572. dispose(disableDepthRender?: boolean): void;
  61573. private _createChromaticAberrationPostProcess;
  61574. private _createHighlightsPostProcess;
  61575. private _createDepthOfFieldPostProcess;
  61576. private _createGrainTexture;
  61577. }
  61578. }
  61579. declare module "babylonjs/Shaders/ssao2.fragment" {
  61580. /** @hidden */
  61581. export var ssao2PixelShader: {
  61582. name: string;
  61583. shader: string;
  61584. };
  61585. }
  61586. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61587. /** @hidden */
  61588. export var ssaoCombinePixelShader: {
  61589. name: string;
  61590. shader: string;
  61591. };
  61592. }
  61593. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61594. import { Camera } from "babylonjs/Cameras/camera";
  61595. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61596. import { Scene } from "babylonjs/scene";
  61597. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61598. import "babylonjs/Shaders/ssao2.fragment";
  61599. import "babylonjs/Shaders/ssaoCombine.fragment";
  61600. /**
  61601. * Render pipeline to produce ssao effect
  61602. */
  61603. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61604. /**
  61605. * @ignore
  61606. * The PassPostProcess id in the pipeline that contains the original scene color
  61607. */
  61608. SSAOOriginalSceneColorEffect: string;
  61609. /**
  61610. * @ignore
  61611. * The SSAO PostProcess id in the pipeline
  61612. */
  61613. SSAORenderEffect: string;
  61614. /**
  61615. * @ignore
  61616. * The horizontal blur PostProcess id in the pipeline
  61617. */
  61618. SSAOBlurHRenderEffect: string;
  61619. /**
  61620. * @ignore
  61621. * The vertical blur PostProcess id in the pipeline
  61622. */
  61623. SSAOBlurVRenderEffect: string;
  61624. /**
  61625. * @ignore
  61626. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61627. */
  61628. SSAOCombineRenderEffect: string;
  61629. /**
  61630. * The output strength of the SSAO post-process. Default value is 1.0.
  61631. */
  61632. totalStrength: number;
  61633. /**
  61634. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61635. */
  61636. maxZ: number;
  61637. /**
  61638. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61639. */
  61640. minZAspect: number;
  61641. private _samples;
  61642. /**
  61643. * Number of samples used for the SSAO calculations. Default value is 8
  61644. */
  61645. samples: number;
  61646. private _textureSamples;
  61647. /**
  61648. * Number of samples to use for antialiasing
  61649. */
  61650. textureSamples: number;
  61651. /**
  61652. * Ratio object used for SSAO ratio and blur ratio
  61653. */
  61654. private _ratio;
  61655. /**
  61656. * Dynamically generated sphere sampler.
  61657. */
  61658. private _sampleSphere;
  61659. /**
  61660. * Blur filter offsets
  61661. */
  61662. private _samplerOffsets;
  61663. private _expensiveBlur;
  61664. /**
  61665. * If bilateral blur should be used
  61666. */
  61667. expensiveBlur: boolean;
  61668. /**
  61669. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61670. */
  61671. radius: number;
  61672. /**
  61673. * The base color of the SSAO post-process
  61674. * The final result is "base + ssao" between [0, 1]
  61675. */
  61676. base: number;
  61677. /**
  61678. * Support test.
  61679. */
  61680. static readonly IsSupported: boolean;
  61681. private _scene;
  61682. private _depthTexture;
  61683. private _normalTexture;
  61684. private _randomTexture;
  61685. private _originalColorPostProcess;
  61686. private _ssaoPostProcess;
  61687. private _blurHPostProcess;
  61688. private _blurVPostProcess;
  61689. private _ssaoCombinePostProcess;
  61690. private _firstUpdate;
  61691. /**
  61692. * Gets active scene
  61693. */
  61694. readonly scene: Scene;
  61695. /**
  61696. * @constructor
  61697. * @param name The rendering pipeline name
  61698. * @param scene The scene linked to this pipeline
  61699. * @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 }
  61700. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61701. */
  61702. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61703. /**
  61704. * Get the class name
  61705. * @returns "SSAO2RenderingPipeline"
  61706. */
  61707. getClassName(): string;
  61708. /**
  61709. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61710. */
  61711. dispose(disableGeometryBufferRenderer?: boolean): void;
  61712. private _createBlurPostProcess;
  61713. /** @hidden */
  61714. _rebuild(): void;
  61715. private _bits;
  61716. private _radicalInverse_VdC;
  61717. private _hammersley;
  61718. private _hemisphereSample_uniform;
  61719. private _generateHemisphere;
  61720. private _createSSAOPostProcess;
  61721. private _createSSAOCombinePostProcess;
  61722. private _createRandomTexture;
  61723. /**
  61724. * Serialize the rendering pipeline (Used when exporting)
  61725. * @returns the serialized object
  61726. */
  61727. serialize(): any;
  61728. /**
  61729. * Parse the serialized pipeline
  61730. * @param source Source pipeline.
  61731. * @param scene The scene to load the pipeline to.
  61732. * @param rootUrl The URL of the serialized pipeline.
  61733. * @returns An instantiated pipeline from the serialized object.
  61734. */
  61735. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61736. }
  61737. }
  61738. declare module "babylonjs/Shaders/ssao.fragment" {
  61739. /** @hidden */
  61740. export var ssaoPixelShader: {
  61741. name: string;
  61742. shader: string;
  61743. };
  61744. }
  61745. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61746. import { Camera } from "babylonjs/Cameras/camera";
  61747. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61748. import { Scene } from "babylonjs/scene";
  61749. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61750. import "babylonjs/Shaders/ssao.fragment";
  61751. import "babylonjs/Shaders/ssaoCombine.fragment";
  61752. /**
  61753. * Render pipeline to produce ssao effect
  61754. */
  61755. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61756. /**
  61757. * @ignore
  61758. * The PassPostProcess id in the pipeline that contains the original scene color
  61759. */
  61760. SSAOOriginalSceneColorEffect: string;
  61761. /**
  61762. * @ignore
  61763. * The SSAO PostProcess id in the pipeline
  61764. */
  61765. SSAORenderEffect: string;
  61766. /**
  61767. * @ignore
  61768. * The horizontal blur PostProcess id in the pipeline
  61769. */
  61770. SSAOBlurHRenderEffect: string;
  61771. /**
  61772. * @ignore
  61773. * The vertical blur PostProcess id in the pipeline
  61774. */
  61775. SSAOBlurVRenderEffect: string;
  61776. /**
  61777. * @ignore
  61778. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61779. */
  61780. SSAOCombineRenderEffect: string;
  61781. /**
  61782. * The output strength of the SSAO post-process. Default value is 1.0.
  61783. */
  61784. totalStrength: number;
  61785. /**
  61786. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61787. */
  61788. radius: number;
  61789. /**
  61790. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61791. * Must not be equal to fallOff and superior to fallOff.
  61792. * Default value is 0.0075
  61793. */
  61794. area: number;
  61795. /**
  61796. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61797. * Must not be equal to area and inferior to area.
  61798. * Default value is 0.000001
  61799. */
  61800. fallOff: number;
  61801. /**
  61802. * The base color of the SSAO post-process
  61803. * The final result is "base + ssao" between [0, 1]
  61804. */
  61805. base: number;
  61806. private _scene;
  61807. private _depthTexture;
  61808. private _randomTexture;
  61809. private _originalColorPostProcess;
  61810. private _ssaoPostProcess;
  61811. private _blurHPostProcess;
  61812. private _blurVPostProcess;
  61813. private _ssaoCombinePostProcess;
  61814. private _firstUpdate;
  61815. /**
  61816. * Gets active scene
  61817. */
  61818. readonly scene: Scene;
  61819. /**
  61820. * @constructor
  61821. * @param name - The rendering pipeline name
  61822. * @param scene - The scene linked to this pipeline
  61823. * @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 }
  61824. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61825. */
  61826. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61827. /**
  61828. * Get the class name
  61829. * @returns "SSAORenderingPipeline"
  61830. */
  61831. getClassName(): string;
  61832. /**
  61833. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61834. */
  61835. dispose(disableDepthRender?: boolean): void;
  61836. private _createBlurPostProcess;
  61837. /** @hidden */
  61838. _rebuild(): void;
  61839. private _createSSAOPostProcess;
  61840. private _createSSAOCombinePostProcess;
  61841. private _createRandomTexture;
  61842. }
  61843. }
  61844. declare module "babylonjs/Shaders/standard.fragment" {
  61845. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61846. /** @hidden */
  61847. export var standardPixelShader: {
  61848. name: string;
  61849. shader: string;
  61850. };
  61851. }
  61852. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61853. import { Nullable } from "babylonjs/types";
  61854. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61855. import { Camera } from "babylonjs/Cameras/camera";
  61856. import { Texture } from "babylonjs/Materials/Textures/texture";
  61857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61858. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61859. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61860. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61861. import { IDisposable } from "babylonjs/scene";
  61862. import { SpotLight } from "babylonjs/Lights/spotLight";
  61863. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61864. import { Scene } from "babylonjs/scene";
  61865. import { Animation } from "babylonjs/Animations/animation";
  61866. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61867. import "babylonjs/Shaders/standard.fragment";
  61868. /**
  61869. * Standard rendering pipeline
  61870. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61871. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61872. */
  61873. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61874. /**
  61875. * Public members
  61876. */
  61877. /**
  61878. * Post-process which contains the original scene color before the pipeline applies all the effects
  61879. */
  61880. originalPostProcess: Nullable<PostProcess>;
  61881. /**
  61882. * Post-process used to down scale an image x4
  61883. */
  61884. downSampleX4PostProcess: Nullable<PostProcess>;
  61885. /**
  61886. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61887. */
  61888. brightPassPostProcess: Nullable<PostProcess>;
  61889. /**
  61890. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61891. */
  61892. blurHPostProcesses: PostProcess[];
  61893. /**
  61894. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61895. */
  61896. blurVPostProcesses: PostProcess[];
  61897. /**
  61898. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61899. */
  61900. textureAdderPostProcess: Nullable<PostProcess>;
  61901. /**
  61902. * Post-process used to create volumetric lighting effect
  61903. */
  61904. volumetricLightPostProcess: Nullable<PostProcess>;
  61905. /**
  61906. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61907. */
  61908. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61909. /**
  61910. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61911. */
  61912. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61913. /**
  61914. * Post-process used to merge the volumetric light effect and the real scene color
  61915. */
  61916. volumetricLightMergePostProces: Nullable<PostProcess>;
  61917. /**
  61918. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61919. */
  61920. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61921. /**
  61922. * Base post-process used to calculate the average luminance of the final image for HDR
  61923. */
  61924. luminancePostProcess: Nullable<PostProcess>;
  61925. /**
  61926. * Post-processes used to create down sample post-processes in order to get
  61927. * the average luminance of the final image for HDR
  61928. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61929. */
  61930. luminanceDownSamplePostProcesses: PostProcess[];
  61931. /**
  61932. * Post-process used to create a HDR effect (light adaptation)
  61933. */
  61934. hdrPostProcess: Nullable<PostProcess>;
  61935. /**
  61936. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61937. */
  61938. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61939. /**
  61940. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61941. */
  61942. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61943. /**
  61944. * Post-process used to merge the final HDR post-process and the real scene color
  61945. */
  61946. hdrFinalPostProcess: Nullable<PostProcess>;
  61947. /**
  61948. * Post-process used to create a lens flare effect
  61949. */
  61950. lensFlarePostProcess: Nullable<PostProcess>;
  61951. /**
  61952. * Post-process that merges the result of the lens flare post-process and the real scene color
  61953. */
  61954. lensFlareComposePostProcess: Nullable<PostProcess>;
  61955. /**
  61956. * Post-process used to create a motion blur effect
  61957. */
  61958. motionBlurPostProcess: Nullable<PostProcess>;
  61959. /**
  61960. * Post-process used to create a depth of field effect
  61961. */
  61962. depthOfFieldPostProcess: Nullable<PostProcess>;
  61963. /**
  61964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61965. */
  61966. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61967. /**
  61968. * Represents the brightness threshold in order to configure the illuminated surfaces
  61969. */
  61970. brightThreshold: number;
  61971. /**
  61972. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61973. */
  61974. blurWidth: number;
  61975. /**
  61976. * Sets if the blur for highlighted surfaces must be only horizontal
  61977. */
  61978. horizontalBlur: boolean;
  61979. /**
  61980. * Gets the overall exposure used by the pipeline
  61981. */
  61982. /**
  61983. * Sets the overall exposure used by the pipeline
  61984. */
  61985. exposure: number;
  61986. /**
  61987. * Texture used typically to simulate "dirty" on camera lens
  61988. */
  61989. lensTexture: Nullable<Texture>;
  61990. /**
  61991. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61992. */
  61993. volumetricLightCoefficient: number;
  61994. /**
  61995. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61996. */
  61997. volumetricLightPower: number;
  61998. /**
  61999. * Used the set the blur intensity to smooth the volumetric lights
  62000. */
  62001. volumetricLightBlurScale: number;
  62002. /**
  62003. * Light (spot or directional) used to generate the volumetric lights rays
  62004. * The source light must have a shadow generate so the pipeline can get its
  62005. * depth map
  62006. */
  62007. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62008. /**
  62009. * For eye adaptation, represents the minimum luminance the eye can see
  62010. */
  62011. hdrMinimumLuminance: number;
  62012. /**
  62013. * For eye adaptation, represents the decrease luminance speed
  62014. */
  62015. hdrDecreaseRate: number;
  62016. /**
  62017. * For eye adaptation, represents the increase luminance speed
  62018. */
  62019. hdrIncreaseRate: number;
  62020. /**
  62021. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62022. */
  62023. /**
  62024. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62025. */
  62026. hdrAutoExposure: boolean;
  62027. /**
  62028. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62029. */
  62030. lensColorTexture: Nullable<Texture>;
  62031. /**
  62032. * The overall strengh for the lens flare effect
  62033. */
  62034. lensFlareStrength: number;
  62035. /**
  62036. * Dispersion coefficient for lens flare ghosts
  62037. */
  62038. lensFlareGhostDispersal: number;
  62039. /**
  62040. * Main lens flare halo width
  62041. */
  62042. lensFlareHaloWidth: number;
  62043. /**
  62044. * Based on the lens distortion effect, defines how much the lens flare result
  62045. * is distorted
  62046. */
  62047. lensFlareDistortionStrength: number;
  62048. /**
  62049. * Lens star texture must be used to simulate rays on the flares and is available
  62050. * in the documentation
  62051. */
  62052. lensStarTexture: Nullable<Texture>;
  62053. /**
  62054. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62055. * flare effect by taking account of the dirt texture
  62056. */
  62057. lensFlareDirtTexture: Nullable<Texture>;
  62058. /**
  62059. * Represents the focal length for the depth of field effect
  62060. */
  62061. depthOfFieldDistance: number;
  62062. /**
  62063. * Represents the blur intensity for the blurred part of the depth of field effect
  62064. */
  62065. depthOfFieldBlurWidth: number;
  62066. /**
  62067. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62068. */
  62069. /**
  62070. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62071. */
  62072. motionStrength: number;
  62073. /**
  62074. * Gets wether or not the motion blur post-process is object based or screen based.
  62075. */
  62076. /**
  62077. * Sets wether or not the motion blur post-process should be object based or screen based
  62078. */
  62079. objectBasedMotionBlur: boolean;
  62080. /**
  62081. * List of animations for the pipeline (IAnimatable implementation)
  62082. */
  62083. animations: Animation[];
  62084. /**
  62085. * Private members
  62086. */
  62087. private _scene;
  62088. private _currentDepthOfFieldSource;
  62089. private _basePostProcess;
  62090. private _fixedExposure;
  62091. private _currentExposure;
  62092. private _hdrAutoExposure;
  62093. private _hdrCurrentLuminance;
  62094. private _motionStrength;
  62095. private _isObjectBasedMotionBlur;
  62096. private _floatTextureType;
  62097. private _camerasToBeAttached;
  62098. private _ratio;
  62099. private _bloomEnabled;
  62100. private _depthOfFieldEnabled;
  62101. private _vlsEnabled;
  62102. private _lensFlareEnabled;
  62103. private _hdrEnabled;
  62104. private _motionBlurEnabled;
  62105. private _fxaaEnabled;
  62106. private _motionBlurSamples;
  62107. private _volumetricLightStepsCount;
  62108. private _samples;
  62109. /**
  62110. * @ignore
  62111. * Specifies if the bloom pipeline is enabled
  62112. */
  62113. BloomEnabled: boolean;
  62114. /**
  62115. * @ignore
  62116. * Specifies if the depth of field pipeline is enabed
  62117. */
  62118. DepthOfFieldEnabled: boolean;
  62119. /**
  62120. * @ignore
  62121. * Specifies if the lens flare pipeline is enabed
  62122. */
  62123. LensFlareEnabled: boolean;
  62124. /**
  62125. * @ignore
  62126. * Specifies if the HDR pipeline is enabled
  62127. */
  62128. HDREnabled: boolean;
  62129. /**
  62130. * @ignore
  62131. * Specifies if the volumetric lights scattering effect is enabled
  62132. */
  62133. VLSEnabled: boolean;
  62134. /**
  62135. * @ignore
  62136. * Specifies if the motion blur effect is enabled
  62137. */
  62138. MotionBlurEnabled: boolean;
  62139. /**
  62140. * Specifies if anti-aliasing is enabled
  62141. */
  62142. fxaaEnabled: boolean;
  62143. /**
  62144. * Specifies the number of steps used to calculate the volumetric lights
  62145. * Typically in interval [50, 200]
  62146. */
  62147. volumetricLightStepsCount: number;
  62148. /**
  62149. * Specifies the number of samples used for the motion blur effect
  62150. * Typically in interval [16, 64]
  62151. */
  62152. motionBlurSamples: number;
  62153. /**
  62154. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62155. */
  62156. samples: number;
  62157. /**
  62158. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62159. * @constructor
  62160. * @param name The rendering pipeline name
  62161. * @param scene The scene linked to this pipeline
  62162. * @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)
  62163. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62164. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62165. */
  62166. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62167. private _buildPipeline;
  62168. private _createDownSampleX4PostProcess;
  62169. private _createBrightPassPostProcess;
  62170. private _createBlurPostProcesses;
  62171. private _createTextureAdderPostProcess;
  62172. private _createVolumetricLightPostProcess;
  62173. private _createLuminancePostProcesses;
  62174. private _createHdrPostProcess;
  62175. private _createLensFlarePostProcess;
  62176. private _createDepthOfFieldPostProcess;
  62177. private _createMotionBlurPostProcess;
  62178. private _getDepthTexture;
  62179. private _disposePostProcesses;
  62180. /**
  62181. * Dispose of the pipeline and stop all post processes
  62182. */
  62183. dispose(): void;
  62184. /**
  62185. * Serialize the rendering pipeline (Used when exporting)
  62186. * @returns the serialized object
  62187. */
  62188. serialize(): any;
  62189. /**
  62190. * Parse the serialized pipeline
  62191. * @param source Source pipeline.
  62192. * @param scene The scene to load the pipeline to.
  62193. * @param rootUrl The URL of the serialized pipeline.
  62194. * @returns An instantiated pipeline from the serialized object.
  62195. */
  62196. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62197. /**
  62198. * Luminance steps
  62199. */
  62200. static LuminanceSteps: number;
  62201. }
  62202. }
  62203. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62204. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62205. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62206. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62207. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62208. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62209. }
  62210. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62211. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62212. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62213. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62214. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62215. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62216. }
  62217. declare module "babylonjs/Shaders/tonemap.fragment" {
  62218. /** @hidden */
  62219. export var tonemapPixelShader: {
  62220. name: string;
  62221. shader: string;
  62222. };
  62223. }
  62224. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62225. import { Camera } from "babylonjs/Cameras/camera";
  62226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62227. import "babylonjs/Shaders/tonemap.fragment";
  62228. import { Engine } from "babylonjs/Engines/engine";
  62229. /** Defines operator used for tonemapping */
  62230. export enum TonemappingOperator {
  62231. /** Hable */
  62232. Hable = 0,
  62233. /** Reinhard */
  62234. Reinhard = 1,
  62235. /** HejiDawson */
  62236. HejiDawson = 2,
  62237. /** Photographic */
  62238. Photographic = 3
  62239. }
  62240. /**
  62241. * Defines a post process to apply tone mapping
  62242. */
  62243. export class TonemapPostProcess extends PostProcess {
  62244. private _operator;
  62245. /** Defines the required exposure adjustement */
  62246. exposureAdjustment: number;
  62247. /**
  62248. * Creates a new TonemapPostProcess
  62249. * @param name defines the name of the postprocess
  62250. * @param _operator defines the operator to use
  62251. * @param exposureAdjustment defines the required exposure adjustement
  62252. * @param camera defines the camera to use (can be null)
  62253. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62254. * @param engine defines the hosting engine (can be ignore if camera is set)
  62255. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62256. */
  62257. constructor(name: string, _operator: TonemappingOperator,
  62258. /** Defines the required exposure adjustement */
  62259. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62260. }
  62261. }
  62262. declare module "babylonjs/Shaders/depth.vertex" {
  62263. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62264. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62266. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62267. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62268. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62269. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62270. /** @hidden */
  62271. export var depthVertexShader: {
  62272. name: string;
  62273. shader: string;
  62274. };
  62275. }
  62276. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62277. /** @hidden */
  62278. export var volumetricLightScatteringPixelShader: {
  62279. name: string;
  62280. shader: string;
  62281. };
  62282. }
  62283. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62284. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62287. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62288. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62289. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62290. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62291. /** @hidden */
  62292. export var volumetricLightScatteringPassVertexShader: {
  62293. name: string;
  62294. shader: string;
  62295. };
  62296. }
  62297. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62298. /** @hidden */
  62299. export var volumetricLightScatteringPassPixelShader: {
  62300. name: string;
  62301. shader: string;
  62302. };
  62303. }
  62304. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62305. import { Vector3 } from "babylonjs/Maths/math.vector";
  62306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62307. import { Mesh } from "babylonjs/Meshes/mesh";
  62308. import { Camera } from "babylonjs/Cameras/camera";
  62309. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62310. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62311. import { Scene } from "babylonjs/scene";
  62312. import "babylonjs/Meshes/Builders/planeBuilder";
  62313. import "babylonjs/Shaders/depth.vertex";
  62314. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62315. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62316. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62317. import { Engine } from "babylonjs/Engines/engine";
  62318. /**
  62319. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62320. */
  62321. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62322. private _volumetricLightScatteringPass;
  62323. private _volumetricLightScatteringRTT;
  62324. private _viewPort;
  62325. private _screenCoordinates;
  62326. private _cachedDefines;
  62327. /**
  62328. * If not undefined, the mesh position is computed from the attached node position
  62329. */
  62330. attachedNode: {
  62331. position: Vector3;
  62332. };
  62333. /**
  62334. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62335. */
  62336. customMeshPosition: Vector3;
  62337. /**
  62338. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62339. */
  62340. useCustomMeshPosition: boolean;
  62341. /**
  62342. * If the post-process should inverse the light scattering direction
  62343. */
  62344. invert: boolean;
  62345. /**
  62346. * The internal mesh used by the post-process
  62347. */
  62348. mesh: Mesh;
  62349. /**
  62350. * @hidden
  62351. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62352. */
  62353. useDiffuseColor: boolean;
  62354. /**
  62355. * Array containing the excluded meshes not rendered in the internal pass
  62356. */
  62357. excludedMeshes: AbstractMesh[];
  62358. /**
  62359. * Controls the overall intensity of the post-process
  62360. */
  62361. exposure: number;
  62362. /**
  62363. * Dissipates each sample's contribution in range [0, 1]
  62364. */
  62365. decay: number;
  62366. /**
  62367. * Controls the overall intensity of each sample
  62368. */
  62369. weight: number;
  62370. /**
  62371. * Controls the density of each sample
  62372. */
  62373. density: number;
  62374. /**
  62375. * @constructor
  62376. * @param name The post-process name
  62377. * @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)
  62378. * @param camera The camera that the post-process will be attached to
  62379. * @param mesh The mesh used to create the light scattering
  62380. * @param samples The post-process quality, default 100
  62381. * @param samplingModeThe post-process filtering mode
  62382. * @param engine The babylon engine
  62383. * @param reusable If the post-process is reusable
  62384. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62385. */
  62386. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62387. /**
  62388. * Returns the string "VolumetricLightScatteringPostProcess"
  62389. * @returns "VolumetricLightScatteringPostProcess"
  62390. */
  62391. getClassName(): string;
  62392. private _isReady;
  62393. /**
  62394. * Sets the new light position for light scattering effect
  62395. * @param position The new custom light position
  62396. */
  62397. setCustomMeshPosition(position: Vector3): void;
  62398. /**
  62399. * Returns the light position for light scattering effect
  62400. * @return Vector3 The custom light position
  62401. */
  62402. getCustomMeshPosition(): Vector3;
  62403. /**
  62404. * Disposes the internal assets and detaches the post-process from the camera
  62405. */
  62406. dispose(camera: Camera): void;
  62407. /**
  62408. * Returns the render target texture used by the post-process
  62409. * @return the render target texture used by the post-process
  62410. */
  62411. getPass(): RenderTargetTexture;
  62412. private _meshExcluded;
  62413. private _createPass;
  62414. private _updateMeshScreenCoordinates;
  62415. /**
  62416. * Creates a default mesh for the Volumeric Light Scattering post-process
  62417. * @param name The mesh name
  62418. * @param scene The scene where to create the mesh
  62419. * @return the default mesh
  62420. */
  62421. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62422. }
  62423. }
  62424. declare module "babylonjs/PostProcesses/index" {
  62425. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62426. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62427. export * from "babylonjs/PostProcesses/bloomEffect";
  62428. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62429. export * from "babylonjs/PostProcesses/blurPostProcess";
  62430. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62431. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62432. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62433. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62434. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62435. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62436. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62437. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62438. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62439. export * from "babylonjs/PostProcesses/filterPostProcess";
  62440. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62441. export * from "babylonjs/PostProcesses/grainPostProcess";
  62442. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62443. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62444. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62445. export * from "babylonjs/PostProcesses/passPostProcess";
  62446. export * from "babylonjs/PostProcesses/postProcess";
  62447. export * from "babylonjs/PostProcesses/postProcessManager";
  62448. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62449. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62450. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62451. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62452. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62453. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62454. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62455. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62456. }
  62457. declare module "babylonjs/Probes/index" {
  62458. export * from "babylonjs/Probes/reflectionProbe";
  62459. }
  62460. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62461. import { Scene } from "babylonjs/scene";
  62462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62463. import { SmartArray } from "babylonjs/Misc/smartArray";
  62464. import { ISceneComponent } from "babylonjs/sceneComponent";
  62465. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62466. import "babylonjs/Meshes/Builders/boxBuilder";
  62467. import "babylonjs/Shaders/color.fragment";
  62468. import "babylonjs/Shaders/color.vertex";
  62469. import { Color3 } from "babylonjs/Maths/math.color";
  62470. module "babylonjs/scene" {
  62471. interface Scene {
  62472. /** @hidden (Backing field) */
  62473. _boundingBoxRenderer: BoundingBoxRenderer;
  62474. /** @hidden (Backing field) */
  62475. _forceShowBoundingBoxes: boolean;
  62476. /**
  62477. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62478. */
  62479. forceShowBoundingBoxes: boolean;
  62480. /**
  62481. * Gets the bounding box renderer associated with the scene
  62482. * @returns a BoundingBoxRenderer
  62483. */
  62484. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62485. }
  62486. }
  62487. module "babylonjs/Meshes/abstractMesh" {
  62488. interface AbstractMesh {
  62489. /** @hidden (Backing field) */
  62490. _showBoundingBox: boolean;
  62491. /**
  62492. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62493. */
  62494. showBoundingBox: boolean;
  62495. }
  62496. }
  62497. /**
  62498. * Component responsible of rendering the bounding box of the meshes in a scene.
  62499. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62500. */
  62501. export class BoundingBoxRenderer implements ISceneComponent {
  62502. /**
  62503. * The component name helpfull to identify the component in the list of scene components.
  62504. */
  62505. readonly name: string;
  62506. /**
  62507. * The scene the component belongs to.
  62508. */
  62509. scene: Scene;
  62510. /**
  62511. * Color of the bounding box lines placed in front of an object
  62512. */
  62513. frontColor: Color3;
  62514. /**
  62515. * Color of the bounding box lines placed behind an object
  62516. */
  62517. backColor: Color3;
  62518. /**
  62519. * Defines if the renderer should show the back lines or not
  62520. */
  62521. showBackLines: boolean;
  62522. /**
  62523. * @hidden
  62524. */
  62525. renderList: SmartArray<BoundingBox>;
  62526. private _colorShader;
  62527. private _vertexBuffers;
  62528. private _indexBuffer;
  62529. private _fillIndexBuffer;
  62530. private _fillIndexData;
  62531. /**
  62532. * Instantiates a new bounding box renderer in a scene.
  62533. * @param scene the scene the renderer renders in
  62534. */
  62535. constructor(scene: Scene);
  62536. /**
  62537. * Registers the component in a given scene
  62538. */
  62539. register(): void;
  62540. private _evaluateSubMesh;
  62541. private _activeMesh;
  62542. private _prepareRessources;
  62543. private _createIndexBuffer;
  62544. /**
  62545. * Rebuilds the elements related to this component in case of
  62546. * context lost for instance.
  62547. */
  62548. rebuild(): void;
  62549. /**
  62550. * @hidden
  62551. */
  62552. reset(): void;
  62553. /**
  62554. * Render the bounding boxes of a specific rendering group
  62555. * @param renderingGroupId defines the rendering group to render
  62556. */
  62557. render(renderingGroupId: number): void;
  62558. /**
  62559. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62560. * @param mesh Define the mesh to render the occlusion bounding box for
  62561. */
  62562. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62563. /**
  62564. * Dispose and release the resources attached to this renderer.
  62565. */
  62566. dispose(): void;
  62567. }
  62568. }
  62569. declare module "babylonjs/Shaders/depth.fragment" {
  62570. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62571. /** @hidden */
  62572. export var depthPixelShader: {
  62573. name: string;
  62574. shader: string;
  62575. };
  62576. }
  62577. declare module "babylonjs/Rendering/depthRenderer" {
  62578. import { Nullable } from "babylonjs/types";
  62579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62580. import { Scene } from "babylonjs/scene";
  62581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62582. import { Camera } from "babylonjs/Cameras/camera";
  62583. import "babylonjs/Shaders/depth.fragment";
  62584. import "babylonjs/Shaders/depth.vertex";
  62585. /**
  62586. * This represents a depth renderer in Babylon.
  62587. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62588. */
  62589. export class DepthRenderer {
  62590. private _scene;
  62591. private _depthMap;
  62592. private _effect;
  62593. private readonly _storeNonLinearDepth;
  62594. private readonly _clearColor;
  62595. /** Get if the depth renderer is using packed depth or not */
  62596. readonly isPacked: boolean;
  62597. private _cachedDefines;
  62598. private _camera;
  62599. /**
  62600. * Specifiess that the depth renderer will only be used within
  62601. * the camera it is created for.
  62602. * This can help forcing its rendering during the camera processing.
  62603. */
  62604. useOnlyInActiveCamera: boolean;
  62605. /** @hidden */
  62606. static _SceneComponentInitialization: (scene: Scene) => void;
  62607. /**
  62608. * Instantiates a depth renderer
  62609. * @param scene The scene the renderer belongs to
  62610. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62611. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62612. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62613. */
  62614. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62615. /**
  62616. * Creates the depth rendering effect and checks if the effect is ready.
  62617. * @param subMesh The submesh to be used to render the depth map of
  62618. * @param useInstances If multiple world instances should be used
  62619. * @returns if the depth renderer is ready to render the depth map
  62620. */
  62621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62622. /**
  62623. * Gets the texture which the depth map will be written to.
  62624. * @returns The depth map texture
  62625. */
  62626. getDepthMap(): RenderTargetTexture;
  62627. /**
  62628. * Disposes of the depth renderer.
  62629. */
  62630. dispose(): void;
  62631. }
  62632. }
  62633. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62634. import { Nullable } from "babylonjs/types";
  62635. import { Scene } from "babylonjs/scene";
  62636. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62637. import { Camera } from "babylonjs/Cameras/camera";
  62638. import { ISceneComponent } from "babylonjs/sceneComponent";
  62639. module "babylonjs/scene" {
  62640. interface Scene {
  62641. /** @hidden (Backing field) */
  62642. _depthRenderer: {
  62643. [id: string]: DepthRenderer;
  62644. };
  62645. /**
  62646. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62647. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62648. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62649. * @returns the created depth renderer
  62650. */
  62651. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62652. /**
  62653. * Disables a depth renderer for a given camera
  62654. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62655. */
  62656. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62657. }
  62658. }
  62659. /**
  62660. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62661. * in several rendering techniques.
  62662. */
  62663. export class DepthRendererSceneComponent implements ISceneComponent {
  62664. /**
  62665. * The component name helpfull to identify the component in the list of scene components.
  62666. */
  62667. readonly name: string;
  62668. /**
  62669. * The scene the component belongs to.
  62670. */
  62671. scene: Scene;
  62672. /**
  62673. * Creates a new instance of the component for the given scene
  62674. * @param scene Defines the scene to register the component in
  62675. */
  62676. constructor(scene: Scene);
  62677. /**
  62678. * Registers the component in a given scene
  62679. */
  62680. register(): void;
  62681. /**
  62682. * Rebuilds the elements related to this component in case of
  62683. * context lost for instance.
  62684. */
  62685. rebuild(): void;
  62686. /**
  62687. * Disposes the component and the associated ressources
  62688. */
  62689. dispose(): void;
  62690. private _gatherRenderTargets;
  62691. private _gatherActiveCameraRenderTargets;
  62692. }
  62693. }
  62694. declare module "babylonjs/Shaders/outline.fragment" {
  62695. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62696. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62697. /** @hidden */
  62698. export var outlinePixelShader: {
  62699. name: string;
  62700. shader: string;
  62701. };
  62702. }
  62703. declare module "babylonjs/Shaders/outline.vertex" {
  62704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62705. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62706. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62707. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62708. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62709. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62710. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62711. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62712. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62713. /** @hidden */
  62714. export var outlineVertexShader: {
  62715. name: string;
  62716. shader: string;
  62717. };
  62718. }
  62719. declare module "babylonjs/Rendering/outlineRenderer" {
  62720. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62721. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62722. import { Scene } from "babylonjs/scene";
  62723. import { ISceneComponent } from "babylonjs/sceneComponent";
  62724. import "babylonjs/Shaders/outline.fragment";
  62725. import "babylonjs/Shaders/outline.vertex";
  62726. module "babylonjs/scene" {
  62727. interface Scene {
  62728. /** @hidden */
  62729. _outlineRenderer: OutlineRenderer;
  62730. /**
  62731. * Gets the outline renderer associated with the scene
  62732. * @returns a OutlineRenderer
  62733. */
  62734. getOutlineRenderer(): OutlineRenderer;
  62735. }
  62736. }
  62737. module "babylonjs/Meshes/abstractMesh" {
  62738. interface AbstractMesh {
  62739. /** @hidden (Backing field) */
  62740. _renderOutline: boolean;
  62741. /**
  62742. * Gets or sets a boolean indicating if the outline must be rendered as well
  62743. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62744. */
  62745. renderOutline: boolean;
  62746. /** @hidden (Backing field) */
  62747. _renderOverlay: boolean;
  62748. /**
  62749. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62750. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62751. */
  62752. renderOverlay: boolean;
  62753. }
  62754. }
  62755. /**
  62756. * This class is responsible to draw bothe outline/overlay of meshes.
  62757. * It should not be used directly but through the available method on mesh.
  62758. */
  62759. export class OutlineRenderer implements ISceneComponent {
  62760. /**
  62761. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62762. */
  62763. private static _StencilReference;
  62764. /**
  62765. * The name of the component. Each component must have a unique name.
  62766. */
  62767. name: string;
  62768. /**
  62769. * The scene the component belongs to.
  62770. */
  62771. scene: Scene;
  62772. /**
  62773. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62774. */
  62775. zOffset: number;
  62776. private _engine;
  62777. private _effect;
  62778. private _cachedDefines;
  62779. private _savedDepthWrite;
  62780. /**
  62781. * Instantiates a new outline renderer. (There could be only one per scene).
  62782. * @param scene Defines the scene it belongs to
  62783. */
  62784. constructor(scene: Scene);
  62785. /**
  62786. * Register the component to one instance of a scene.
  62787. */
  62788. register(): void;
  62789. /**
  62790. * Rebuilds the elements related to this component in case of
  62791. * context lost for instance.
  62792. */
  62793. rebuild(): void;
  62794. /**
  62795. * Disposes the component and the associated ressources.
  62796. */
  62797. dispose(): void;
  62798. /**
  62799. * Renders the outline in the canvas.
  62800. * @param subMesh Defines the sumesh to render
  62801. * @param batch Defines the batch of meshes in case of instances
  62802. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62803. */
  62804. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62805. /**
  62806. * Returns whether or not the outline renderer is ready for a given submesh.
  62807. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62808. * @param subMesh Defines the submesh to check readyness for
  62809. * @param useInstances Defines wheter wee are trying to render instances or not
  62810. * @returns true if ready otherwise false
  62811. */
  62812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62813. private _beforeRenderingMesh;
  62814. private _afterRenderingMesh;
  62815. }
  62816. }
  62817. declare module "babylonjs/Rendering/index" {
  62818. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62819. export * from "babylonjs/Rendering/depthRenderer";
  62820. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62821. export * from "babylonjs/Rendering/edgesRenderer";
  62822. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62823. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62824. export * from "babylonjs/Rendering/outlineRenderer";
  62825. export * from "babylonjs/Rendering/renderingGroup";
  62826. export * from "babylonjs/Rendering/renderingManager";
  62827. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62828. }
  62829. declare module "babylonjs/Sprites/spritePackedManager" {
  62830. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  62831. import { Scene } from "babylonjs/scene";
  62832. /**
  62833. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62834. * @see http://doc.babylonjs.com/babylon101/sprites
  62835. */
  62836. export class SpritePackedManager extends SpriteManager {
  62837. /** defines the packed manager's name */
  62838. name: string;
  62839. /**
  62840. * Creates a new sprite manager from a packed sprite sheet
  62841. * @param name defines the manager's name
  62842. * @param imgUrl defines the sprite sheet url
  62843. * @param capacity defines the maximum allowed number of sprites
  62844. * @param scene defines the hosting scene
  62845. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62846. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62847. * @param samplingMode defines the smapling mode to use with spritesheet
  62848. * @param fromPacked set to true; do not alter
  62849. */
  62850. constructor(
  62851. /** defines the packed manager's name */
  62852. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62853. }
  62854. }
  62855. declare module "babylonjs/Sprites/index" {
  62856. export * from "babylonjs/Sprites/sprite";
  62857. export * from "babylonjs/Sprites/spriteManager";
  62858. export * from "babylonjs/Sprites/spritePackedManager";
  62859. export * from "babylonjs/Sprites/spriteSceneComponent";
  62860. }
  62861. declare module "babylonjs/Misc/assetsManager" {
  62862. import { Scene } from "babylonjs/scene";
  62863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62865. import { Skeleton } from "babylonjs/Bones/skeleton";
  62866. import { Observable } from "babylonjs/Misc/observable";
  62867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62868. import { Texture } from "babylonjs/Materials/Textures/texture";
  62869. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62870. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62871. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62872. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62873. /**
  62874. * Defines the list of states available for a task inside a AssetsManager
  62875. */
  62876. export enum AssetTaskState {
  62877. /**
  62878. * Initialization
  62879. */
  62880. INIT = 0,
  62881. /**
  62882. * Running
  62883. */
  62884. RUNNING = 1,
  62885. /**
  62886. * Done
  62887. */
  62888. DONE = 2,
  62889. /**
  62890. * Error
  62891. */
  62892. ERROR = 3
  62893. }
  62894. /**
  62895. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62896. */
  62897. export abstract class AbstractAssetTask {
  62898. /**
  62899. * Task name
  62900. */ name: string;
  62901. /**
  62902. * Callback called when the task is successful
  62903. */
  62904. onSuccess: (task: any) => void;
  62905. /**
  62906. * Callback called when the task is not successful
  62907. */
  62908. onError: (task: any, message?: string, exception?: any) => void;
  62909. /**
  62910. * Creates a new AssetsManager
  62911. * @param name defines the name of the task
  62912. */
  62913. constructor(
  62914. /**
  62915. * Task name
  62916. */ name: string);
  62917. private _isCompleted;
  62918. private _taskState;
  62919. private _errorObject;
  62920. /**
  62921. * Get if the task is completed
  62922. */
  62923. readonly isCompleted: boolean;
  62924. /**
  62925. * Gets the current state of the task
  62926. */
  62927. readonly taskState: AssetTaskState;
  62928. /**
  62929. * Gets the current error object (if task is in error)
  62930. */
  62931. readonly errorObject: {
  62932. message?: string;
  62933. exception?: any;
  62934. };
  62935. /**
  62936. * Internal only
  62937. * @hidden
  62938. */
  62939. _setErrorObject(message?: string, exception?: any): void;
  62940. /**
  62941. * Execute the current task
  62942. * @param scene defines the scene where you want your assets to be loaded
  62943. * @param onSuccess is a callback called when the task is successfully executed
  62944. * @param onError is a callback called if an error occurs
  62945. */
  62946. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62947. /**
  62948. * Execute the current task
  62949. * @param scene defines the scene where you want your assets to be loaded
  62950. * @param onSuccess is a callback called when the task is successfully executed
  62951. * @param onError is a callback called if an error occurs
  62952. */
  62953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62954. /**
  62955. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62956. * This can be used with failed tasks that have the reason for failure fixed.
  62957. */
  62958. reset(): void;
  62959. private onErrorCallback;
  62960. private onDoneCallback;
  62961. }
  62962. /**
  62963. * Define the interface used by progress events raised during assets loading
  62964. */
  62965. export interface IAssetsProgressEvent {
  62966. /**
  62967. * Defines the number of remaining tasks to process
  62968. */
  62969. remainingCount: number;
  62970. /**
  62971. * Defines the total number of tasks
  62972. */
  62973. totalCount: number;
  62974. /**
  62975. * Defines the task that was just processed
  62976. */
  62977. task: AbstractAssetTask;
  62978. }
  62979. /**
  62980. * Class used to share progress information about assets loading
  62981. */
  62982. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62983. /**
  62984. * Defines the number of remaining tasks to process
  62985. */
  62986. remainingCount: number;
  62987. /**
  62988. * Defines the total number of tasks
  62989. */
  62990. totalCount: number;
  62991. /**
  62992. * Defines the task that was just processed
  62993. */
  62994. task: AbstractAssetTask;
  62995. /**
  62996. * Creates a AssetsProgressEvent
  62997. * @param remainingCount defines the number of remaining tasks to process
  62998. * @param totalCount defines the total number of tasks
  62999. * @param task defines the task that was just processed
  63000. */
  63001. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63002. }
  63003. /**
  63004. * Define a task used by AssetsManager to load meshes
  63005. */
  63006. export class MeshAssetTask extends AbstractAssetTask {
  63007. /**
  63008. * Defines the name of the task
  63009. */
  63010. name: string;
  63011. /**
  63012. * Defines the list of mesh's names you want to load
  63013. */
  63014. meshesNames: any;
  63015. /**
  63016. * Defines the root url to use as a base to load your meshes and associated resources
  63017. */
  63018. rootUrl: string;
  63019. /**
  63020. * Defines the filename of the scene to load from
  63021. */
  63022. sceneFilename: string;
  63023. /**
  63024. * Gets the list of loaded meshes
  63025. */
  63026. loadedMeshes: Array<AbstractMesh>;
  63027. /**
  63028. * Gets the list of loaded particle systems
  63029. */
  63030. loadedParticleSystems: Array<IParticleSystem>;
  63031. /**
  63032. * Gets the list of loaded skeletons
  63033. */
  63034. loadedSkeletons: Array<Skeleton>;
  63035. /**
  63036. * Gets the list of loaded animation groups
  63037. */
  63038. loadedAnimationGroups: Array<AnimationGroup>;
  63039. /**
  63040. * Callback called when the task is successful
  63041. */
  63042. onSuccess: (task: MeshAssetTask) => void;
  63043. /**
  63044. * Callback called when the task is successful
  63045. */
  63046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63047. /**
  63048. * Creates a new MeshAssetTask
  63049. * @param name defines the name of the task
  63050. * @param meshesNames defines the list of mesh's names you want to load
  63051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63052. * @param sceneFilename defines the filename of the scene to load from
  63053. */
  63054. constructor(
  63055. /**
  63056. * Defines the name of the task
  63057. */
  63058. name: string,
  63059. /**
  63060. * Defines the list of mesh's names you want to load
  63061. */
  63062. meshesNames: any,
  63063. /**
  63064. * Defines the root url to use as a base to load your meshes and associated resources
  63065. */
  63066. rootUrl: string,
  63067. /**
  63068. * Defines the filename of the scene to load from
  63069. */
  63070. sceneFilename: string);
  63071. /**
  63072. * Execute the current task
  63073. * @param scene defines the scene where you want your assets to be loaded
  63074. * @param onSuccess is a callback called when the task is successfully executed
  63075. * @param onError is a callback called if an error occurs
  63076. */
  63077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63078. }
  63079. /**
  63080. * Define a task used by AssetsManager to load text content
  63081. */
  63082. export class TextFileAssetTask extends AbstractAssetTask {
  63083. /**
  63084. * Defines the name of the task
  63085. */
  63086. name: string;
  63087. /**
  63088. * Defines the location of the file to load
  63089. */
  63090. url: string;
  63091. /**
  63092. * Gets the loaded text string
  63093. */
  63094. text: string;
  63095. /**
  63096. * Callback called when the task is successful
  63097. */
  63098. onSuccess: (task: TextFileAssetTask) => void;
  63099. /**
  63100. * Callback called when the task is successful
  63101. */
  63102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63103. /**
  63104. * Creates a new TextFileAssetTask object
  63105. * @param name defines the name of the task
  63106. * @param url defines the location of the file to load
  63107. */
  63108. constructor(
  63109. /**
  63110. * Defines the name of the task
  63111. */
  63112. name: string,
  63113. /**
  63114. * Defines the location of the file to load
  63115. */
  63116. url: string);
  63117. /**
  63118. * Execute the current task
  63119. * @param scene defines the scene where you want your assets to be loaded
  63120. * @param onSuccess is a callback called when the task is successfully executed
  63121. * @param onError is a callback called if an error occurs
  63122. */
  63123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63124. }
  63125. /**
  63126. * Define a task used by AssetsManager to load binary data
  63127. */
  63128. export class BinaryFileAssetTask extends AbstractAssetTask {
  63129. /**
  63130. * Defines the name of the task
  63131. */
  63132. name: string;
  63133. /**
  63134. * Defines the location of the file to load
  63135. */
  63136. url: string;
  63137. /**
  63138. * Gets the lodaded data (as an array buffer)
  63139. */
  63140. data: ArrayBuffer;
  63141. /**
  63142. * Callback called when the task is successful
  63143. */
  63144. onSuccess: (task: BinaryFileAssetTask) => void;
  63145. /**
  63146. * Callback called when the task is successful
  63147. */
  63148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63149. /**
  63150. * Creates a new BinaryFileAssetTask object
  63151. * @param name defines the name of the new task
  63152. * @param url defines the location of the file to load
  63153. */
  63154. constructor(
  63155. /**
  63156. * Defines the name of the task
  63157. */
  63158. name: string,
  63159. /**
  63160. * Defines the location of the file to load
  63161. */
  63162. url: string);
  63163. /**
  63164. * Execute the current task
  63165. * @param scene defines the scene where you want your assets to be loaded
  63166. * @param onSuccess is a callback called when the task is successfully executed
  63167. * @param onError is a callback called if an error occurs
  63168. */
  63169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63170. }
  63171. /**
  63172. * Define a task used by AssetsManager to load images
  63173. */
  63174. export class ImageAssetTask extends AbstractAssetTask {
  63175. /**
  63176. * Defines the name of the task
  63177. */
  63178. name: string;
  63179. /**
  63180. * Defines the location of the image to load
  63181. */
  63182. url: string;
  63183. /**
  63184. * Gets the loaded images
  63185. */
  63186. image: HTMLImageElement;
  63187. /**
  63188. * Callback called when the task is successful
  63189. */
  63190. onSuccess: (task: ImageAssetTask) => void;
  63191. /**
  63192. * Callback called when the task is successful
  63193. */
  63194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63195. /**
  63196. * Creates a new ImageAssetTask
  63197. * @param name defines the name of the task
  63198. * @param url defines the location of the image to load
  63199. */
  63200. constructor(
  63201. /**
  63202. * Defines the name of the task
  63203. */
  63204. name: string,
  63205. /**
  63206. * Defines the location of the image to load
  63207. */
  63208. url: string);
  63209. /**
  63210. * Execute the current task
  63211. * @param scene defines the scene where you want your assets to be loaded
  63212. * @param onSuccess is a callback called when the task is successfully executed
  63213. * @param onError is a callback called if an error occurs
  63214. */
  63215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63216. }
  63217. /**
  63218. * Defines the interface used by texture loading tasks
  63219. */
  63220. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63221. /**
  63222. * Gets the loaded texture
  63223. */
  63224. texture: TEX;
  63225. }
  63226. /**
  63227. * Define a task used by AssetsManager to load 2D textures
  63228. */
  63229. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63230. /**
  63231. * Defines the name of the task
  63232. */
  63233. name: string;
  63234. /**
  63235. * Defines the location of the file to load
  63236. */
  63237. url: string;
  63238. /**
  63239. * Defines if mipmap should not be generated (default is false)
  63240. */
  63241. noMipmap?: boolean | undefined;
  63242. /**
  63243. * Defines if texture must be inverted on Y axis (default is false)
  63244. */
  63245. invertY?: boolean | undefined;
  63246. /**
  63247. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63248. */
  63249. samplingMode: number;
  63250. /**
  63251. * Gets the loaded texture
  63252. */
  63253. texture: Texture;
  63254. /**
  63255. * Callback called when the task is successful
  63256. */
  63257. onSuccess: (task: TextureAssetTask) => void;
  63258. /**
  63259. * Callback called when the task is successful
  63260. */
  63261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63262. /**
  63263. * Creates a new TextureAssetTask object
  63264. * @param name defines the name of the task
  63265. * @param url defines the location of the file to load
  63266. * @param noMipmap defines if mipmap should not be generated (default is false)
  63267. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63269. */
  63270. constructor(
  63271. /**
  63272. * Defines the name of the task
  63273. */
  63274. name: string,
  63275. /**
  63276. * Defines the location of the file to load
  63277. */
  63278. url: string,
  63279. /**
  63280. * Defines if mipmap should not be generated (default is false)
  63281. */
  63282. noMipmap?: boolean | undefined,
  63283. /**
  63284. * Defines if texture must be inverted on Y axis (default is false)
  63285. */
  63286. invertY?: boolean | undefined,
  63287. /**
  63288. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63289. */
  63290. samplingMode?: number);
  63291. /**
  63292. * Execute the current task
  63293. * @param scene defines the scene where you want your assets to be loaded
  63294. * @param onSuccess is a callback called when the task is successfully executed
  63295. * @param onError is a callback called if an error occurs
  63296. */
  63297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63298. }
  63299. /**
  63300. * Define a task used by AssetsManager to load cube textures
  63301. */
  63302. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63303. /**
  63304. * Defines the name of the task
  63305. */
  63306. name: string;
  63307. /**
  63308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63309. */
  63310. url: string;
  63311. /**
  63312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63313. */
  63314. extensions?: string[] | undefined;
  63315. /**
  63316. * Defines if mipmaps should not be generated (default is false)
  63317. */
  63318. noMipmap?: boolean | undefined;
  63319. /**
  63320. * Defines the explicit list of files (undefined by default)
  63321. */
  63322. files?: string[] | undefined;
  63323. /**
  63324. * Gets the loaded texture
  63325. */
  63326. texture: CubeTexture;
  63327. /**
  63328. * Callback called when the task is successful
  63329. */
  63330. onSuccess: (task: CubeTextureAssetTask) => void;
  63331. /**
  63332. * Callback called when the task is successful
  63333. */
  63334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63335. /**
  63336. * Creates a new CubeTextureAssetTask
  63337. * @param name defines the name of the task
  63338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63341. * @param files defines the explicit list of files (undefined by default)
  63342. */
  63343. constructor(
  63344. /**
  63345. * Defines the name of the task
  63346. */
  63347. name: string,
  63348. /**
  63349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63350. */
  63351. url: string,
  63352. /**
  63353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63354. */
  63355. extensions?: string[] | undefined,
  63356. /**
  63357. * Defines if mipmaps should not be generated (default is false)
  63358. */
  63359. noMipmap?: boolean | undefined,
  63360. /**
  63361. * Defines the explicit list of files (undefined by default)
  63362. */
  63363. files?: string[] | undefined);
  63364. /**
  63365. * Execute the current task
  63366. * @param scene defines the scene where you want your assets to be loaded
  63367. * @param onSuccess is a callback called when the task is successfully executed
  63368. * @param onError is a callback called if an error occurs
  63369. */
  63370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63371. }
  63372. /**
  63373. * Define a task used by AssetsManager to load HDR cube textures
  63374. */
  63375. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63376. /**
  63377. * Defines the name of the task
  63378. */
  63379. name: string;
  63380. /**
  63381. * Defines the location of the file to load
  63382. */
  63383. url: string;
  63384. /**
  63385. * Defines the desired size (the more it increases the longer the generation will be)
  63386. */
  63387. size: number;
  63388. /**
  63389. * Defines if mipmaps should not be generated (default is false)
  63390. */
  63391. noMipmap: boolean;
  63392. /**
  63393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63394. */
  63395. generateHarmonics: boolean;
  63396. /**
  63397. * 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)
  63398. */
  63399. gammaSpace: boolean;
  63400. /**
  63401. * Internal Use Only
  63402. */
  63403. reserved: boolean;
  63404. /**
  63405. * Gets the loaded texture
  63406. */
  63407. texture: HDRCubeTexture;
  63408. /**
  63409. * Callback called when the task is successful
  63410. */
  63411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63412. /**
  63413. * Callback called when the task is successful
  63414. */
  63415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63416. /**
  63417. * Creates a new HDRCubeTextureAssetTask object
  63418. * @param name defines the name of the task
  63419. * @param url defines the location of the file to load
  63420. * @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.
  63421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63423. * @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)
  63424. * @param reserved Internal use only
  63425. */
  63426. constructor(
  63427. /**
  63428. * Defines the name of the task
  63429. */
  63430. name: string,
  63431. /**
  63432. * Defines the location of the file to load
  63433. */
  63434. url: string,
  63435. /**
  63436. * Defines the desired size (the more it increases the longer the generation will be)
  63437. */
  63438. size: number,
  63439. /**
  63440. * Defines if mipmaps should not be generated (default is false)
  63441. */
  63442. noMipmap?: boolean,
  63443. /**
  63444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63445. */
  63446. generateHarmonics?: boolean,
  63447. /**
  63448. * 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)
  63449. */
  63450. gammaSpace?: boolean,
  63451. /**
  63452. * Internal Use Only
  63453. */
  63454. reserved?: boolean);
  63455. /**
  63456. * Execute the current task
  63457. * @param scene defines the scene where you want your assets to be loaded
  63458. * @param onSuccess is a callback called when the task is successfully executed
  63459. * @param onError is a callback called if an error occurs
  63460. */
  63461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63462. }
  63463. /**
  63464. * Define a task used by AssetsManager to load Equirectangular cube textures
  63465. */
  63466. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63467. /**
  63468. * Defines the name of the task
  63469. */
  63470. name: string;
  63471. /**
  63472. * Defines the location of the file to load
  63473. */
  63474. url: string;
  63475. /**
  63476. * Defines the desired size (the more it increases the longer the generation will be)
  63477. */
  63478. size: number;
  63479. /**
  63480. * Defines if mipmaps should not be generated (default is false)
  63481. */
  63482. noMipmap: boolean;
  63483. /**
  63484. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63485. * but the standard material would require them in Gamma space) (default is true)
  63486. */
  63487. gammaSpace: boolean;
  63488. /**
  63489. * Gets the loaded texture
  63490. */
  63491. texture: EquiRectangularCubeTexture;
  63492. /**
  63493. * Callback called when the task is successful
  63494. */
  63495. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63496. /**
  63497. * Callback called when the task is successful
  63498. */
  63499. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63500. /**
  63501. * Creates a new EquiRectangularCubeTextureAssetTask object
  63502. * @param name defines the name of the task
  63503. * @param url defines the location of the file to load
  63504. * @param size defines the desired size (the more it increases the longer the generation will be)
  63505. * If the size is omitted this implies you are using a preprocessed cubemap.
  63506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63507. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63508. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63509. * (default is true)
  63510. */
  63511. constructor(
  63512. /**
  63513. * Defines the name of the task
  63514. */
  63515. name: string,
  63516. /**
  63517. * Defines the location of the file to load
  63518. */
  63519. url: string,
  63520. /**
  63521. * Defines the desired size (the more it increases the longer the generation will be)
  63522. */
  63523. size: number,
  63524. /**
  63525. * Defines if mipmaps should not be generated (default is false)
  63526. */
  63527. noMipmap?: boolean,
  63528. /**
  63529. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63530. * but the standard material would require them in Gamma space) (default is true)
  63531. */
  63532. gammaSpace?: boolean);
  63533. /**
  63534. * Execute the current task
  63535. * @param scene defines the scene where you want your assets to be loaded
  63536. * @param onSuccess is a callback called when the task is successfully executed
  63537. * @param onError is a callback called if an error occurs
  63538. */
  63539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63540. }
  63541. /**
  63542. * This class can be used to easily import assets into a scene
  63543. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63544. */
  63545. export class AssetsManager {
  63546. private _scene;
  63547. private _isLoading;
  63548. protected _tasks: AbstractAssetTask[];
  63549. protected _waitingTasksCount: number;
  63550. protected _totalTasksCount: number;
  63551. /**
  63552. * Callback called when all tasks are processed
  63553. */
  63554. onFinish: (tasks: AbstractAssetTask[]) => void;
  63555. /**
  63556. * Callback called when a task is successful
  63557. */
  63558. onTaskSuccess: (task: AbstractAssetTask) => void;
  63559. /**
  63560. * Callback called when a task had an error
  63561. */
  63562. onTaskError: (task: AbstractAssetTask) => void;
  63563. /**
  63564. * Callback called when a task is done (whatever the result is)
  63565. */
  63566. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63567. /**
  63568. * Observable called when all tasks are processed
  63569. */
  63570. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63571. /**
  63572. * Observable called when a task had an error
  63573. */
  63574. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63575. /**
  63576. * Observable called when all tasks were executed
  63577. */
  63578. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63579. /**
  63580. * Observable called when a task is done (whatever the result is)
  63581. */
  63582. onProgressObservable: Observable<IAssetsProgressEvent>;
  63583. /**
  63584. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63585. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63586. */
  63587. useDefaultLoadingScreen: boolean;
  63588. /**
  63589. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63590. * when all assets have been downloaded.
  63591. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63592. */
  63593. autoHideLoadingUI: boolean;
  63594. /**
  63595. * Creates a new AssetsManager
  63596. * @param scene defines the scene to work on
  63597. */
  63598. constructor(scene: Scene);
  63599. /**
  63600. * Add a MeshAssetTask to the list of active tasks
  63601. * @param taskName defines the name of the new task
  63602. * @param meshesNames defines the name of meshes to load
  63603. * @param rootUrl defines the root url to use to locate files
  63604. * @param sceneFilename defines the filename of the scene file
  63605. * @returns a new MeshAssetTask object
  63606. */
  63607. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63608. /**
  63609. * Add a TextFileAssetTask to the list of active tasks
  63610. * @param taskName defines the name of the new task
  63611. * @param url defines the url of the file to load
  63612. * @returns a new TextFileAssetTask object
  63613. */
  63614. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63615. /**
  63616. * Add a BinaryFileAssetTask to the list of active tasks
  63617. * @param taskName defines the name of the new task
  63618. * @param url defines the url of the file to load
  63619. * @returns a new BinaryFileAssetTask object
  63620. */
  63621. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63622. /**
  63623. * Add a ImageAssetTask to the list of active tasks
  63624. * @param taskName defines the name of the new task
  63625. * @param url defines the url of the file to load
  63626. * @returns a new ImageAssetTask object
  63627. */
  63628. addImageTask(taskName: string, url: string): ImageAssetTask;
  63629. /**
  63630. * Add a TextureAssetTask to the list of active tasks
  63631. * @param taskName defines the name of the new task
  63632. * @param url defines the url of the file to load
  63633. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63634. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63635. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63636. * @returns a new TextureAssetTask object
  63637. */
  63638. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63639. /**
  63640. * Add a CubeTextureAssetTask to the list of active tasks
  63641. * @param taskName defines the name of the new task
  63642. * @param url defines the url of the file to load
  63643. * @param extensions defines the extension to use to load the cube map (can be null)
  63644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63645. * @param files defines the list of files to load (can be null)
  63646. * @returns a new CubeTextureAssetTask object
  63647. */
  63648. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63649. /**
  63650. *
  63651. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63652. * @param taskName defines the name of the new task
  63653. * @param url defines the url of the file to load
  63654. * @param size defines the size you want for the cubemap (can be null)
  63655. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63656. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63657. * @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)
  63658. * @param reserved Internal use only
  63659. * @returns a new HDRCubeTextureAssetTask object
  63660. */
  63661. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63662. /**
  63663. *
  63664. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63665. * @param taskName defines the name of the new task
  63666. * @param url defines the url of the file to load
  63667. * @param size defines the size you want for the cubemap (can be null)
  63668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63669. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63670. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63671. * @returns a new EquiRectangularCubeTextureAssetTask object
  63672. */
  63673. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63674. /**
  63675. * Remove a task from the assets manager.
  63676. * @param task the task to remove
  63677. */
  63678. removeTask(task: AbstractAssetTask): void;
  63679. private _decreaseWaitingTasksCount;
  63680. private _runTask;
  63681. /**
  63682. * Reset the AssetsManager and remove all tasks
  63683. * @return the current instance of the AssetsManager
  63684. */
  63685. reset(): AssetsManager;
  63686. /**
  63687. * Start the loading process
  63688. * @return the current instance of the AssetsManager
  63689. */
  63690. load(): AssetsManager;
  63691. /**
  63692. * Start the loading process as an async operation
  63693. * @return a promise returning the list of failed tasks
  63694. */
  63695. loadAsync(): Promise<void>;
  63696. }
  63697. }
  63698. declare module "babylonjs/Misc/deferred" {
  63699. /**
  63700. * Wrapper class for promise with external resolve and reject.
  63701. */
  63702. export class Deferred<T> {
  63703. /**
  63704. * The promise associated with this deferred object.
  63705. */
  63706. readonly promise: Promise<T>;
  63707. private _resolve;
  63708. private _reject;
  63709. /**
  63710. * The resolve method of the promise associated with this deferred object.
  63711. */
  63712. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63713. /**
  63714. * The reject method of the promise associated with this deferred object.
  63715. */
  63716. readonly reject: (reason?: any) => void;
  63717. /**
  63718. * Constructor for this deferred object.
  63719. */
  63720. constructor();
  63721. }
  63722. }
  63723. declare module "babylonjs/Misc/meshExploder" {
  63724. import { Mesh } from "babylonjs/Meshes/mesh";
  63725. /**
  63726. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63727. */
  63728. export class MeshExploder {
  63729. private _centerMesh;
  63730. private _meshes;
  63731. private _meshesOrigins;
  63732. private _toCenterVectors;
  63733. private _scaledDirection;
  63734. private _newPosition;
  63735. private _centerPosition;
  63736. /**
  63737. * Explodes meshes from a center mesh.
  63738. * @param meshes The meshes to explode.
  63739. * @param centerMesh The mesh to be center of explosion.
  63740. */
  63741. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63742. private _setCenterMesh;
  63743. /**
  63744. * Get class name
  63745. * @returns "MeshExploder"
  63746. */
  63747. getClassName(): string;
  63748. /**
  63749. * "Exploded meshes"
  63750. * @returns Array of meshes with the centerMesh at index 0.
  63751. */
  63752. getMeshes(): Array<Mesh>;
  63753. /**
  63754. * Explodes meshes giving a specific direction
  63755. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63756. */
  63757. explode(direction?: number): void;
  63758. }
  63759. }
  63760. declare module "babylonjs/Misc/filesInput" {
  63761. import { Engine } from "babylonjs/Engines/engine";
  63762. import { Scene } from "babylonjs/scene";
  63763. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63764. /**
  63765. * Class used to help managing file picking and drag'n'drop
  63766. */
  63767. export class FilesInput {
  63768. /**
  63769. * List of files ready to be loaded
  63770. */
  63771. static readonly FilesToLoad: {
  63772. [key: string]: File;
  63773. };
  63774. /**
  63775. * Callback called when a file is processed
  63776. */
  63777. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63778. private _engine;
  63779. private _currentScene;
  63780. private _sceneLoadedCallback;
  63781. private _progressCallback;
  63782. private _additionalRenderLoopLogicCallback;
  63783. private _textureLoadingCallback;
  63784. private _startingProcessingFilesCallback;
  63785. private _onReloadCallback;
  63786. private _errorCallback;
  63787. private _elementToMonitor;
  63788. private _sceneFileToLoad;
  63789. private _filesToLoad;
  63790. /**
  63791. * Creates a new FilesInput
  63792. * @param engine defines the rendering engine
  63793. * @param scene defines the hosting scene
  63794. * @param sceneLoadedCallback callback called when scene is loaded
  63795. * @param progressCallback callback called to track progress
  63796. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63797. * @param textureLoadingCallback callback called when a texture is loading
  63798. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63799. * @param onReloadCallback callback called when a reload is requested
  63800. * @param errorCallback callback call if an error occurs
  63801. */
  63802. 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);
  63803. private _dragEnterHandler;
  63804. private _dragOverHandler;
  63805. private _dropHandler;
  63806. /**
  63807. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63808. * @param elementToMonitor defines the DOM element to track
  63809. */
  63810. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63811. /**
  63812. * Release all associated resources
  63813. */
  63814. dispose(): void;
  63815. private renderFunction;
  63816. private drag;
  63817. private drop;
  63818. private _traverseFolder;
  63819. private _processFiles;
  63820. /**
  63821. * Load files from a drop event
  63822. * @param event defines the drop event to use as source
  63823. */
  63824. loadFiles(event: any): void;
  63825. private _processReload;
  63826. /**
  63827. * Reload the current scene from the loaded files
  63828. */
  63829. reload(): void;
  63830. }
  63831. }
  63832. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63833. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63834. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63835. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63836. }
  63837. declare module "babylonjs/Misc/sceneOptimizer" {
  63838. import { Scene, IDisposable } from "babylonjs/scene";
  63839. import { Observable } from "babylonjs/Misc/observable";
  63840. /**
  63841. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63843. */
  63844. export class SceneOptimization {
  63845. /**
  63846. * Defines the priority of this optimization (0 by default which means first in the list)
  63847. */
  63848. priority: number;
  63849. /**
  63850. * Gets a string describing the action executed by the current optimization
  63851. * @returns description string
  63852. */
  63853. getDescription(): string;
  63854. /**
  63855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63856. * @param scene defines the current scene where to apply this optimization
  63857. * @param optimizer defines the current optimizer
  63858. * @returns true if everything that can be done was applied
  63859. */
  63860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63861. /**
  63862. * Creates the SceneOptimization object
  63863. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63864. * @param desc defines the description associated with the optimization
  63865. */
  63866. constructor(
  63867. /**
  63868. * Defines the priority of this optimization (0 by default which means first in the list)
  63869. */
  63870. priority?: number);
  63871. }
  63872. /**
  63873. * Defines an optimization used to reduce the size of render target textures
  63874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63875. */
  63876. export class TextureOptimization extends SceneOptimization {
  63877. /**
  63878. * Defines the priority of this optimization (0 by default which means first in the list)
  63879. */
  63880. priority: number;
  63881. /**
  63882. * 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
  63883. */
  63884. maximumSize: number;
  63885. /**
  63886. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63887. */
  63888. step: number;
  63889. /**
  63890. * Gets a string describing the action executed by the current optimization
  63891. * @returns description string
  63892. */
  63893. getDescription(): string;
  63894. /**
  63895. * Creates the TextureOptimization object
  63896. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63897. * @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
  63898. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63899. */
  63900. constructor(
  63901. /**
  63902. * Defines the priority of this optimization (0 by default which means first in the list)
  63903. */
  63904. priority?: number,
  63905. /**
  63906. * 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
  63907. */
  63908. maximumSize?: number,
  63909. /**
  63910. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63911. */
  63912. step?: number);
  63913. /**
  63914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63915. * @param scene defines the current scene where to apply this optimization
  63916. * @param optimizer defines the current optimizer
  63917. * @returns true if everything that can be done was applied
  63918. */
  63919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63920. }
  63921. /**
  63922. * Defines an optimization used to increase or decrease the rendering resolution
  63923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63924. */
  63925. export class HardwareScalingOptimization extends SceneOptimization {
  63926. /**
  63927. * Defines the priority of this optimization (0 by default which means first in the list)
  63928. */
  63929. priority: number;
  63930. /**
  63931. * Defines the maximum scale to use (2 by default)
  63932. */
  63933. maximumScale: number;
  63934. /**
  63935. * Defines the step to use between two passes (0.5 by default)
  63936. */
  63937. step: number;
  63938. private _currentScale;
  63939. private _directionOffset;
  63940. /**
  63941. * Gets a string describing the action executed by the current optimization
  63942. * @return description string
  63943. */
  63944. getDescription(): string;
  63945. /**
  63946. * Creates the HardwareScalingOptimization object
  63947. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63948. * @param maximumScale defines the maximum scale to use (2 by default)
  63949. * @param step defines the step to use between two passes (0.5 by default)
  63950. */
  63951. constructor(
  63952. /**
  63953. * Defines the priority of this optimization (0 by default which means first in the list)
  63954. */
  63955. priority?: number,
  63956. /**
  63957. * Defines the maximum scale to use (2 by default)
  63958. */
  63959. maximumScale?: number,
  63960. /**
  63961. * Defines the step to use between two passes (0.5 by default)
  63962. */
  63963. step?: number);
  63964. /**
  63965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63966. * @param scene defines the current scene where to apply this optimization
  63967. * @param optimizer defines the current optimizer
  63968. * @returns true if everything that can be done was applied
  63969. */
  63970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63971. }
  63972. /**
  63973. * Defines an optimization used to remove shadows
  63974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63975. */
  63976. export class ShadowsOptimization extends SceneOptimization {
  63977. /**
  63978. * Gets a string describing the action executed by the current optimization
  63979. * @return description string
  63980. */
  63981. getDescription(): string;
  63982. /**
  63983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63984. * @param scene defines the current scene where to apply this optimization
  63985. * @param optimizer defines the current optimizer
  63986. * @returns true if everything that can be done was applied
  63987. */
  63988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63989. }
  63990. /**
  63991. * Defines an optimization used to turn post-processes off
  63992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63993. */
  63994. export class PostProcessesOptimization extends SceneOptimization {
  63995. /**
  63996. * Gets a string describing the action executed by the current optimization
  63997. * @return description string
  63998. */
  63999. getDescription(): string;
  64000. /**
  64001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64002. * @param scene defines the current scene where to apply this optimization
  64003. * @param optimizer defines the current optimizer
  64004. * @returns true if everything that can be done was applied
  64005. */
  64006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64007. }
  64008. /**
  64009. * Defines an optimization used to turn lens flares off
  64010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64011. */
  64012. export class LensFlaresOptimization extends SceneOptimization {
  64013. /**
  64014. * Gets a string describing the action executed by the current optimization
  64015. * @return description string
  64016. */
  64017. getDescription(): string;
  64018. /**
  64019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64020. * @param scene defines the current scene where to apply this optimization
  64021. * @param optimizer defines the current optimizer
  64022. * @returns true if everything that can be done was applied
  64023. */
  64024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64025. }
  64026. /**
  64027. * Defines an optimization based on user defined callback.
  64028. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64029. */
  64030. export class CustomOptimization extends SceneOptimization {
  64031. /**
  64032. * Callback called to apply the custom optimization.
  64033. */
  64034. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64035. /**
  64036. * Callback called to get custom description
  64037. */
  64038. onGetDescription: () => string;
  64039. /**
  64040. * Gets a string describing the action executed by the current optimization
  64041. * @returns description string
  64042. */
  64043. getDescription(): string;
  64044. /**
  64045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64046. * @param scene defines the current scene where to apply this optimization
  64047. * @param optimizer defines the current optimizer
  64048. * @returns true if everything that can be done was applied
  64049. */
  64050. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64051. }
  64052. /**
  64053. * Defines an optimization used to turn particles off
  64054. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64055. */
  64056. export class ParticlesOptimization extends SceneOptimization {
  64057. /**
  64058. * Gets a string describing the action executed by the current optimization
  64059. * @return description string
  64060. */
  64061. getDescription(): string;
  64062. /**
  64063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64064. * @param scene defines the current scene where to apply this optimization
  64065. * @param optimizer defines the current optimizer
  64066. * @returns true if everything that can be done was applied
  64067. */
  64068. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64069. }
  64070. /**
  64071. * Defines an optimization used to turn render targets off
  64072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64073. */
  64074. export class RenderTargetsOptimization extends SceneOptimization {
  64075. /**
  64076. * Gets a string describing the action executed by the current optimization
  64077. * @return description string
  64078. */
  64079. getDescription(): string;
  64080. /**
  64081. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64082. * @param scene defines the current scene where to apply this optimization
  64083. * @param optimizer defines the current optimizer
  64084. * @returns true if everything that can be done was applied
  64085. */
  64086. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64087. }
  64088. /**
  64089. * Defines an optimization used to merge meshes with compatible materials
  64090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64091. */
  64092. export class MergeMeshesOptimization extends SceneOptimization {
  64093. private static _UpdateSelectionTree;
  64094. /**
  64095. * Gets or sets a boolean which defines if optimization octree has to be updated
  64096. */
  64097. /**
  64098. * Gets or sets a boolean which defines if optimization octree has to be updated
  64099. */
  64100. static UpdateSelectionTree: boolean;
  64101. /**
  64102. * Gets a string describing the action executed by the current optimization
  64103. * @return description string
  64104. */
  64105. getDescription(): string;
  64106. private _canBeMerged;
  64107. /**
  64108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64109. * @param scene defines the current scene where to apply this optimization
  64110. * @param optimizer defines the current optimizer
  64111. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64112. * @returns true if everything that can be done was applied
  64113. */
  64114. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64115. }
  64116. /**
  64117. * Defines a list of options used by SceneOptimizer
  64118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64119. */
  64120. export class SceneOptimizerOptions {
  64121. /**
  64122. * Defines the target frame rate to reach (60 by default)
  64123. */
  64124. targetFrameRate: number;
  64125. /**
  64126. * Defines the interval between two checkes (2000ms by default)
  64127. */
  64128. trackerDuration: number;
  64129. /**
  64130. * Gets the list of optimizations to apply
  64131. */
  64132. optimizations: SceneOptimization[];
  64133. /**
  64134. * Creates a new list of options used by SceneOptimizer
  64135. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64136. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64137. */
  64138. constructor(
  64139. /**
  64140. * Defines the target frame rate to reach (60 by default)
  64141. */
  64142. targetFrameRate?: number,
  64143. /**
  64144. * Defines the interval between two checkes (2000ms by default)
  64145. */
  64146. trackerDuration?: number);
  64147. /**
  64148. * Add a new optimization
  64149. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64150. * @returns the current SceneOptimizerOptions
  64151. */
  64152. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64153. /**
  64154. * Add a new custom optimization
  64155. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64156. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64157. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64158. * @returns the current SceneOptimizerOptions
  64159. */
  64160. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64161. /**
  64162. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64163. * @param targetFrameRate defines the target frame rate (60 by default)
  64164. * @returns a SceneOptimizerOptions object
  64165. */
  64166. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64167. /**
  64168. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64169. * @param targetFrameRate defines the target frame rate (60 by default)
  64170. * @returns a SceneOptimizerOptions object
  64171. */
  64172. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64173. /**
  64174. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64175. * @param targetFrameRate defines the target frame rate (60 by default)
  64176. * @returns a SceneOptimizerOptions object
  64177. */
  64178. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64179. }
  64180. /**
  64181. * Class used to run optimizations in order to reach a target frame rate
  64182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64183. */
  64184. export class SceneOptimizer implements IDisposable {
  64185. private _isRunning;
  64186. private _options;
  64187. private _scene;
  64188. private _currentPriorityLevel;
  64189. private _targetFrameRate;
  64190. private _trackerDuration;
  64191. private _currentFrameRate;
  64192. private _sceneDisposeObserver;
  64193. private _improvementMode;
  64194. /**
  64195. * Defines an observable called when the optimizer reaches the target frame rate
  64196. */
  64197. onSuccessObservable: Observable<SceneOptimizer>;
  64198. /**
  64199. * Defines an observable called when the optimizer enables an optimization
  64200. */
  64201. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64202. /**
  64203. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64204. */
  64205. onFailureObservable: Observable<SceneOptimizer>;
  64206. /**
  64207. * Gets a boolean indicating if the optimizer is in improvement mode
  64208. */
  64209. readonly isInImprovementMode: boolean;
  64210. /**
  64211. * Gets the current priority level (0 at start)
  64212. */
  64213. readonly currentPriorityLevel: number;
  64214. /**
  64215. * Gets the current frame rate checked by the SceneOptimizer
  64216. */
  64217. readonly currentFrameRate: number;
  64218. /**
  64219. * Gets or sets the current target frame rate (60 by default)
  64220. */
  64221. /**
  64222. * Gets or sets the current target frame rate (60 by default)
  64223. */
  64224. targetFrameRate: number;
  64225. /**
  64226. * Gets or sets the current interval between two checks (every 2000ms by default)
  64227. */
  64228. /**
  64229. * Gets or sets the current interval between two checks (every 2000ms by default)
  64230. */
  64231. trackerDuration: number;
  64232. /**
  64233. * Gets the list of active optimizations
  64234. */
  64235. readonly optimizations: SceneOptimization[];
  64236. /**
  64237. * Creates a new SceneOptimizer
  64238. * @param scene defines the scene to work on
  64239. * @param options defines the options to use with the SceneOptimizer
  64240. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64241. * @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)
  64242. */
  64243. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64244. /**
  64245. * Stops the current optimizer
  64246. */
  64247. stop(): void;
  64248. /**
  64249. * Reset the optimizer to initial step (current priority level = 0)
  64250. */
  64251. reset(): void;
  64252. /**
  64253. * Start the optimizer. By default it will try to reach a specific framerate
  64254. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64255. */
  64256. start(): void;
  64257. private _checkCurrentState;
  64258. /**
  64259. * Release all resources
  64260. */
  64261. dispose(): void;
  64262. /**
  64263. * Helper function to create a SceneOptimizer with one single line of code
  64264. * @param scene defines the scene to work on
  64265. * @param options defines the options to use with the SceneOptimizer
  64266. * @param onSuccess defines a callback to call on success
  64267. * @param onFailure defines a callback to call on failure
  64268. * @returns the new SceneOptimizer object
  64269. */
  64270. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64271. }
  64272. }
  64273. declare module "babylonjs/Misc/sceneSerializer" {
  64274. import { Scene } from "babylonjs/scene";
  64275. /**
  64276. * Class used to serialize a scene into a string
  64277. */
  64278. export class SceneSerializer {
  64279. /**
  64280. * Clear cache used by a previous serialization
  64281. */
  64282. static ClearCache(): void;
  64283. /**
  64284. * Serialize a scene into a JSON compatible object
  64285. * @param scene defines the scene to serialize
  64286. * @returns a JSON compatible object
  64287. */
  64288. static Serialize(scene: Scene): any;
  64289. /**
  64290. * Serialize a mesh into a JSON compatible object
  64291. * @param toSerialize defines the mesh to serialize
  64292. * @param withParents defines if parents must be serialized as well
  64293. * @param withChildren defines if children must be serialized as well
  64294. * @returns a JSON compatible object
  64295. */
  64296. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64297. }
  64298. }
  64299. declare module "babylonjs/Misc/textureTools" {
  64300. import { Texture } from "babylonjs/Materials/Textures/texture";
  64301. /**
  64302. * Class used to host texture specific utilities
  64303. */
  64304. export class TextureTools {
  64305. /**
  64306. * Uses the GPU to create a copy texture rescaled at a given size
  64307. * @param texture Texture to copy from
  64308. * @param width defines the desired width
  64309. * @param height defines the desired height
  64310. * @param useBilinearMode defines if bilinear mode has to be used
  64311. * @return the generated texture
  64312. */
  64313. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64314. }
  64315. }
  64316. declare module "babylonjs/Misc/videoRecorder" {
  64317. import { Nullable } from "babylonjs/types";
  64318. import { Engine } from "babylonjs/Engines/engine";
  64319. /**
  64320. * This represents the different options available for the video capture.
  64321. */
  64322. export interface VideoRecorderOptions {
  64323. /** Defines the mime type of the video. */
  64324. mimeType: string;
  64325. /** Defines the FPS the video should be recorded at. */
  64326. fps: number;
  64327. /** Defines the chunk size for the recording data. */
  64328. recordChunckSize: number;
  64329. /** The audio tracks to attach to the recording. */
  64330. audioTracks?: MediaStreamTrack[];
  64331. }
  64332. /**
  64333. * This can help with recording videos from BabylonJS.
  64334. * This is based on the available WebRTC functionalities of the browser.
  64335. *
  64336. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64337. */
  64338. export class VideoRecorder {
  64339. private static readonly _defaultOptions;
  64340. /**
  64341. * Returns whether or not the VideoRecorder is available in your browser.
  64342. * @param engine Defines the Babylon Engine.
  64343. * @returns true if supported otherwise false.
  64344. */
  64345. static IsSupported(engine: Engine): boolean;
  64346. private readonly _options;
  64347. private _canvas;
  64348. private _mediaRecorder;
  64349. private _recordedChunks;
  64350. private _fileName;
  64351. private _resolve;
  64352. private _reject;
  64353. /**
  64354. * True when a recording is already in progress.
  64355. */
  64356. readonly isRecording: boolean;
  64357. /**
  64358. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64359. * @param engine Defines the BabylonJS Engine you wish to record.
  64360. * @param options Defines options that can be used to customize the capture.
  64361. */
  64362. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64363. /**
  64364. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64365. */
  64366. stopRecording(): void;
  64367. /**
  64368. * Starts recording the canvas for a max duration specified in parameters.
  64369. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64370. * If null no automatic download will start and you can rely on the promise to get the data back.
  64371. * @param maxDuration Defines the maximum recording time in seconds.
  64372. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64373. * @return A promise callback at the end of the recording with the video data in Blob.
  64374. */
  64375. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64376. /**
  64377. * Releases internal resources used during the recording.
  64378. */
  64379. dispose(): void;
  64380. private _handleDataAvailable;
  64381. private _handleError;
  64382. private _handleStop;
  64383. }
  64384. }
  64385. declare module "babylonjs/Misc/screenshotTools" {
  64386. import { Camera } from "babylonjs/Cameras/camera";
  64387. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64388. import { Engine } from "babylonjs/Engines/engine";
  64389. /**
  64390. * Class containing a set of static utilities functions for screenshots
  64391. */
  64392. export class ScreenshotTools {
  64393. /**
  64394. * Captures a screenshot of the current rendering
  64395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64396. * @param engine defines the rendering engine
  64397. * @param camera defines the source camera
  64398. * @param size This parameter can be set to a single number or to an object with the
  64399. * following (optional) properties: precision, width, height. If a single number is passed,
  64400. * it will be used for both width and height. If an object is passed, the screenshot size
  64401. * will be derived from the parameters. The precision property is a multiplier allowing
  64402. * rendering at a higher or lower resolution
  64403. * @param successCallback defines the callback receives a single parameter which contains the
  64404. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64405. * src parameter of an <img> to display it
  64406. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64407. * Check your browser for supported MIME types
  64408. */
  64409. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64410. /**
  64411. * Captures a screenshot of the current rendering
  64412. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64413. * @param engine defines the rendering engine
  64414. * @param camera defines the source camera
  64415. * @param size This parameter can be set to a single number or to an object with the
  64416. * following (optional) properties: precision, width, height. If a single number is passed,
  64417. * it will be used for both width and height. If an object is passed, the screenshot size
  64418. * will be derived from the parameters. The precision property is a multiplier allowing
  64419. * rendering at a higher or lower resolution
  64420. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64421. * Check your browser for supported MIME types
  64422. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64423. * to the src parameter of an <img> to display it
  64424. */
  64425. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64426. /**
  64427. * Generates an image screenshot from the specified camera.
  64428. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64429. * @param engine The engine to use for rendering
  64430. * @param camera The camera to use for rendering
  64431. * @param size This parameter can be set to a single number or to an object with the
  64432. * following (optional) properties: precision, width, height. If a single number is passed,
  64433. * it will be used for both width and height. If an object is passed, the screenshot size
  64434. * will be derived from the parameters. The precision property is a multiplier allowing
  64435. * rendering at a higher or lower resolution
  64436. * @param successCallback The callback receives a single parameter which contains the
  64437. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64438. * src parameter of an <img> to display it
  64439. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64440. * Check your browser for supported MIME types
  64441. * @param samples Texture samples (default: 1)
  64442. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64443. * @param fileName A name for for the downloaded file.
  64444. */
  64445. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64446. /**
  64447. * Generates an image screenshot from the specified camera.
  64448. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64449. * @param engine The engine to use for rendering
  64450. * @param camera The camera to use for rendering
  64451. * @param size This parameter can be set to a single number or to an object with the
  64452. * following (optional) properties: precision, width, height. If a single number is passed,
  64453. * it will be used for both width and height. If an object is passed, the screenshot size
  64454. * will be derived from the parameters. The precision property is a multiplier allowing
  64455. * rendering at a higher or lower resolution
  64456. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64457. * Check your browser for supported MIME types
  64458. * @param samples Texture samples (default: 1)
  64459. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64460. * @param fileName A name for for the downloaded file.
  64461. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64462. * to the src parameter of an <img> to display it
  64463. */
  64464. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64465. /**
  64466. * Gets height and width for screenshot size
  64467. * @private
  64468. */
  64469. private static _getScreenshotSize;
  64470. }
  64471. }
  64472. declare module "babylonjs/Misc/index" {
  64473. export * from "babylonjs/Misc/andOrNotEvaluator";
  64474. export * from "babylonjs/Misc/assetsManager";
  64475. export * from "babylonjs/Misc/dds";
  64476. export * from "babylonjs/Misc/decorators";
  64477. export * from "babylonjs/Misc/deferred";
  64478. export * from "babylonjs/Misc/environmentTextureTools";
  64479. export * from "babylonjs/Misc/meshExploder";
  64480. export * from "babylonjs/Misc/filesInput";
  64481. export * from "babylonjs/Misc/HighDynamicRange/index";
  64482. export * from "babylonjs/Misc/khronosTextureContainer";
  64483. export * from "babylonjs/Misc/observable";
  64484. export * from "babylonjs/Misc/performanceMonitor";
  64485. export * from "babylonjs/Misc/promise";
  64486. export * from "babylonjs/Misc/sceneOptimizer";
  64487. export * from "babylonjs/Misc/sceneSerializer";
  64488. export * from "babylonjs/Misc/smartArray";
  64489. export * from "babylonjs/Misc/stringDictionary";
  64490. export * from "babylonjs/Misc/tags";
  64491. export * from "babylonjs/Misc/textureTools";
  64492. export * from "babylonjs/Misc/tga";
  64493. export * from "babylonjs/Misc/tools";
  64494. export * from "babylonjs/Misc/videoRecorder";
  64495. export * from "babylonjs/Misc/virtualJoystick";
  64496. export * from "babylonjs/Misc/workerPool";
  64497. export * from "babylonjs/Misc/logger";
  64498. export * from "babylonjs/Misc/typeStore";
  64499. export * from "babylonjs/Misc/filesInputStore";
  64500. export * from "babylonjs/Misc/deepCopier";
  64501. export * from "babylonjs/Misc/pivotTools";
  64502. export * from "babylonjs/Misc/precisionDate";
  64503. export * from "babylonjs/Misc/screenshotTools";
  64504. export * from "babylonjs/Misc/typeStore";
  64505. export * from "babylonjs/Misc/webRequest";
  64506. export * from "babylonjs/Misc/iInspectable";
  64507. export * from "babylonjs/Misc/brdfTextureTools";
  64508. export * from "babylonjs/Misc/gradients";
  64509. export * from "babylonjs/Misc/perfCounter";
  64510. export * from "babylonjs/Misc/fileRequest";
  64511. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64512. export * from "babylonjs/Misc/retryStrategy";
  64513. export * from "babylonjs/Misc/loadFileError";
  64514. }
  64515. declare module "babylonjs/index" {
  64516. export * from "babylonjs/abstractScene";
  64517. export * from "babylonjs/Actions/index";
  64518. export * from "babylonjs/Animations/index";
  64519. export * from "babylonjs/assetContainer";
  64520. export * from "babylonjs/Audio/index";
  64521. export * from "babylonjs/Behaviors/index";
  64522. export * from "babylonjs/Bones/index";
  64523. export * from "babylonjs/Cameras/index";
  64524. export * from "babylonjs/Collisions/index";
  64525. export * from "babylonjs/Culling/index";
  64526. export * from "babylonjs/Debug/index";
  64527. export * from "babylonjs/Engines/index";
  64528. export * from "babylonjs/Events/index";
  64529. export * from "babylonjs/Gamepads/index";
  64530. export * from "babylonjs/Gizmos/index";
  64531. export * from "babylonjs/Helpers/index";
  64532. export * from "babylonjs/Instrumentation/index";
  64533. export * from "babylonjs/Layers/index";
  64534. export * from "babylonjs/LensFlares/index";
  64535. export * from "babylonjs/Lights/index";
  64536. export * from "babylonjs/Loading/index";
  64537. export * from "babylonjs/Materials/index";
  64538. export * from "babylonjs/Maths/index";
  64539. export * from "babylonjs/Meshes/index";
  64540. export * from "babylonjs/Morph/index";
  64541. export * from "babylonjs/Navigation/index";
  64542. export * from "babylonjs/node";
  64543. export * from "babylonjs/Offline/index";
  64544. export * from "babylonjs/Particles/index";
  64545. export * from "babylonjs/Physics/index";
  64546. export * from "babylonjs/PostProcesses/index";
  64547. export * from "babylonjs/Probes/index";
  64548. export * from "babylonjs/Rendering/index";
  64549. export * from "babylonjs/scene";
  64550. export * from "babylonjs/sceneComponent";
  64551. export * from "babylonjs/Sprites/index";
  64552. export * from "babylonjs/States/index";
  64553. export * from "babylonjs/Misc/index";
  64554. export * from "babylonjs/types";
  64555. }
  64556. declare module "babylonjs/Animations/pathCursor" {
  64557. import { Vector3 } from "babylonjs/Maths/math.vector";
  64558. import { Path2 } from "babylonjs/Maths/math.path";
  64559. /**
  64560. * A cursor which tracks a point on a path
  64561. */
  64562. export class PathCursor {
  64563. private path;
  64564. /**
  64565. * Stores path cursor callbacks for when an onchange event is triggered
  64566. */
  64567. private _onchange;
  64568. /**
  64569. * The value of the path cursor
  64570. */
  64571. value: number;
  64572. /**
  64573. * The animation array of the path cursor
  64574. */
  64575. animations: Animation[];
  64576. /**
  64577. * Initializes the path cursor
  64578. * @param path The path to track
  64579. */
  64580. constructor(path: Path2);
  64581. /**
  64582. * Gets the cursor point on the path
  64583. * @returns A point on the path cursor at the cursor location
  64584. */
  64585. getPoint(): Vector3;
  64586. /**
  64587. * Moves the cursor ahead by the step amount
  64588. * @param step The amount to move the cursor forward
  64589. * @returns This path cursor
  64590. */
  64591. moveAhead(step?: number): PathCursor;
  64592. /**
  64593. * Moves the cursor behind by the step amount
  64594. * @param step The amount to move the cursor back
  64595. * @returns This path cursor
  64596. */
  64597. moveBack(step?: number): PathCursor;
  64598. /**
  64599. * Moves the cursor by the step amount
  64600. * If the step amount is greater than one, an exception is thrown
  64601. * @param step The amount to move the cursor
  64602. * @returns This path cursor
  64603. */
  64604. move(step: number): PathCursor;
  64605. /**
  64606. * Ensures that the value is limited between zero and one
  64607. * @returns This path cursor
  64608. */
  64609. private ensureLimits;
  64610. /**
  64611. * Runs onchange callbacks on change (used by the animation engine)
  64612. * @returns This path cursor
  64613. */
  64614. private raiseOnChange;
  64615. /**
  64616. * Executes a function on change
  64617. * @param f A path cursor onchange callback
  64618. * @returns This path cursor
  64619. */
  64620. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64621. }
  64622. }
  64623. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64624. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64625. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64626. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64627. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64628. }
  64629. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64630. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64631. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64632. }
  64633. declare module "babylonjs/Engines/Processors/index" {
  64634. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64635. export * from "babylonjs/Engines/Processors/Expressions/index";
  64636. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64637. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64638. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64639. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64640. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64641. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64642. }
  64643. declare module "babylonjs/Legacy/legacy" {
  64644. import * as Babylon from "babylonjs/index";
  64645. export * from "babylonjs/index";
  64646. }
  64647. declare module "babylonjs/Shaders/blur.fragment" {
  64648. /** @hidden */
  64649. export var blurPixelShader: {
  64650. name: string;
  64651. shader: string;
  64652. };
  64653. }
  64654. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64655. /** @hidden */
  64656. export var pointCloudVertexDeclaration: {
  64657. name: string;
  64658. shader: string;
  64659. };
  64660. }
  64661. declare module "babylonjs" {
  64662. export * from "babylonjs/Legacy/legacy";
  64663. }
  64664. declare module BABYLON {
  64665. /** Alias type for value that can be null */
  64666. export type Nullable<T> = T | null;
  64667. /**
  64668. * Alias type for number that are floats
  64669. * @ignorenaming
  64670. */
  64671. export type float = number;
  64672. /**
  64673. * Alias type for number that are doubles.
  64674. * @ignorenaming
  64675. */
  64676. export type double = number;
  64677. /**
  64678. * Alias type for number that are integer
  64679. * @ignorenaming
  64680. */
  64681. export type int = number;
  64682. /** Alias type for number array or Float32Array */
  64683. export type FloatArray = number[] | Float32Array;
  64684. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64685. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64686. /**
  64687. * Alias for types that can be used by a Buffer or VertexBuffer.
  64688. */
  64689. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64690. /**
  64691. * Alias type for primitive types
  64692. * @ignorenaming
  64693. */
  64694. type Primitive = undefined | null | boolean | string | number | Function;
  64695. /**
  64696. * Type modifier to make all the properties of an object Readonly
  64697. */
  64698. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64699. /**
  64700. * Type modifier to make all the properties of an object Readonly recursively
  64701. */
  64702. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64703. /** @hidden */
  64704. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64705. }
  64706. /** @hidden */
  64707. /** @hidden */
  64708. type DeepImmutableObject<T> = {
  64709. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64710. };
  64711. }
  64712. declare module BABYLON {
  64713. /**
  64714. * A class serves as a medium between the observable and its observers
  64715. */
  64716. export class EventState {
  64717. /**
  64718. * Create a new EventState
  64719. * @param mask defines the mask associated with this state
  64720. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64721. * @param target defines the original target of the state
  64722. * @param currentTarget defines the current target of the state
  64723. */
  64724. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64725. /**
  64726. * Initialize the current event state
  64727. * @param mask defines the mask associated with this state
  64728. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64729. * @param target defines the original target of the state
  64730. * @param currentTarget defines the current target of the state
  64731. * @returns the current event state
  64732. */
  64733. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64734. /**
  64735. * An Observer can set this property to true to prevent subsequent observers of being notified
  64736. */
  64737. skipNextObservers: boolean;
  64738. /**
  64739. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64740. */
  64741. mask: number;
  64742. /**
  64743. * The object that originally notified the event
  64744. */
  64745. target?: any;
  64746. /**
  64747. * The current object in the bubbling phase
  64748. */
  64749. currentTarget?: any;
  64750. /**
  64751. * This will be populated with the return value of the last function that was executed.
  64752. * If it is the first function in the callback chain it will be the event data.
  64753. */
  64754. lastReturnValue?: any;
  64755. }
  64756. /**
  64757. * Represent an Observer registered to a given Observable object.
  64758. */
  64759. export class Observer<T> {
  64760. /**
  64761. * Defines the callback to call when the observer is notified
  64762. */
  64763. callback: (eventData: T, eventState: EventState) => void;
  64764. /**
  64765. * Defines the mask of the observer (used to filter notifications)
  64766. */
  64767. mask: number;
  64768. /**
  64769. * Defines the current scope used to restore the JS context
  64770. */
  64771. scope: any;
  64772. /** @hidden */
  64773. _willBeUnregistered: boolean;
  64774. /**
  64775. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64776. */
  64777. unregisterOnNextCall: boolean;
  64778. /**
  64779. * Creates a new observer
  64780. * @param callback defines the callback to call when the observer is notified
  64781. * @param mask defines the mask of the observer (used to filter notifications)
  64782. * @param scope defines the current scope used to restore the JS context
  64783. */
  64784. constructor(
  64785. /**
  64786. * Defines the callback to call when the observer is notified
  64787. */
  64788. callback: (eventData: T, eventState: EventState) => void,
  64789. /**
  64790. * Defines the mask of the observer (used to filter notifications)
  64791. */
  64792. mask: number,
  64793. /**
  64794. * Defines the current scope used to restore the JS context
  64795. */
  64796. scope?: any);
  64797. }
  64798. /**
  64799. * Represent a list of observers registered to multiple Observables object.
  64800. */
  64801. export class MultiObserver<T> {
  64802. private _observers;
  64803. private _observables;
  64804. /**
  64805. * Release associated resources
  64806. */
  64807. dispose(): void;
  64808. /**
  64809. * Raise a callback when one of the observable will notify
  64810. * @param observables defines a list of observables to watch
  64811. * @param callback defines the callback to call on notification
  64812. * @param mask defines the mask used to filter notifications
  64813. * @param scope defines the current scope used to restore the JS context
  64814. * @returns the new MultiObserver
  64815. */
  64816. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64817. }
  64818. /**
  64819. * The Observable class is a simple implementation of the Observable pattern.
  64820. *
  64821. * 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.
  64822. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64823. * 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).
  64824. * 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.
  64825. */
  64826. export class Observable<T> {
  64827. private _observers;
  64828. private _eventState;
  64829. private _onObserverAdded;
  64830. /**
  64831. * Gets the list of observers
  64832. */
  64833. readonly observers: Array<Observer<T>>;
  64834. /**
  64835. * Creates a new observable
  64836. * @param onObserverAdded defines a callback to call when a new observer is added
  64837. */
  64838. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64839. /**
  64840. * Create a new Observer with the specified callback
  64841. * @param callback the callback that will be executed for that Observer
  64842. * @param mask the mask used to filter observers
  64843. * @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.
  64844. * @param scope optional scope for the callback to be called from
  64845. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64846. * @returns the new observer created for the callback
  64847. */
  64848. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64849. /**
  64850. * Create a new Observer with the specified callback and unregisters after the next notification
  64851. * @param callback the callback that will be executed for that Observer
  64852. * @returns the new observer created for the callback
  64853. */
  64854. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64855. /**
  64856. * Remove an Observer from the Observable object
  64857. * @param observer the instance of the Observer to remove
  64858. * @returns false if it doesn't belong to this Observable
  64859. */
  64860. remove(observer: Nullable<Observer<T>>): boolean;
  64861. /**
  64862. * Remove a callback from the Observable object
  64863. * @param callback the callback to remove
  64864. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64865. * @returns false if it doesn't belong to this Observable
  64866. */
  64867. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64868. private _deferUnregister;
  64869. private _remove;
  64870. /**
  64871. * Moves the observable to the top of the observer list making it get called first when notified
  64872. * @param observer the observer to move
  64873. */
  64874. makeObserverTopPriority(observer: Observer<T>): void;
  64875. /**
  64876. * Moves the observable to the bottom of the observer list making it get called last when notified
  64877. * @param observer the observer to move
  64878. */
  64879. makeObserverBottomPriority(observer: Observer<T>): void;
  64880. /**
  64881. * Notify all Observers by calling their respective callback with the given data
  64882. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64883. * @param eventData defines the data to send to all observers
  64884. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64885. * @param target defines the original target of the state
  64886. * @param currentTarget defines the current target of the state
  64887. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64888. */
  64889. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64890. /**
  64891. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64892. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64893. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64894. * and it is crucial that all callbacks will be executed.
  64895. * The order of the callbacks is kept, callbacks are not executed parallel.
  64896. *
  64897. * @param eventData The data to be sent to each callback
  64898. * @param mask is used to filter observers defaults to -1
  64899. * @param target defines the callback target (see EventState)
  64900. * @param currentTarget defines he current object in the bubbling phase
  64901. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64902. */
  64903. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64904. /**
  64905. * Notify a specific observer
  64906. * @param observer defines the observer to notify
  64907. * @param eventData defines the data to be sent to each callback
  64908. * @param mask is used to filter observers defaults to -1
  64909. */
  64910. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64911. /**
  64912. * Gets a boolean indicating if the observable has at least one observer
  64913. * @returns true is the Observable has at least one Observer registered
  64914. */
  64915. hasObservers(): boolean;
  64916. /**
  64917. * Clear the list of observers
  64918. */
  64919. clear(): void;
  64920. /**
  64921. * Clone the current observable
  64922. * @returns a new observable
  64923. */
  64924. clone(): Observable<T>;
  64925. /**
  64926. * Does this observable handles observer registered with a given mask
  64927. * @param mask defines the mask to be tested
  64928. * @return whether or not one observer registered with the given mask is handeled
  64929. **/
  64930. hasSpecificMask(mask?: number): boolean;
  64931. }
  64932. }
  64933. declare module BABYLON {
  64934. /**
  64935. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64936. * Babylon.js
  64937. */
  64938. export class DomManagement {
  64939. /**
  64940. * Checks if the window object exists
  64941. * @returns true if the window object exists
  64942. */
  64943. static IsWindowObjectExist(): boolean;
  64944. /**
  64945. * Extracts text content from a DOM element hierarchy
  64946. * @param element defines the root element
  64947. * @returns a string
  64948. */
  64949. static GetDOMTextContent(element: HTMLElement): string;
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /**
  64954. * Logger used througouht the application to allow configuration of
  64955. * the log level required for the messages.
  64956. */
  64957. export class Logger {
  64958. /**
  64959. * No log
  64960. */
  64961. static readonly NoneLogLevel: number;
  64962. /**
  64963. * Only message logs
  64964. */
  64965. static readonly MessageLogLevel: number;
  64966. /**
  64967. * Only warning logs
  64968. */
  64969. static readonly WarningLogLevel: number;
  64970. /**
  64971. * Only error logs
  64972. */
  64973. static readonly ErrorLogLevel: number;
  64974. /**
  64975. * All logs
  64976. */
  64977. static readonly AllLogLevel: number;
  64978. private static _LogCache;
  64979. /**
  64980. * Gets a value indicating the number of loading errors
  64981. * @ignorenaming
  64982. */
  64983. static errorsCount: number;
  64984. /**
  64985. * Callback called when a new log is added
  64986. */
  64987. static OnNewCacheEntry: (entry: string) => void;
  64988. private static _AddLogEntry;
  64989. private static _FormatMessage;
  64990. private static _LogDisabled;
  64991. private static _LogEnabled;
  64992. private static _WarnDisabled;
  64993. private static _WarnEnabled;
  64994. private static _ErrorDisabled;
  64995. private static _ErrorEnabled;
  64996. /**
  64997. * Log a message to the console
  64998. */
  64999. static Log: (message: string) => void;
  65000. /**
  65001. * Write a warning message to the console
  65002. */
  65003. static Warn: (message: string) => void;
  65004. /**
  65005. * Write an error message to the console
  65006. */
  65007. static Error: (message: string) => void;
  65008. /**
  65009. * Gets current log cache (list of logs)
  65010. */
  65011. static readonly LogCache: string;
  65012. /**
  65013. * Clears the log cache
  65014. */
  65015. static ClearLogCache(): void;
  65016. /**
  65017. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65018. */
  65019. static LogLevels: number;
  65020. }
  65021. }
  65022. declare module BABYLON {
  65023. /** @hidden */
  65024. export class _TypeStore {
  65025. /** @hidden */
  65026. static RegisteredTypes: {
  65027. [key: string]: Object;
  65028. };
  65029. /** @hidden */
  65030. static GetClass(fqdn: string): any;
  65031. }
  65032. }
  65033. declare module BABYLON {
  65034. /**
  65035. * Class containing a set of static utilities functions for deep copy.
  65036. */
  65037. export class DeepCopier {
  65038. /**
  65039. * Tries to copy an object by duplicating every property
  65040. * @param source defines the source object
  65041. * @param destination defines the target object
  65042. * @param doNotCopyList defines a list of properties to avoid
  65043. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65044. */
  65045. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65046. }
  65047. }
  65048. declare module BABYLON {
  65049. /**
  65050. * Class containing a set of static utilities functions for precision date
  65051. */
  65052. export class PrecisionDate {
  65053. /**
  65054. * Gets either window.performance.now() if supported or Date.now() else
  65055. */
  65056. static readonly Now: number;
  65057. }
  65058. }
  65059. declare module BABYLON {
  65060. /** @hidden */
  65061. export class _DevTools {
  65062. static WarnImport(name: string): string;
  65063. }
  65064. }
  65065. declare module BABYLON {
  65066. /**
  65067. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65068. */
  65069. export class WebRequest {
  65070. private _xhr;
  65071. /**
  65072. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65073. * i.e. when loading files, where the server/service expects an Authorization header
  65074. */
  65075. static CustomRequestHeaders: {
  65076. [key: string]: string;
  65077. };
  65078. /**
  65079. * Add callback functions in this array to update all the requests before they get sent to the network
  65080. */
  65081. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65082. private _injectCustomRequestHeaders;
  65083. /**
  65084. * Gets or sets a function to be called when loading progress changes
  65085. */
  65086. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65087. /**
  65088. * Returns client's state
  65089. */
  65090. readonly readyState: number;
  65091. /**
  65092. * Returns client's status
  65093. */
  65094. readonly status: number;
  65095. /**
  65096. * Returns client's status as a text
  65097. */
  65098. readonly statusText: string;
  65099. /**
  65100. * Returns client's response
  65101. */
  65102. readonly response: any;
  65103. /**
  65104. * Returns client's response url
  65105. */
  65106. readonly responseURL: string;
  65107. /**
  65108. * Returns client's response as text
  65109. */
  65110. readonly responseText: string;
  65111. /**
  65112. * Gets or sets the expected response type
  65113. */
  65114. responseType: XMLHttpRequestResponseType;
  65115. /** @hidden */
  65116. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65117. /** @hidden */
  65118. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65119. /**
  65120. * Cancels any network activity
  65121. */
  65122. abort(): void;
  65123. /**
  65124. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65125. * @param body defines an optional request body
  65126. */
  65127. send(body?: Document | BodyInit | null): void;
  65128. /**
  65129. * Sets the request method, request URL
  65130. * @param method defines the method to use (GET, POST, etc..)
  65131. * @param url defines the url to connect with
  65132. */
  65133. open(method: string, url: string): void;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /**
  65138. * File request interface
  65139. */
  65140. export interface IFileRequest {
  65141. /**
  65142. * Raised when the request is complete (success or error).
  65143. */
  65144. onCompleteObservable: Observable<IFileRequest>;
  65145. /**
  65146. * Aborts the request for a file.
  65147. */
  65148. abort: () => void;
  65149. }
  65150. }
  65151. declare module BABYLON {
  65152. /**
  65153. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65154. */
  65155. export class PerformanceMonitor {
  65156. private _enabled;
  65157. private _rollingFrameTime;
  65158. private _lastFrameTimeMs;
  65159. /**
  65160. * constructor
  65161. * @param frameSampleSize The number of samples required to saturate the sliding window
  65162. */
  65163. constructor(frameSampleSize?: number);
  65164. /**
  65165. * Samples current frame
  65166. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65167. */
  65168. sampleFrame(timeMs?: number): void;
  65169. /**
  65170. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65171. */
  65172. readonly averageFrameTime: number;
  65173. /**
  65174. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65175. */
  65176. readonly averageFrameTimeVariance: number;
  65177. /**
  65178. * Returns the frame time of the most recent frame
  65179. */
  65180. readonly instantaneousFrameTime: number;
  65181. /**
  65182. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65183. */
  65184. readonly averageFPS: number;
  65185. /**
  65186. * Returns the average framerate in frames per second using the most recent frame time
  65187. */
  65188. readonly instantaneousFPS: number;
  65189. /**
  65190. * Returns true if enough samples have been taken to completely fill the sliding window
  65191. */
  65192. readonly isSaturated: boolean;
  65193. /**
  65194. * Enables contributions to the sliding window sample set
  65195. */
  65196. enable(): void;
  65197. /**
  65198. * Disables contributions to the sliding window sample set
  65199. * Samples will not be interpolated over the disabled period
  65200. */
  65201. disable(): void;
  65202. /**
  65203. * Returns true if sampling is enabled
  65204. */
  65205. readonly isEnabled: boolean;
  65206. /**
  65207. * Resets performance monitor
  65208. */
  65209. reset(): void;
  65210. }
  65211. /**
  65212. * RollingAverage
  65213. *
  65214. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65215. */
  65216. export class RollingAverage {
  65217. /**
  65218. * Current average
  65219. */
  65220. average: number;
  65221. /**
  65222. * Current variance
  65223. */
  65224. variance: number;
  65225. protected _samples: Array<number>;
  65226. protected _sampleCount: number;
  65227. protected _pos: number;
  65228. protected _m2: number;
  65229. /**
  65230. * constructor
  65231. * @param length The number of samples required to saturate the sliding window
  65232. */
  65233. constructor(length: number);
  65234. /**
  65235. * Adds a sample to the sample set
  65236. * @param v The sample value
  65237. */
  65238. add(v: number): void;
  65239. /**
  65240. * Returns previously added values or null if outside of history or outside the sliding window domain
  65241. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65242. * @return Value previously recorded with add() or null if outside of range
  65243. */
  65244. history(i: number): number;
  65245. /**
  65246. * Returns true if enough samples have been taken to completely fill the sliding window
  65247. * @return true if sample-set saturated
  65248. */
  65249. isSaturated(): boolean;
  65250. /**
  65251. * Resets the rolling average (equivalent to 0 samples taken so far)
  65252. */
  65253. reset(): void;
  65254. /**
  65255. * Wraps a value around the sample range boundaries
  65256. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65257. * @return Wrapped position in sample range
  65258. */
  65259. protected _wrapPosition(i: number): number;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /**
  65264. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65265. * The underlying implementation relies on an associative array to ensure the best performances.
  65266. * The value can be anything including 'null' but except 'undefined'
  65267. */
  65268. export class StringDictionary<T> {
  65269. /**
  65270. * This will clear this dictionary and copy the content from the 'source' one.
  65271. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65272. * @param source the dictionary to take the content from and copy to this dictionary
  65273. */
  65274. copyFrom(source: StringDictionary<T>): void;
  65275. /**
  65276. * Get a value based from its key
  65277. * @param key the given key to get the matching value from
  65278. * @return the value if found, otherwise undefined is returned
  65279. */
  65280. get(key: string): T | undefined;
  65281. /**
  65282. * Get a value from its key or add it if it doesn't exist.
  65283. * This method will ensure you that a given key/data will be present in the dictionary.
  65284. * @param key the given key to get the matching value from
  65285. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65286. * The factory will only be invoked if there's no data for the given key.
  65287. * @return the value corresponding to the key.
  65288. */
  65289. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65290. /**
  65291. * Get a value from its key if present in the dictionary otherwise add it
  65292. * @param key the key to get the value from
  65293. * @param val if there's no such key/value pair in the dictionary add it with this value
  65294. * @return the value corresponding to the key
  65295. */
  65296. getOrAdd(key: string, val: T): T;
  65297. /**
  65298. * Check if there's a given key in the dictionary
  65299. * @param key the key to check for
  65300. * @return true if the key is present, false otherwise
  65301. */
  65302. contains(key: string): boolean;
  65303. /**
  65304. * Add a new key and its corresponding value
  65305. * @param key the key to add
  65306. * @param value the value corresponding to the key
  65307. * @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
  65308. */
  65309. add(key: string, value: T): boolean;
  65310. /**
  65311. * Update a specific value associated to a key
  65312. * @param key defines the key to use
  65313. * @param value defines the value to store
  65314. * @returns true if the value was updated (or false if the key was not found)
  65315. */
  65316. set(key: string, value: T): boolean;
  65317. /**
  65318. * Get the element of the given key and remove it from the dictionary
  65319. * @param key defines the key to search
  65320. * @returns the value associated with the key or null if not found
  65321. */
  65322. getAndRemove(key: string): Nullable<T>;
  65323. /**
  65324. * Remove a key/value from the dictionary.
  65325. * @param key the key to remove
  65326. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65327. */
  65328. remove(key: string): boolean;
  65329. /**
  65330. * Clear the whole content of the dictionary
  65331. */
  65332. clear(): void;
  65333. /**
  65334. * Gets the current count
  65335. */
  65336. readonly count: number;
  65337. /**
  65338. * Execute a callback on each key/val of the dictionary.
  65339. * Note that you can remove any element in this dictionary in the callback implementation
  65340. * @param callback the callback to execute on a given key/value pair
  65341. */
  65342. forEach(callback: (key: string, val: T) => void): void;
  65343. /**
  65344. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65345. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65346. * Note that you can remove any element in this dictionary in the callback implementation
  65347. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65348. * @returns the first item
  65349. */
  65350. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65351. private _count;
  65352. private _data;
  65353. }
  65354. }
  65355. declare module BABYLON {
  65356. /**
  65357. * Class used to store gfx data (like WebGLBuffer)
  65358. */
  65359. export class DataBuffer {
  65360. /**
  65361. * Gets or sets the number of objects referencing this buffer
  65362. */
  65363. references: number;
  65364. /** Gets or sets the size of the underlying buffer */
  65365. capacity: number;
  65366. /**
  65367. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65368. */
  65369. is32Bits: boolean;
  65370. /**
  65371. * Gets the underlying buffer
  65372. */
  65373. readonly underlyingResource: any;
  65374. }
  65375. }
  65376. declare module BABYLON {
  65377. /**
  65378. * Class used to store data that will be store in GPU memory
  65379. */
  65380. export class Buffer {
  65381. private _engine;
  65382. private _buffer;
  65383. /** @hidden */
  65384. _data: Nullable<DataArray>;
  65385. private _updatable;
  65386. private _instanced;
  65387. /**
  65388. * Gets the byte stride.
  65389. */
  65390. readonly byteStride: number;
  65391. /**
  65392. * Constructor
  65393. * @param engine the engine
  65394. * @param data the data to use for this buffer
  65395. * @param updatable whether the data is updatable
  65396. * @param stride the stride (optional)
  65397. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65398. * @param instanced whether the buffer is instanced (optional)
  65399. * @param useBytes set to true if the stride in in bytes (optional)
  65400. */
  65401. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65402. /**
  65403. * Create a new VertexBuffer based on the current buffer
  65404. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65405. * @param offset defines offset in the buffer (0 by default)
  65406. * @param size defines the size in floats of attributes (position is 3 for instance)
  65407. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65408. * @param instanced defines if the vertex buffer contains indexed data
  65409. * @param useBytes defines if the offset and stride are in bytes
  65410. * @returns the new vertex buffer
  65411. */
  65412. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65413. /**
  65414. * Gets a boolean indicating if the Buffer is updatable?
  65415. * @returns true if the buffer is updatable
  65416. */
  65417. isUpdatable(): boolean;
  65418. /**
  65419. * Gets current buffer's data
  65420. * @returns a DataArray or null
  65421. */
  65422. getData(): Nullable<DataArray>;
  65423. /**
  65424. * Gets underlying native buffer
  65425. * @returns underlying native buffer
  65426. */
  65427. getBuffer(): Nullable<DataBuffer>;
  65428. /**
  65429. * Gets the stride in float32 units (i.e. byte stride / 4).
  65430. * May not be an integer if the byte stride is not divisible by 4.
  65431. * DEPRECATED. Use byteStride instead.
  65432. * @returns the stride in float32 units
  65433. */
  65434. getStrideSize(): number;
  65435. /**
  65436. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65437. * @param data defines the data to store
  65438. */
  65439. create(data?: Nullable<DataArray>): void;
  65440. /** @hidden */
  65441. _rebuild(): void;
  65442. /**
  65443. * Update current buffer data
  65444. * @param data defines the data to store
  65445. */
  65446. update(data: DataArray): void;
  65447. /**
  65448. * Updates the data directly.
  65449. * @param data the new data
  65450. * @param offset the new offset
  65451. * @param vertexCount the vertex count (optional)
  65452. * @param useBytes set to true if the offset is in bytes
  65453. */
  65454. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65455. /**
  65456. * Release all resources
  65457. */
  65458. dispose(): void;
  65459. }
  65460. /**
  65461. * Specialized buffer used to store vertex data
  65462. */
  65463. export class VertexBuffer {
  65464. /** @hidden */
  65465. _buffer: Buffer;
  65466. private _kind;
  65467. private _size;
  65468. private _ownsBuffer;
  65469. private _instanced;
  65470. private _instanceDivisor;
  65471. /**
  65472. * The byte type.
  65473. */
  65474. static readonly BYTE: number;
  65475. /**
  65476. * The unsigned byte type.
  65477. */
  65478. static readonly UNSIGNED_BYTE: number;
  65479. /**
  65480. * The short type.
  65481. */
  65482. static readonly SHORT: number;
  65483. /**
  65484. * The unsigned short type.
  65485. */
  65486. static readonly UNSIGNED_SHORT: number;
  65487. /**
  65488. * The integer type.
  65489. */
  65490. static readonly INT: number;
  65491. /**
  65492. * The unsigned integer type.
  65493. */
  65494. static readonly UNSIGNED_INT: number;
  65495. /**
  65496. * The float type.
  65497. */
  65498. static readonly FLOAT: number;
  65499. /**
  65500. * Gets or sets the instance divisor when in instanced mode
  65501. */
  65502. instanceDivisor: number;
  65503. /**
  65504. * Gets the byte stride.
  65505. */
  65506. readonly byteStride: number;
  65507. /**
  65508. * Gets the byte offset.
  65509. */
  65510. readonly byteOffset: number;
  65511. /**
  65512. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65513. */
  65514. readonly normalized: boolean;
  65515. /**
  65516. * Gets the data type of each component in the array.
  65517. */
  65518. readonly type: number;
  65519. /**
  65520. * Constructor
  65521. * @param engine the engine
  65522. * @param data the data to use for this vertex buffer
  65523. * @param kind the vertex buffer kind
  65524. * @param updatable whether the data is updatable
  65525. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65526. * @param stride the stride (optional)
  65527. * @param instanced whether the buffer is instanced (optional)
  65528. * @param offset the offset of the data (optional)
  65529. * @param size the number of components (optional)
  65530. * @param type the type of the component (optional)
  65531. * @param normalized whether the data contains normalized data (optional)
  65532. * @param useBytes set to true if stride and offset are in bytes (optional)
  65533. */
  65534. 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);
  65535. /** @hidden */
  65536. _rebuild(): void;
  65537. /**
  65538. * Returns the kind of the VertexBuffer (string)
  65539. * @returns a string
  65540. */
  65541. getKind(): string;
  65542. /**
  65543. * Gets a boolean indicating if the VertexBuffer is updatable?
  65544. * @returns true if the buffer is updatable
  65545. */
  65546. isUpdatable(): boolean;
  65547. /**
  65548. * Gets current buffer's data
  65549. * @returns a DataArray or null
  65550. */
  65551. getData(): Nullable<DataArray>;
  65552. /**
  65553. * Gets underlying native buffer
  65554. * @returns underlying native buffer
  65555. */
  65556. getBuffer(): Nullable<DataBuffer>;
  65557. /**
  65558. * Gets the stride in float32 units (i.e. byte stride / 4).
  65559. * May not be an integer if the byte stride is not divisible by 4.
  65560. * DEPRECATED. Use byteStride instead.
  65561. * @returns the stride in float32 units
  65562. */
  65563. getStrideSize(): number;
  65564. /**
  65565. * Returns the offset as a multiple of the type byte length.
  65566. * DEPRECATED. Use byteOffset instead.
  65567. * @returns the offset in bytes
  65568. */
  65569. getOffset(): number;
  65570. /**
  65571. * Returns the number of components per vertex attribute (integer)
  65572. * @returns the size in float
  65573. */
  65574. getSize(): number;
  65575. /**
  65576. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65577. * @returns true if this buffer is instanced
  65578. */
  65579. getIsInstanced(): boolean;
  65580. /**
  65581. * Returns the instancing divisor, zero for non-instanced (integer).
  65582. * @returns a number
  65583. */
  65584. getInstanceDivisor(): number;
  65585. /**
  65586. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65587. * @param data defines the data to store
  65588. */
  65589. create(data?: DataArray): void;
  65590. /**
  65591. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65592. * This function will create a new buffer if the current one is not updatable
  65593. * @param data defines the data to store
  65594. */
  65595. update(data: DataArray): void;
  65596. /**
  65597. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65598. * Returns the directly updated WebGLBuffer.
  65599. * @param data the new data
  65600. * @param offset the new offset
  65601. * @param useBytes set to true if the offset is in bytes
  65602. */
  65603. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65604. /**
  65605. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65606. */
  65607. dispose(): void;
  65608. /**
  65609. * Enumerates each value of this vertex buffer as numbers.
  65610. * @param count the number of values to enumerate
  65611. * @param callback the callback function called for each value
  65612. */
  65613. forEach(count: number, callback: (value: number, index: number) => void): void;
  65614. /**
  65615. * Positions
  65616. */
  65617. static readonly PositionKind: string;
  65618. /**
  65619. * Normals
  65620. */
  65621. static readonly NormalKind: string;
  65622. /**
  65623. * Tangents
  65624. */
  65625. static readonly TangentKind: string;
  65626. /**
  65627. * Texture coordinates
  65628. */
  65629. static readonly UVKind: string;
  65630. /**
  65631. * Texture coordinates 2
  65632. */
  65633. static readonly UV2Kind: string;
  65634. /**
  65635. * Texture coordinates 3
  65636. */
  65637. static readonly UV3Kind: string;
  65638. /**
  65639. * Texture coordinates 4
  65640. */
  65641. static readonly UV4Kind: string;
  65642. /**
  65643. * Texture coordinates 5
  65644. */
  65645. static readonly UV5Kind: string;
  65646. /**
  65647. * Texture coordinates 6
  65648. */
  65649. static readonly UV6Kind: string;
  65650. /**
  65651. * Colors
  65652. */
  65653. static readonly ColorKind: string;
  65654. /**
  65655. * Matrix indices (for bones)
  65656. */
  65657. static readonly MatricesIndicesKind: string;
  65658. /**
  65659. * Matrix weights (for bones)
  65660. */
  65661. static readonly MatricesWeightsKind: string;
  65662. /**
  65663. * Additional matrix indices (for bones)
  65664. */
  65665. static readonly MatricesIndicesExtraKind: string;
  65666. /**
  65667. * Additional matrix weights (for bones)
  65668. */
  65669. static readonly MatricesWeightsExtraKind: string;
  65670. /**
  65671. * Deduces the stride given a kind.
  65672. * @param kind The kind string to deduce
  65673. * @returns The deduced stride
  65674. */
  65675. static DeduceStride(kind: string): number;
  65676. /**
  65677. * Gets the byte length of the given type.
  65678. * @param type the type
  65679. * @returns the number of bytes
  65680. */
  65681. static GetTypeByteLength(type: number): number;
  65682. /**
  65683. * Enumerates each value of the given parameters as numbers.
  65684. * @param data the data to enumerate
  65685. * @param byteOffset the byte offset of the data
  65686. * @param byteStride the byte stride of the data
  65687. * @param componentCount the number of components per element
  65688. * @param componentType the type of the component
  65689. * @param count the number of values to enumerate
  65690. * @param normalized whether the data is normalized
  65691. * @param callback the callback function called for each value
  65692. */
  65693. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65694. private static _GetFloatValue;
  65695. }
  65696. }
  65697. declare module BABYLON {
  65698. /**
  65699. * Scalar computation library
  65700. */
  65701. export class Scalar {
  65702. /**
  65703. * Two pi constants convenient for computation.
  65704. */
  65705. static TwoPi: number;
  65706. /**
  65707. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65708. * @param a number
  65709. * @param b number
  65710. * @param epsilon (default = 1.401298E-45)
  65711. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65712. */
  65713. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65714. /**
  65715. * Returns a string : the upper case translation of the number i to hexadecimal.
  65716. * @param i number
  65717. * @returns the upper case translation of the number i to hexadecimal.
  65718. */
  65719. static ToHex(i: number): string;
  65720. /**
  65721. * Returns -1 if value is negative and +1 is value is positive.
  65722. * @param value the value
  65723. * @returns the value itself if it's equal to zero.
  65724. */
  65725. static Sign(value: number): number;
  65726. /**
  65727. * Returns the value itself if it's between min and max.
  65728. * Returns min if the value is lower than min.
  65729. * Returns max if the value is greater than max.
  65730. * @param value the value to clmap
  65731. * @param min the min value to clamp to (default: 0)
  65732. * @param max the max value to clamp to (default: 1)
  65733. * @returns the clamped value
  65734. */
  65735. static Clamp(value: number, min?: number, max?: number): number;
  65736. /**
  65737. * the log2 of value.
  65738. * @param value the value to compute log2 of
  65739. * @returns the log2 of value.
  65740. */
  65741. static Log2(value: number): number;
  65742. /**
  65743. * Loops the value, so that it is never larger than length and never smaller than 0.
  65744. *
  65745. * This is similar to the modulo operator but it works with floating point numbers.
  65746. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65747. * With t = 5 and length = 2.5, the result would be 0.0.
  65748. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65749. * @param value the value
  65750. * @param length the length
  65751. * @returns the looped value
  65752. */
  65753. static Repeat(value: number, length: number): number;
  65754. /**
  65755. * Normalize the value between 0.0 and 1.0 using min and max values
  65756. * @param value value to normalize
  65757. * @param min max to normalize between
  65758. * @param max min to normalize between
  65759. * @returns the normalized value
  65760. */
  65761. static Normalize(value: number, min: number, max: number): number;
  65762. /**
  65763. * Denormalize the value from 0.0 and 1.0 using min and max values
  65764. * @param normalized value to denormalize
  65765. * @param min max to denormalize between
  65766. * @param max min to denormalize between
  65767. * @returns the denormalized value
  65768. */
  65769. static Denormalize(normalized: number, min: number, max: number): number;
  65770. /**
  65771. * Calculates the shortest difference between two given angles given in degrees.
  65772. * @param current current angle in degrees
  65773. * @param target target angle in degrees
  65774. * @returns the delta
  65775. */
  65776. static DeltaAngle(current: number, target: number): number;
  65777. /**
  65778. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65779. * @param tx value
  65780. * @param length length
  65781. * @returns The returned value will move back and forth between 0 and length
  65782. */
  65783. static PingPong(tx: number, length: number): number;
  65784. /**
  65785. * Interpolates between min and max with smoothing at the limits.
  65786. *
  65787. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65788. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65789. * @param from from
  65790. * @param to to
  65791. * @param tx value
  65792. * @returns the smooth stepped value
  65793. */
  65794. static SmoothStep(from: number, to: number, tx: number): number;
  65795. /**
  65796. * Moves a value current towards target.
  65797. *
  65798. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65799. * Negative values of maxDelta pushes the value away from target.
  65800. * @param current current value
  65801. * @param target target value
  65802. * @param maxDelta max distance to move
  65803. * @returns resulting value
  65804. */
  65805. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65806. /**
  65807. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65808. *
  65809. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65810. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65811. * @param current current value
  65812. * @param target target value
  65813. * @param maxDelta max distance to move
  65814. * @returns resulting angle
  65815. */
  65816. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65817. /**
  65818. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65819. * @param start start value
  65820. * @param end target value
  65821. * @param amount amount to lerp between
  65822. * @returns the lerped value
  65823. */
  65824. static Lerp(start: number, end: number, amount: number): number;
  65825. /**
  65826. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65827. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65828. * @param start start value
  65829. * @param end target value
  65830. * @param amount amount to lerp between
  65831. * @returns the lerped value
  65832. */
  65833. static LerpAngle(start: number, end: number, amount: number): number;
  65834. /**
  65835. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65836. * @param a start value
  65837. * @param b target value
  65838. * @param value value between a and b
  65839. * @returns the inverseLerp value
  65840. */
  65841. static InverseLerp(a: number, b: number, value: number): number;
  65842. /**
  65843. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65844. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65845. * @param value1 spline value
  65846. * @param tangent1 spline value
  65847. * @param value2 spline value
  65848. * @param tangent2 spline value
  65849. * @param amount input value
  65850. * @returns hermite result
  65851. */
  65852. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65853. /**
  65854. * Returns a random float number between and min and max values
  65855. * @param min min value of random
  65856. * @param max max value of random
  65857. * @returns random value
  65858. */
  65859. static RandomRange(min: number, max: number): number;
  65860. /**
  65861. * This function returns percentage of a number in a given range.
  65862. *
  65863. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65864. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65865. * @param number to convert to percentage
  65866. * @param min min range
  65867. * @param max max range
  65868. * @returns the percentage
  65869. */
  65870. static RangeToPercent(number: number, min: number, max: number): number;
  65871. /**
  65872. * This function returns number that corresponds to the percentage in a given range.
  65873. *
  65874. * PercentToRange(0.34,0,100) will return 34.
  65875. * @param percent to convert to number
  65876. * @param min min range
  65877. * @param max max range
  65878. * @returns the number
  65879. */
  65880. static PercentToRange(percent: number, min: number, max: number): number;
  65881. /**
  65882. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65883. * @param angle The angle to normalize in radian.
  65884. * @return The converted angle.
  65885. */
  65886. static NormalizeRadians(angle: number): number;
  65887. }
  65888. }
  65889. declare module BABYLON {
  65890. /**
  65891. * Constant used to convert a value to gamma space
  65892. * @ignorenaming
  65893. */
  65894. export const ToGammaSpace: number;
  65895. /**
  65896. * Constant used to convert a value to linear space
  65897. * @ignorenaming
  65898. */
  65899. export const ToLinearSpace = 2.2;
  65900. /**
  65901. * Constant used to define the minimal number value in Babylon.js
  65902. * @ignorenaming
  65903. */
  65904. let Epsilon: number;
  65905. }
  65906. declare module BABYLON {
  65907. /**
  65908. * Class used to represent a viewport on screen
  65909. */
  65910. export class Viewport {
  65911. /** viewport left coordinate */
  65912. x: number;
  65913. /** viewport top coordinate */
  65914. y: number;
  65915. /**viewport width */
  65916. width: number;
  65917. /** viewport height */
  65918. height: number;
  65919. /**
  65920. * Creates a Viewport object located at (x, y) and sized (width, height)
  65921. * @param x defines viewport left coordinate
  65922. * @param y defines viewport top coordinate
  65923. * @param width defines the viewport width
  65924. * @param height defines the viewport height
  65925. */
  65926. constructor(
  65927. /** viewport left coordinate */
  65928. x: number,
  65929. /** viewport top coordinate */
  65930. y: number,
  65931. /**viewport width */
  65932. width: number,
  65933. /** viewport height */
  65934. height: number);
  65935. /**
  65936. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65937. * @param renderWidth defines the rendering width
  65938. * @param renderHeight defines the rendering height
  65939. * @returns a new Viewport
  65940. */
  65941. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65942. /**
  65943. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65944. * @param renderWidth defines the rendering width
  65945. * @param renderHeight defines the rendering height
  65946. * @param ref defines the target viewport
  65947. * @returns the current viewport
  65948. */
  65949. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65950. /**
  65951. * Returns a new Viewport copied from the current one
  65952. * @returns a new Viewport
  65953. */
  65954. clone(): Viewport;
  65955. }
  65956. }
  65957. declare module BABYLON {
  65958. /**
  65959. * Class containing a set of static utilities functions for arrays.
  65960. */
  65961. export class ArrayTools {
  65962. /**
  65963. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65964. * @param size the number of element to construct and put in the array
  65965. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65966. * @returns a new array filled with new objects
  65967. */
  65968. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65969. }
  65970. }
  65971. declare module BABYLON {
  65972. /**
  65973. * @hidden
  65974. */
  65975. export interface IColor4Like {
  65976. r: float;
  65977. g: float;
  65978. b: float;
  65979. a: float;
  65980. }
  65981. /**
  65982. * @hidden
  65983. */
  65984. export interface IColor3Like {
  65985. r: float;
  65986. g: float;
  65987. b: float;
  65988. }
  65989. /**
  65990. * @hidden
  65991. */
  65992. export interface IVector4Like {
  65993. x: float;
  65994. y: float;
  65995. z: float;
  65996. w: float;
  65997. }
  65998. /**
  65999. * @hidden
  66000. */
  66001. export interface IVector3Like {
  66002. x: float;
  66003. y: float;
  66004. z: float;
  66005. }
  66006. /**
  66007. * @hidden
  66008. */
  66009. export interface IVector2Like {
  66010. x: float;
  66011. y: float;
  66012. }
  66013. /**
  66014. * @hidden
  66015. */
  66016. export interface IMatrixLike {
  66017. toArray(): DeepImmutable<Float32Array>;
  66018. updateFlag: int;
  66019. }
  66020. /**
  66021. * @hidden
  66022. */
  66023. export interface IViewportLike {
  66024. x: float;
  66025. y: float;
  66026. width: float;
  66027. height: float;
  66028. }
  66029. /**
  66030. * @hidden
  66031. */
  66032. export interface IPlaneLike {
  66033. normal: IVector3Like;
  66034. d: float;
  66035. normalize(): void;
  66036. }
  66037. }
  66038. declare module BABYLON {
  66039. /**
  66040. * Class representing a vector containing 2 coordinates
  66041. */
  66042. export class Vector2 {
  66043. /** defines the first coordinate */
  66044. x: number;
  66045. /** defines the second coordinate */
  66046. y: number;
  66047. /**
  66048. * Creates a new Vector2 from the given x and y coordinates
  66049. * @param x defines the first coordinate
  66050. * @param y defines the second coordinate
  66051. */
  66052. constructor(
  66053. /** defines the first coordinate */
  66054. x?: number,
  66055. /** defines the second coordinate */
  66056. y?: number);
  66057. /**
  66058. * Gets a string with the Vector2 coordinates
  66059. * @returns a string with the Vector2 coordinates
  66060. */
  66061. toString(): string;
  66062. /**
  66063. * Gets class name
  66064. * @returns the string "Vector2"
  66065. */
  66066. getClassName(): string;
  66067. /**
  66068. * Gets current vector hash code
  66069. * @returns the Vector2 hash code as a number
  66070. */
  66071. getHashCode(): number;
  66072. /**
  66073. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66074. * @param array defines the source array
  66075. * @param index defines the offset in source array
  66076. * @returns the current Vector2
  66077. */
  66078. toArray(array: FloatArray, index?: number): Vector2;
  66079. /**
  66080. * Copy the current vector to an array
  66081. * @returns a new array with 2 elements: the Vector2 coordinates.
  66082. */
  66083. asArray(): number[];
  66084. /**
  66085. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66086. * @param source defines the source Vector2
  66087. * @returns the current updated Vector2
  66088. */
  66089. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66090. /**
  66091. * Sets the Vector2 coordinates with the given floats
  66092. * @param x defines the first coordinate
  66093. * @param y defines the second coordinate
  66094. * @returns the current updated Vector2
  66095. */
  66096. copyFromFloats(x: number, y: number): Vector2;
  66097. /**
  66098. * Sets the Vector2 coordinates with the given floats
  66099. * @param x defines the first coordinate
  66100. * @param y defines the second coordinate
  66101. * @returns the current updated Vector2
  66102. */
  66103. set(x: number, y: number): Vector2;
  66104. /**
  66105. * Add another vector with the current one
  66106. * @param otherVector defines the other vector
  66107. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66108. */
  66109. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66110. /**
  66111. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66112. * @param otherVector defines the other vector
  66113. * @param result defines the target vector
  66114. * @returns the unmodified current Vector2
  66115. */
  66116. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66117. /**
  66118. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66119. * @param otherVector defines the other vector
  66120. * @returns the current updated Vector2
  66121. */
  66122. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66123. /**
  66124. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66125. * @param otherVector defines the other vector
  66126. * @returns a new Vector2
  66127. */
  66128. addVector3(otherVector: Vector3): Vector2;
  66129. /**
  66130. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66131. * @param otherVector defines the other vector
  66132. * @returns a new Vector2
  66133. */
  66134. subtract(otherVector: Vector2): Vector2;
  66135. /**
  66136. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66137. * @param otherVector defines the other vector
  66138. * @param result defines the target vector
  66139. * @returns the unmodified current Vector2
  66140. */
  66141. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66142. /**
  66143. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66144. * @param otherVector defines the other vector
  66145. * @returns the current updated Vector2
  66146. */
  66147. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66148. /**
  66149. * Multiplies in place the current Vector2 coordinates by the given ones
  66150. * @param otherVector defines the other vector
  66151. * @returns the current updated Vector2
  66152. */
  66153. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66154. /**
  66155. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66156. * @param otherVector defines the other vector
  66157. * @returns a new Vector2
  66158. */
  66159. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66160. /**
  66161. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66162. * @param otherVector defines the other vector
  66163. * @param result defines the target vector
  66164. * @returns the unmodified current Vector2
  66165. */
  66166. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66167. /**
  66168. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66169. * @param x defines the first coordinate
  66170. * @param y defines the second coordinate
  66171. * @returns a new Vector2
  66172. */
  66173. multiplyByFloats(x: number, y: number): Vector2;
  66174. /**
  66175. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66176. * @param otherVector defines the other vector
  66177. * @returns a new Vector2
  66178. */
  66179. divide(otherVector: Vector2): Vector2;
  66180. /**
  66181. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66182. * @param otherVector defines the other vector
  66183. * @param result defines the target vector
  66184. * @returns the unmodified current Vector2
  66185. */
  66186. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66187. /**
  66188. * Divides the current Vector2 coordinates by the given ones
  66189. * @param otherVector defines the other vector
  66190. * @returns the current updated Vector2
  66191. */
  66192. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66193. /**
  66194. * Gets a new Vector2 with current Vector2 negated coordinates
  66195. * @returns a new Vector2
  66196. */
  66197. negate(): Vector2;
  66198. /**
  66199. * Multiply the Vector2 coordinates by scale
  66200. * @param scale defines the scaling factor
  66201. * @returns the current updated Vector2
  66202. */
  66203. scaleInPlace(scale: number): Vector2;
  66204. /**
  66205. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66206. * @param scale defines the scaling factor
  66207. * @returns a new Vector2
  66208. */
  66209. scale(scale: number): Vector2;
  66210. /**
  66211. * Scale the current Vector2 values by a factor to a given Vector2
  66212. * @param scale defines the scale factor
  66213. * @param result defines the Vector2 object where to store the result
  66214. * @returns the unmodified current Vector2
  66215. */
  66216. scaleToRef(scale: number, result: Vector2): Vector2;
  66217. /**
  66218. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66219. * @param scale defines the scale factor
  66220. * @param result defines the Vector2 object where to store the result
  66221. * @returns the unmodified current Vector2
  66222. */
  66223. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66224. /**
  66225. * Gets a boolean if two vectors are equals
  66226. * @param otherVector defines the other vector
  66227. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66228. */
  66229. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66230. /**
  66231. * Gets a boolean if two vectors are equals (using an epsilon value)
  66232. * @param otherVector defines the other vector
  66233. * @param epsilon defines the minimal distance to consider equality
  66234. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66235. */
  66236. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66237. /**
  66238. * Gets a new Vector2 from current Vector2 floored values
  66239. * @returns a new Vector2
  66240. */
  66241. floor(): Vector2;
  66242. /**
  66243. * Gets a new Vector2 from current Vector2 floored values
  66244. * @returns a new Vector2
  66245. */
  66246. fract(): Vector2;
  66247. /**
  66248. * Gets the length of the vector
  66249. * @returns the vector length (float)
  66250. */
  66251. length(): number;
  66252. /**
  66253. * Gets the vector squared length
  66254. * @returns the vector squared length (float)
  66255. */
  66256. lengthSquared(): number;
  66257. /**
  66258. * Normalize the vector
  66259. * @returns the current updated Vector2
  66260. */
  66261. normalize(): Vector2;
  66262. /**
  66263. * Gets a new Vector2 copied from the Vector2
  66264. * @returns a new Vector2
  66265. */
  66266. clone(): Vector2;
  66267. /**
  66268. * Gets a new Vector2(0, 0)
  66269. * @returns a new Vector2
  66270. */
  66271. static Zero(): Vector2;
  66272. /**
  66273. * Gets a new Vector2(1, 1)
  66274. * @returns a new Vector2
  66275. */
  66276. static One(): Vector2;
  66277. /**
  66278. * Gets a new Vector2 set from the given index element of the given array
  66279. * @param array defines the data source
  66280. * @param offset defines the offset in the data source
  66281. * @returns a new Vector2
  66282. */
  66283. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66284. /**
  66285. * Sets "result" from the given index element of the given array
  66286. * @param array defines the data source
  66287. * @param offset defines the offset in the data source
  66288. * @param result defines the target vector
  66289. */
  66290. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66291. /**
  66292. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66293. * @param value1 defines 1st point of control
  66294. * @param value2 defines 2nd point of control
  66295. * @param value3 defines 3rd point of control
  66296. * @param value4 defines 4th point of control
  66297. * @param amount defines the interpolation factor
  66298. * @returns a new Vector2
  66299. */
  66300. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66301. /**
  66302. * 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".
  66303. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66304. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66305. * @param value defines the value to clamp
  66306. * @param min defines the lower limit
  66307. * @param max defines the upper limit
  66308. * @returns a new Vector2
  66309. */
  66310. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66311. /**
  66312. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66313. * @param value1 defines the 1st control point
  66314. * @param tangent1 defines the outgoing tangent
  66315. * @param value2 defines the 2nd control point
  66316. * @param tangent2 defines the incoming tangent
  66317. * @param amount defines the interpolation factor
  66318. * @returns a new Vector2
  66319. */
  66320. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66321. /**
  66322. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66323. * @param start defines the start vector
  66324. * @param end defines the end vector
  66325. * @param amount defines the interpolation factor
  66326. * @returns a new Vector2
  66327. */
  66328. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66329. /**
  66330. * Gets the dot product of the vector "left" and the vector "right"
  66331. * @param left defines first vector
  66332. * @param right defines second vector
  66333. * @returns the dot product (float)
  66334. */
  66335. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66336. /**
  66337. * Returns a new Vector2 equal to the normalized given vector
  66338. * @param vector defines the vector to normalize
  66339. * @returns a new Vector2
  66340. */
  66341. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66342. /**
  66343. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66344. * @param left defines 1st vector
  66345. * @param right defines 2nd vector
  66346. * @returns a new Vector2
  66347. */
  66348. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66349. /**
  66350. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66351. * @param left defines 1st vector
  66352. * @param right defines 2nd vector
  66353. * @returns a new Vector2
  66354. */
  66355. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66356. /**
  66357. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66358. * @param vector defines the vector to transform
  66359. * @param transformation defines the matrix to apply
  66360. * @returns a new Vector2
  66361. */
  66362. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66363. /**
  66364. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66365. * @param vector defines the vector to transform
  66366. * @param transformation defines the matrix to apply
  66367. * @param result defines the target vector
  66368. */
  66369. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66370. /**
  66371. * Determines if a given vector is included in a triangle
  66372. * @param p defines the vector to test
  66373. * @param p0 defines 1st triangle point
  66374. * @param p1 defines 2nd triangle point
  66375. * @param p2 defines 3rd triangle point
  66376. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66377. */
  66378. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66379. /**
  66380. * Gets the distance between the vectors "value1" and "value2"
  66381. * @param value1 defines first vector
  66382. * @param value2 defines second vector
  66383. * @returns the distance between vectors
  66384. */
  66385. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66386. /**
  66387. * Returns the squared distance between the vectors "value1" and "value2"
  66388. * @param value1 defines first vector
  66389. * @param value2 defines second vector
  66390. * @returns the squared distance between vectors
  66391. */
  66392. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66393. /**
  66394. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66395. * @param value1 defines first vector
  66396. * @param value2 defines second vector
  66397. * @returns a new Vector2
  66398. */
  66399. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66400. /**
  66401. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66402. * @param p defines the middle point
  66403. * @param segA defines one point of the segment
  66404. * @param segB defines the other point of the segment
  66405. * @returns the shortest distance
  66406. */
  66407. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66408. }
  66409. /**
  66410. * Classed used to store (x,y,z) vector representation
  66411. * A Vector3 is the main object used in 3D geometry
  66412. * It can represent etiher the coordinates of a point the space, either a direction
  66413. * Reminder: js uses a left handed forward facing system
  66414. */
  66415. export class Vector3 {
  66416. /**
  66417. * Defines the first coordinates (on X axis)
  66418. */
  66419. x: number;
  66420. /**
  66421. * Defines the second coordinates (on Y axis)
  66422. */
  66423. y: number;
  66424. /**
  66425. * Defines the third coordinates (on Z axis)
  66426. */
  66427. z: number;
  66428. private static _UpReadOnly;
  66429. private static _ZeroReadOnly;
  66430. /**
  66431. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66432. * @param x defines the first coordinates (on X axis)
  66433. * @param y defines the second coordinates (on Y axis)
  66434. * @param z defines the third coordinates (on Z axis)
  66435. */
  66436. constructor(
  66437. /**
  66438. * Defines the first coordinates (on X axis)
  66439. */
  66440. x?: number,
  66441. /**
  66442. * Defines the second coordinates (on Y axis)
  66443. */
  66444. y?: number,
  66445. /**
  66446. * Defines the third coordinates (on Z axis)
  66447. */
  66448. z?: number);
  66449. /**
  66450. * Creates a string representation of the Vector3
  66451. * @returns a string with the Vector3 coordinates.
  66452. */
  66453. toString(): string;
  66454. /**
  66455. * Gets the class name
  66456. * @returns the string "Vector3"
  66457. */
  66458. getClassName(): string;
  66459. /**
  66460. * Creates the Vector3 hash code
  66461. * @returns a number which tends to be unique between Vector3 instances
  66462. */
  66463. getHashCode(): number;
  66464. /**
  66465. * Creates an array containing three elements : the coordinates of the Vector3
  66466. * @returns a new array of numbers
  66467. */
  66468. asArray(): number[];
  66469. /**
  66470. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66471. * @param array defines the destination array
  66472. * @param index defines the offset in the destination array
  66473. * @returns the current Vector3
  66474. */
  66475. toArray(array: FloatArray, index?: number): Vector3;
  66476. /**
  66477. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66478. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66479. */
  66480. toQuaternion(): Quaternion;
  66481. /**
  66482. * Adds the given vector to the current Vector3
  66483. * @param otherVector defines the second operand
  66484. * @returns the current updated Vector3
  66485. */
  66486. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66487. /**
  66488. * Adds the given coordinates to the current Vector3
  66489. * @param x defines the x coordinate of the operand
  66490. * @param y defines the y coordinate of the operand
  66491. * @param z defines the z coordinate of the operand
  66492. * @returns the current updated Vector3
  66493. */
  66494. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66495. /**
  66496. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66497. * @param otherVector defines the second operand
  66498. * @returns the resulting Vector3
  66499. */
  66500. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66501. /**
  66502. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66503. * @param otherVector defines the second operand
  66504. * @param result defines the Vector3 object where to store the result
  66505. * @returns the current Vector3
  66506. */
  66507. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66508. /**
  66509. * Subtract the given vector from the current Vector3
  66510. * @param otherVector defines the second operand
  66511. * @returns the current updated Vector3
  66512. */
  66513. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66514. /**
  66515. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66516. * @param otherVector defines the second operand
  66517. * @returns the resulting Vector3
  66518. */
  66519. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66520. /**
  66521. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66522. * @param otherVector defines the second operand
  66523. * @param result defines the Vector3 object where to store the result
  66524. * @returns the current Vector3
  66525. */
  66526. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66527. /**
  66528. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66529. * @param x defines the x coordinate of the operand
  66530. * @param y defines the y coordinate of the operand
  66531. * @param z defines the z coordinate of the operand
  66532. * @returns the resulting Vector3
  66533. */
  66534. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66535. /**
  66536. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66537. * @param x defines the x coordinate of the operand
  66538. * @param y defines the y coordinate of the operand
  66539. * @param z defines the z coordinate of the operand
  66540. * @param result defines the Vector3 object where to store the result
  66541. * @returns the current Vector3
  66542. */
  66543. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66544. /**
  66545. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66546. * @returns a new Vector3
  66547. */
  66548. negate(): Vector3;
  66549. /**
  66550. * Multiplies the Vector3 coordinates by the float "scale"
  66551. * @param scale defines the multiplier factor
  66552. * @returns the current updated Vector3
  66553. */
  66554. scaleInPlace(scale: number): Vector3;
  66555. /**
  66556. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66557. * @param scale defines the multiplier factor
  66558. * @returns a new Vector3
  66559. */
  66560. scale(scale: number): Vector3;
  66561. /**
  66562. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66563. * @param scale defines the multiplier factor
  66564. * @param result defines the Vector3 object where to store the result
  66565. * @returns the current Vector3
  66566. */
  66567. scaleToRef(scale: number, result: Vector3): Vector3;
  66568. /**
  66569. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66570. * @param scale defines the scale factor
  66571. * @param result defines the Vector3 object where to store the result
  66572. * @returns the unmodified current Vector3
  66573. */
  66574. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66575. /**
  66576. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66577. * @param otherVector defines the second operand
  66578. * @returns true if both vectors are equals
  66579. */
  66580. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66581. /**
  66582. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66583. * @param otherVector defines the second operand
  66584. * @param epsilon defines the minimal distance to define values as equals
  66585. * @returns true if both vectors are distant less than epsilon
  66586. */
  66587. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66588. /**
  66589. * Returns true if the current Vector3 coordinates equals the given floats
  66590. * @param x defines the x coordinate of the operand
  66591. * @param y defines the y coordinate of the operand
  66592. * @param z defines the z coordinate of the operand
  66593. * @returns true if both vectors are equals
  66594. */
  66595. equalsToFloats(x: number, y: number, z: number): boolean;
  66596. /**
  66597. * Multiplies the current Vector3 coordinates by the given ones
  66598. * @param otherVector defines the second operand
  66599. * @returns the current updated Vector3
  66600. */
  66601. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66602. /**
  66603. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66604. * @param otherVector defines the second operand
  66605. * @returns the new Vector3
  66606. */
  66607. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66608. /**
  66609. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66610. * @param otherVector defines the second operand
  66611. * @param result defines the Vector3 object where to store the result
  66612. * @returns the current Vector3
  66613. */
  66614. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66615. /**
  66616. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66617. * @param x defines the x coordinate of the operand
  66618. * @param y defines the y coordinate of the operand
  66619. * @param z defines the z coordinate of the operand
  66620. * @returns the new Vector3
  66621. */
  66622. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66623. /**
  66624. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66625. * @param otherVector defines the second operand
  66626. * @returns the new Vector3
  66627. */
  66628. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66629. /**
  66630. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66631. * @param otherVector defines the second operand
  66632. * @param result defines the Vector3 object where to store the result
  66633. * @returns the current Vector3
  66634. */
  66635. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66636. /**
  66637. * Divides the current Vector3 coordinates by the given ones.
  66638. * @param otherVector defines the second operand
  66639. * @returns the current updated Vector3
  66640. */
  66641. divideInPlace(otherVector: Vector3): Vector3;
  66642. /**
  66643. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66644. * @param other defines the second operand
  66645. * @returns the current updated Vector3
  66646. */
  66647. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66648. /**
  66649. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66650. * @param other defines the second operand
  66651. * @returns the current updated Vector3
  66652. */
  66653. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66654. /**
  66655. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66656. * @param x defines the x coordinate of the operand
  66657. * @param y defines the y coordinate of the operand
  66658. * @param z defines the z coordinate of the operand
  66659. * @returns the current updated Vector3
  66660. */
  66661. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66662. /**
  66663. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66664. * @param x defines the x coordinate of the operand
  66665. * @param y defines the y coordinate of the operand
  66666. * @param z defines the z coordinate of the operand
  66667. * @returns the current updated Vector3
  66668. */
  66669. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66670. /**
  66671. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66672. * Check if is non uniform within a certain amount of decimal places to account for this
  66673. * @param epsilon the amount the values can differ
  66674. * @returns if the the vector is non uniform to a certain number of decimal places
  66675. */
  66676. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66677. /**
  66678. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66679. */
  66680. readonly isNonUniform: boolean;
  66681. /**
  66682. * Gets a new Vector3 from current Vector3 floored values
  66683. * @returns a new Vector3
  66684. */
  66685. floor(): Vector3;
  66686. /**
  66687. * Gets a new Vector3 from current Vector3 floored values
  66688. * @returns a new Vector3
  66689. */
  66690. fract(): Vector3;
  66691. /**
  66692. * Gets the length of the Vector3
  66693. * @returns the length of the Vector3
  66694. */
  66695. length(): number;
  66696. /**
  66697. * Gets the squared length of the Vector3
  66698. * @returns squared length of the Vector3
  66699. */
  66700. lengthSquared(): number;
  66701. /**
  66702. * Normalize the current Vector3.
  66703. * Please note that this is an in place operation.
  66704. * @returns the current updated Vector3
  66705. */
  66706. normalize(): Vector3;
  66707. /**
  66708. * Reorders the x y z properties of the vector in place
  66709. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66710. * @returns the current updated vector
  66711. */
  66712. reorderInPlace(order: string): this;
  66713. /**
  66714. * Rotates the vector around 0,0,0 by a quaternion
  66715. * @param quaternion the rotation quaternion
  66716. * @param result vector to store the result
  66717. * @returns the resulting vector
  66718. */
  66719. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66720. /**
  66721. * Rotates a vector around a given point
  66722. * @param quaternion the rotation quaternion
  66723. * @param point the point to rotate around
  66724. * @param result vector to store the result
  66725. * @returns the resulting vector
  66726. */
  66727. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66728. /**
  66729. * Normalize the current Vector3 with the given input length.
  66730. * Please note that this is an in place operation.
  66731. * @param len the length of the vector
  66732. * @returns the current updated Vector3
  66733. */
  66734. normalizeFromLength(len: number): Vector3;
  66735. /**
  66736. * Normalize the current Vector3 to a new vector
  66737. * @returns the new Vector3
  66738. */
  66739. normalizeToNew(): Vector3;
  66740. /**
  66741. * Normalize the current Vector3 to the reference
  66742. * @param reference define the Vector3 to update
  66743. * @returns the updated Vector3
  66744. */
  66745. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66746. /**
  66747. * Creates a new Vector3 copied from the current Vector3
  66748. * @returns the new Vector3
  66749. */
  66750. clone(): Vector3;
  66751. /**
  66752. * Copies the given vector coordinates to the current Vector3 ones
  66753. * @param source defines the source Vector3
  66754. * @returns the current updated Vector3
  66755. */
  66756. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66757. /**
  66758. * Copies the given floats to the current Vector3 coordinates
  66759. * @param x defines the x coordinate of the operand
  66760. * @param y defines the y coordinate of the operand
  66761. * @param z defines the z coordinate of the operand
  66762. * @returns the current updated Vector3
  66763. */
  66764. copyFromFloats(x: number, y: number, z: number): Vector3;
  66765. /**
  66766. * Copies the given floats to the current Vector3 coordinates
  66767. * @param x defines the x coordinate of the operand
  66768. * @param y defines the y coordinate of the operand
  66769. * @param z defines the z coordinate of the operand
  66770. * @returns the current updated Vector3
  66771. */
  66772. set(x: number, y: number, z: number): Vector3;
  66773. /**
  66774. * Copies the given float to the current Vector3 coordinates
  66775. * @param v defines the x, y and z coordinates of the operand
  66776. * @returns the current updated Vector3
  66777. */
  66778. setAll(v: number): Vector3;
  66779. /**
  66780. * Get the clip factor between two vectors
  66781. * @param vector0 defines the first operand
  66782. * @param vector1 defines the second operand
  66783. * @param axis defines the axis to use
  66784. * @param size defines the size along the axis
  66785. * @returns the clip factor
  66786. */
  66787. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66788. /**
  66789. * Get angle between two vectors
  66790. * @param vector0 angle between vector0 and vector1
  66791. * @param vector1 angle between vector0 and vector1
  66792. * @param normal direction of the normal
  66793. * @return the angle between vector0 and vector1
  66794. */
  66795. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66796. /**
  66797. * Returns a new Vector3 set from the index "offset" of the given array
  66798. * @param array defines the source array
  66799. * @param offset defines the offset in the source array
  66800. * @returns the new Vector3
  66801. */
  66802. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66803. /**
  66804. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66805. * This function is deprecated. Use FromArray instead
  66806. * @param array defines the source array
  66807. * @param offset defines the offset in the source array
  66808. * @returns the new Vector3
  66809. */
  66810. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66811. /**
  66812. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66813. * @param array defines the source array
  66814. * @param offset defines the offset in the source array
  66815. * @param result defines the Vector3 where to store the result
  66816. */
  66817. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66818. /**
  66819. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66820. * This function is deprecated. Use FromArrayToRef instead.
  66821. * @param array defines the source array
  66822. * @param offset defines the offset in the source array
  66823. * @param result defines the Vector3 where to store the result
  66824. */
  66825. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66826. /**
  66827. * Sets the given vector "result" with the given floats.
  66828. * @param x defines the x coordinate of the source
  66829. * @param y defines the y coordinate of the source
  66830. * @param z defines the z coordinate of the source
  66831. * @param result defines the Vector3 where to store the result
  66832. */
  66833. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66834. /**
  66835. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66836. * @returns a new empty Vector3
  66837. */
  66838. static Zero(): Vector3;
  66839. /**
  66840. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66841. * @returns a new unit Vector3
  66842. */
  66843. static One(): Vector3;
  66844. /**
  66845. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66846. * @returns a new up Vector3
  66847. */
  66848. static Up(): Vector3;
  66849. /**
  66850. * Gets a up Vector3 that must not be updated
  66851. */
  66852. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66853. /**
  66854. * Gets a zero Vector3 that must not be updated
  66855. */
  66856. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66857. /**
  66858. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66859. * @returns a new down Vector3
  66860. */
  66861. static Down(): Vector3;
  66862. /**
  66863. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66864. * @returns a new forward Vector3
  66865. */
  66866. static Forward(): Vector3;
  66867. /**
  66868. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66869. * @returns a new forward Vector3
  66870. */
  66871. static Backward(): Vector3;
  66872. /**
  66873. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66874. * @returns a new right Vector3
  66875. */
  66876. static Right(): Vector3;
  66877. /**
  66878. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66879. * @returns a new left Vector3
  66880. */
  66881. static Left(): Vector3;
  66882. /**
  66883. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66884. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66885. * @param vector defines the Vector3 to transform
  66886. * @param transformation defines the transformation matrix
  66887. * @returns the transformed Vector3
  66888. */
  66889. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66890. /**
  66891. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66892. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66893. * @param vector defines the Vector3 to transform
  66894. * @param transformation defines the transformation matrix
  66895. * @param result defines the Vector3 where to store the result
  66896. */
  66897. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66898. /**
  66899. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66900. * This method computes tranformed coordinates only, not transformed direction vectors
  66901. * @param x define the x coordinate of the source vector
  66902. * @param y define the y coordinate of the source vector
  66903. * @param z define the z coordinate of the source vector
  66904. * @param transformation defines the transformation matrix
  66905. * @param result defines the Vector3 where to store the result
  66906. */
  66907. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66908. /**
  66909. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66910. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66911. * @param vector defines the Vector3 to transform
  66912. * @param transformation defines the transformation matrix
  66913. * @returns the new Vector3
  66914. */
  66915. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66916. /**
  66917. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66918. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66919. * @param vector defines the Vector3 to transform
  66920. * @param transformation defines the transformation matrix
  66921. * @param result defines the Vector3 where to store the result
  66922. */
  66923. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66924. /**
  66925. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66926. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66927. * @param x define the x coordinate of the source vector
  66928. * @param y define the y coordinate of the source vector
  66929. * @param z define the z coordinate of the source vector
  66930. * @param transformation defines the transformation matrix
  66931. * @param result defines the Vector3 where to store the result
  66932. */
  66933. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66934. /**
  66935. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66936. * @param value1 defines the first control point
  66937. * @param value2 defines the second control point
  66938. * @param value3 defines the third control point
  66939. * @param value4 defines the fourth control point
  66940. * @param amount defines the amount on the spline to use
  66941. * @returns the new Vector3
  66942. */
  66943. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66944. /**
  66945. * 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"
  66946. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66947. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66948. * @param value defines the current value
  66949. * @param min defines the lower range value
  66950. * @param max defines the upper range value
  66951. * @returns the new Vector3
  66952. */
  66953. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66954. /**
  66955. * 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"
  66956. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66957. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66958. * @param value defines the current value
  66959. * @param min defines the lower range value
  66960. * @param max defines the upper range value
  66961. * @param result defines the Vector3 where to store the result
  66962. */
  66963. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66964. /**
  66965. * Checks if a given vector is inside a specific range
  66966. * @param v defines the vector to test
  66967. * @param min defines the minimum range
  66968. * @param max defines the maximum range
  66969. */
  66970. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66971. /**
  66972. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66973. * @param value1 defines the first control point
  66974. * @param tangent1 defines the first tangent vector
  66975. * @param value2 defines the second control point
  66976. * @param tangent2 defines the second tangent vector
  66977. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66978. * @returns the new Vector3
  66979. */
  66980. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66981. /**
  66982. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66983. * @param start defines the start value
  66984. * @param end defines the end value
  66985. * @param amount max defines amount between both (between 0 and 1)
  66986. * @returns the new Vector3
  66987. */
  66988. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66989. /**
  66990. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66991. * @param start defines the start value
  66992. * @param end defines the end value
  66993. * @param amount max defines amount between both (between 0 and 1)
  66994. * @param result defines the Vector3 where to store the result
  66995. */
  66996. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66997. /**
  66998. * Returns the dot product (float) between the vectors "left" and "right"
  66999. * @param left defines the left operand
  67000. * @param right defines the right operand
  67001. * @returns the dot product
  67002. */
  67003. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67004. /**
  67005. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67006. * The cross product is then orthogonal to both "left" and "right"
  67007. * @param left defines the left operand
  67008. * @param right defines the right operand
  67009. * @returns the cross product
  67010. */
  67011. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67012. /**
  67013. * Sets the given vector "result" with the cross product of "left" and "right"
  67014. * The cross product is then orthogonal to both "left" and "right"
  67015. * @param left defines the left operand
  67016. * @param right defines the right operand
  67017. * @param result defines the Vector3 where to store the result
  67018. */
  67019. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67020. /**
  67021. * Returns a new Vector3 as the normalization of the given vector
  67022. * @param vector defines the Vector3 to normalize
  67023. * @returns the new Vector3
  67024. */
  67025. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67026. /**
  67027. * Sets the given vector "result" with the normalization of the given first vector
  67028. * @param vector defines the Vector3 to normalize
  67029. * @param result defines the Vector3 where to store the result
  67030. */
  67031. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67032. /**
  67033. * Project a Vector3 onto screen space
  67034. * @param vector defines the Vector3 to project
  67035. * @param world defines the world matrix to use
  67036. * @param transform defines the transform (view x projection) matrix to use
  67037. * @param viewport defines the screen viewport to use
  67038. * @returns the new Vector3
  67039. */
  67040. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67041. /** @hidden */
  67042. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67043. /**
  67044. * Unproject from screen space to object space
  67045. * @param source defines the screen space Vector3 to use
  67046. * @param viewportWidth defines the current width of the viewport
  67047. * @param viewportHeight defines the current height of the viewport
  67048. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67049. * @param transform defines the transform (view x projection) matrix to use
  67050. * @returns the new Vector3
  67051. */
  67052. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67053. /**
  67054. * Unproject from screen space to object space
  67055. * @param source defines the screen space Vector3 to use
  67056. * @param viewportWidth defines the current width of the viewport
  67057. * @param viewportHeight defines the current height of the viewport
  67058. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67059. * @param view defines the view matrix to use
  67060. * @param projection defines the projection matrix to use
  67061. * @returns the new Vector3
  67062. */
  67063. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67064. /**
  67065. * Unproject from screen space to object space
  67066. * @param source defines the screen space Vector3 to use
  67067. * @param viewportWidth defines the current width of the viewport
  67068. * @param viewportHeight defines the current height of the viewport
  67069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67070. * @param view defines the view matrix to use
  67071. * @param projection defines the projection matrix to use
  67072. * @param result defines the Vector3 where to store the result
  67073. */
  67074. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67075. /**
  67076. * Unproject from screen space to object space
  67077. * @param sourceX defines the screen space x coordinate to use
  67078. * @param sourceY defines the screen space y coordinate to use
  67079. * @param sourceZ defines the screen space z coordinate to use
  67080. * @param viewportWidth defines the current width of the viewport
  67081. * @param viewportHeight defines the current height of the viewport
  67082. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67083. * @param view defines the view matrix to use
  67084. * @param projection defines the projection matrix to use
  67085. * @param result defines the Vector3 where to store the result
  67086. */
  67087. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67088. /**
  67089. * Gets the minimal coordinate values between two Vector3
  67090. * @param left defines the first operand
  67091. * @param right defines the second operand
  67092. * @returns the new Vector3
  67093. */
  67094. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67095. /**
  67096. * Gets the maximal coordinate values between two Vector3
  67097. * @param left defines the first operand
  67098. * @param right defines the second operand
  67099. * @returns the new Vector3
  67100. */
  67101. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67102. /**
  67103. * Returns the distance between the vectors "value1" and "value2"
  67104. * @param value1 defines the first operand
  67105. * @param value2 defines the second operand
  67106. * @returns the distance
  67107. */
  67108. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67109. /**
  67110. * Returns the squared distance between the vectors "value1" and "value2"
  67111. * @param value1 defines the first operand
  67112. * @param value2 defines the second operand
  67113. * @returns the squared distance
  67114. */
  67115. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67116. /**
  67117. * Returns a new Vector3 located at the center between "value1" and "value2"
  67118. * @param value1 defines the first operand
  67119. * @param value2 defines the second operand
  67120. * @returns the new Vector3
  67121. */
  67122. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67123. /**
  67124. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67125. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67126. * to something in order to rotate it from its local system to the given target system
  67127. * Note: axis1, axis2 and axis3 are normalized during this operation
  67128. * @param axis1 defines the first axis
  67129. * @param axis2 defines the second axis
  67130. * @param axis3 defines the third axis
  67131. * @returns a new Vector3
  67132. */
  67133. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67134. /**
  67135. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67136. * @param axis1 defines the first axis
  67137. * @param axis2 defines the second axis
  67138. * @param axis3 defines the third axis
  67139. * @param ref defines the Vector3 where to store the result
  67140. */
  67141. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67142. }
  67143. /**
  67144. * Vector4 class created for EulerAngle class conversion to Quaternion
  67145. */
  67146. export class Vector4 {
  67147. /** x value of the vector */
  67148. x: number;
  67149. /** y value of the vector */
  67150. y: number;
  67151. /** z value of the vector */
  67152. z: number;
  67153. /** w value of the vector */
  67154. w: number;
  67155. /**
  67156. * Creates a Vector4 object from the given floats.
  67157. * @param x x value of the vector
  67158. * @param y y value of the vector
  67159. * @param z z value of the vector
  67160. * @param w w value of the vector
  67161. */
  67162. constructor(
  67163. /** x value of the vector */
  67164. x: number,
  67165. /** y value of the vector */
  67166. y: number,
  67167. /** z value of the vector */
  67168. z: number,
  67169. /** w value of the vector */
  67170. w: number);
  67171. /**
  67172. * Returns the string with the Vector4 coordinates.
  67173. * @returns a string containing all the vector values
  67174. */
  67175. toString(): string;
  67176. /**
  67177. * Returns the string "Vector4".
  67178. * @returns "Vector4"
  67179. */
  67180. getClassName(): string;
  67181. /**
  67182. * Returns the Vector4 hash code.
  67183. * @returns a unique hash code
  67184. */
  67185. getHashCode(): number;
  67186. /**
  67187. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67188. * @returns the resulting array
  67189. */
  67190. asArray(): number[];
  67191. /**
  67192. * Populates the given array from the given index with the Vector4 coordinates.
  67193. * @param array array to populate
  67194. * @param index index of the array to start at (default: 0)
  67195. * @returns the Vector4.
  67196. */
  67197. toArray(array: FloatArray, index?: number): Vector4;
  67198. /**
  67199. * Adds the given vector to the current Vector4.
  67200. * @param otherVector the vector to add
  67201. * @returns the updated Vector4.
  67202. */
  67203. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67204. /**
  67205. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67206. * @param otherVector the vector to add
  67207. * @returns the resulting vector
  67208. */
  67209. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67210. /**
  67211. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67212. * @param otherVector the vector to add
  67213. * @param result the vector to store the result
  67214. * @returns the current Vector4.
  67215. */
  67216. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67217. /**
  67218. * Subtract in place the given vector from the current Vector4.
  67219. * @param otherVector the vector to subtract
  67220. * @returns the updated Vector4.
  67221. */
  67222. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67223. /**
  67224. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67225. * @param otherVector the vector to add
  67226. * @returns the new vector with the result
  67227. */
  67228. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67229. /**
  67230. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67231. * @param otherVector the vector to subtract
  67232. * @param result the vector to store the result
  67233. * @returns the current Vector4.
  67234. */
  67235. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67236. /**
  67237. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67238. */
  67239. /**
  67240. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67241. * @param x value to subtract
  67242. * @param y value to subtract
  67243. * @param z value to subtract
  67244. * @param w value to subtract
  67245. * @returns new vector containing the result
  67246. */
  67247. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67248. /**
  67249. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67250. * @param x value to subtract
  67251. * @param y value to subtract
  67252. * @param z value to subtract
  67253. * @param w value to subtract
  67254. * @param result the vector to store the result in
  67255. * @returns the current Vector4.
  67256. */
  67257. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67258. /**
  67259. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67260. * @returns a new vector with the negated values
  67261. */
  67262. negate(): Vector4;
  67263. /**
  67264. * Multiplies the current Vector4 coordinates by scale (float).
  67265. * @param scale the number to scale with
  67266. * @returns the updated Vector4.
  67267. */
  67268. scaleInPlace(scale: number): Vector4;
  67269. /**
  67270. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67271. * @param scale the number to scale with
  67272. * @returns a new vector with the result
  67273. */
  67274. scale(scale: number): Vector4;
  67275. /**
  67276. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67277. * @param scale the number to scale with
  67278. * @param result a vector to store the result in
  67279. * @returns the current Vector4.
  67280. */
  67281. scaleToRef(scale: number, result: Vector4): Vector4;
  67282. /**
  67283. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67284. * @param scale defines the scale factor
  67285. * @param result defines the Vector4 object where to store the result
  67286. * @returns the unmodified current Vector4
  67287. */
  67288. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67289. /**
  67290. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67291. * @param otherVector the vector to compare against
  67292. * @returns true if they are equal
  67293. */
  67294. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67295. /**
  67296. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67297. * @param otherVector vector to compare against
  67298. * @param epsilon (Default: very small number)
  67299. * @returns true if they are equal
  67300. */
  67301. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67302. /**
  67303. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67304. * @param x x value to compare against
  67305. * @param y y value to compare against
  67306. * @param z z value to compare against
  67307. * @param w w value to compare against
  67308. * @returns true if equal
  67309. */
  67310. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67311. /**
  67312. * Multiplies in place the current Vector4 by the given one.
  67313. * @param otherVector vector to multiple with
  67314. * @returns the updated Vector4.
  67315. */
  67316. multiplyInPlace(otherVector: Vector4): Vector4;
  67317. /**
  67318. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67319. * @param otherVector vector to multiple with
  67320. * @returns resulting new vector
  67321. */
  67322. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67323. /**
  67324. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67325. * @param otherVector vector to multiple with
  67326. * @param result vector to store the result
  67327. * @returns the current Vector4.
  67328. */
  67329. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67330. /**
  67331. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67332. * @param x x value multiply with
  67333. * @param y y value multiply with
  67334. * @param z z value multiply with
  67335. * @param w w value multiply with
  67336. * @returns resulting new vector
  67337. */
  67338. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67339. /**
  67340. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67341. * @param otherVector vector to devide with
  67342. * @returns resulting new vector
  67343. */
  67344. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67345. /**
  67346. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67347. * @param otherVector vector to devide with
  67348. * @param result vector to store the result
  67349. * @returns the current Vector4.
  67350. */
  67351. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67352. /**
  67353. * Divides the current Vector3 coordinates by the given ones.
  67354. * @param otherVector vector to devide with
  67355. * @returns the updated Vector3.
  67356. */
  67357. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67358. /**
  67359. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67360. * @param other defines the second operand
  67361. * @returns the current updated Vector4
  67362. */
  67363. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67364. /**
  67365. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67366. * @param other defines the second operand
  67367. * @returns the current updated Vector4
  67368. */
  67369. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67370. /**
  67371. * Gets a new Vector4 from current Vector4 floored values
  67372. * @returns a new Vector4
  67373. */
  67374. floor(): Vector4;
  67375. /**
  67376. * Gets a new Vector4 from current Vector3 floored values
  67377. * @returns a new Vector4
  67378. */
  67379. fract(): Vector4;
  67380. /**
  67381. * Returns the Vector4 length (float).
  67382. * @returns the length
  67383. */
  67384. length(): number;
  67385. /**
  67386. * Returns the Vector4 squared length (float).
  67387. * @returns the length squared
  67388. */
  67389. lengthSquared(): number;
  67390. /**
  67391. * Normalizes in place the Vector4.
  67392. * @returns the updated Vector4.
  67393. */
  67394. normalize(): Vector4;
  67395. /**
  67396. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67397. * @returns this converted to a new vector3
  67398. */
  67399. toVector3(): Vector3;
  67400. /**
  67401. * Returns a new Vector4 copied from the current one.
  67402. * @returns the new cloned vector
  67403. */
  67404. clone(): Vector4;
  67405. /**
  67406. * Updates the current Vector4 with the given one coordinates.
  67407. * @param source the source vector to copy from
  67408. * @returns the updated Vector4.
  67409. */
  67410. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67411. /**
  67412. * Updates the current Vector4 coordinates with the given floats.
  67413. * @param x float to copy from
  67414. * @param y float to copy from
  67415. * @param z float to copy from
  67416. * @param w float to copy from
  67417. * @returns the updated Vector4.
  67418. */
  67419. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67420. /**
  67421. * Updates the current Vector4 coordinates with the given floats.
  67422. * @param x float to set from
  67423. * @param y float to set from
  67424. * @param z float to set from
  67425. * @param w float to set from
  67426. * @returns the updated Vector4.
  67427. */
  67428. set(x: number, y: number, z: number, w: number): Vector4;
  67429. /**
  67430. * Copies the given float to the current Vector3 coordinates
  67431. * @param v defines the x, y, z and w coordinates of the operand
  67432. * @returns the current updated Vector3
  67433. */
  67434. setAll(v: number): Vector4;
  67435. /**
  67436. * Returns a new Vector4 set from the starting index of the given array.
  67437. * @param array the array to pull values from
  67438. * @param offset the offset into the array to start at
  67439. * @returns the new vector
  67440. */
  67441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67442. /**
  67443. * Updates the given vector "result" from the starting index of the given array.
  67444. * @param array the array to pull values from
  67445. * @param offset the offset into the array to start at
  67446. * @param result the vector to store the result in
  67447. */
  67448. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67449. /**
  67450. * Updates the given vector "result" from the starting index of the given Float32Array.
  67451. * @param array the array to pull values from
  67452. * @param offset the offset into the array to start at
  67453. * @param result the vector to store the result in
  67454. */
  67455. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67456. /**
  67457. * Updates the given vector "result" coordinates from the given floats.
  67458. * @param x float to set from
  67459. * @param y float to set from
  67460. * @param z float to set from
  67461. * @param w float to set from
  67462. * @param result the vector to the floats in
  67463. */
  67464. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67465. /**
  67466. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67467. * @returns the new vector
  67468. */
  67469. static Zero(): Vector4;
  67470. /**
  67471. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67472. * @returns the new vector
  67473. */
  67474. static One(): Vector4;
  67475. /**
  67476. * Returns a new normalized Vector4 from the given one.
  67477. * @param vector the vector to normalize
  67478. * @returns the vector
  67479. */
  67480. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67481. /**
  67482. * Updates the given vector "result" from the normalization of the given one.
  67483. * @param vector the vector to normalize
  67484. * @param result the vector to store the result in
  67485. */
  67486. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67487. /**
  67488. * Returns a vector with the minimum values from the left and right vectors
  67489. * @param left left vector to minimize
  67490. * @param right right vector to minimize
  67491. * @returns a new vector with the minimum of the left and right vector values
  67492. */
  67493. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67494. /**
  67495. * Returns a vector with the maximum values from the left and right vectors
  67496. * @param left left vector to maximize
  67497. * @param right right vector to maximize
  67498. * @returns a new vector with the maximum of the left and right vector values
  67499. */
  67500. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67501. /**
  67502. * Returns the distance (float) between the vectors "value1" and "value2".
  67503. * @param value1 value to calulate the distance between
  67504. * @param value2 value to calulate the distance between
  67505. * @return the distance between the two vectors
  67506. */
  67507. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67508. /**
  67509. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67510. * @param value1 value to calulate the distance between
  67511. * @param value2 value to calulate the distance between
  67512. * @return the distance between the two vectors squared
  67513. */
  67514. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67515. /**
  67516. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67517. * @param value1 value to calulate the center between
  67518. * @param value2 value to calulate the center between
  67519. * @return the center between the two vectors
  67520. */
  67521. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67522. /**
  67523. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67524. * This methods computes transformed normalized direction vectors only.
  67525. * @param vector the vector to transform
  67526. * @param transformation the transformation matrix to apply
  67527. * @returns the new vector
  67528. */
  67529. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67530. /**
  67531. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67532. * This methods computes transformed normalized direction vectors only.
  67533. * @param vector the vector to transform
  67534. * @param transformation the transformation matrix to apply
  67535. * @param result the vector to store the result in
  67536. */
  67537. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67538. /**
  67539. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67540. * This methods computes transformed normalized direction vectors only.
  67541. * @param x value to transform
  67542. * @param y value to transform
  67543. * @param z value to transform
  67544. * @param w value to transform
  67545. * @param transformation the transformation matrix to apply
  67546. * @param result the vector to store the results in
  67547. */
  67548. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67549. /**
  67550. * Creates a new Vector4 from a Vector3
  67551. * @param source defines the source data
  67552. * @param w defines the 4th component (default is 0)
  67553. * @returns a new Vector4
  67554. */
  67555. static FromVector3(source: Vector3, w?: number): Vector4;
  67556. }
  67557. /**
  67558. * Class used to store quaternion data
  67559. * @see https://en.wikipedia.org/wiki/Quaternion
  67560. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67561. */
  67562. export class Quaternion {
  67563. /** defines the first component (0 by default) */
  67564. x: number;
  67565. /** defines the second component (0 by default) */
  67566. y: number;
  67567. /** defines the third component (0 by default) */
  67568. z: number;
  67569. /** defines the fourth component (1.0 by default) */
  67570. w: number;
  67571. /**
  67572. * Creates a new Quaternion from the given floats
  67573. * @param x defines the first component (0 by default)
  67574. * @param y defines the second component (0 by default)
  67575. * @param z defines the third component (0 by default)
  67576. * @param w defines the fourth component (1.0 by default)
  67577. */
  67578. constructor(
  67579. /** defines the first component (0 by default) */
  67580. x?: number,
  67581. /** defines the second component (0 by default) */
  67582. y?: number,
  67583. /** defines the third component (0 by default) */
  67584. z?: number,
  67585. /** defines the fourth component (1.0 by default) */
  67586. w?: number);
  67587. /**
  67588. * Gets a string representation for the current quaternion
  67589. * @returns a string with the Quaternion coordinates
  67590. */
  67591. toString(): string;
  67592. /**
  67593. * Gets the class name of the quaternion
  67594. * @returns the string "Quaternion"
  67595. */
  67596. getClassName(): string;
  67597. /**
  67598. * Gets a hash code for this quaternion
  67599. * @returns the quaternion hash code
  67600. */
  67601. getHashCode(): number;
  67602. /**
  67603. * Copy the quaternion to an array
  67604. * @returns a new array populated with 4 elements from the quaternion coordinates
  67605. */
  67606. asArray(): number[];
  67607. /**
  67608. * Check if two quaternions are equals
  67609. * @param otherQuaternion defines the second operand
  67610. * @return true if the current quaternion and the given one coordinates are strictly equals
  67611. */
  67612. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67613. /**
  67614. * Clone the current quaternion
  67615. * @returns a new quaternion copied from the current one
  67616. */
  67617. clone(): Quaternion;
  67618. /**
  67619. * Copy a quaternion to the current one
  67620. * @param other defines the other quaternion
  67621. * @returns the updated current quaternion
  67622. */
  67623. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67624. /**
  67625. * Updates the current quaternion with the given float coordinates
  67626. * @param x defines the x coordinate
  67627. * @param y defines the y coordinate
  67628. * @param z defines the z coordinate
  67629. * @param w defines the w coordinate
  67630. * @returns the updated current quaternion
  67631. */
  67632. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67633. /**
  67634. * Updates the current quaternion from the given float coordinates
  67635. * @param x defines the x coordinate
  67636. * @param y defines the y coordinate
  67637. * @param z defines the z coordinate
  67638. * @param w defines the w coordinate
  67639. * @returns the updated current quaternion
  67640. */
  67641. set(x: number, y: number, z: number, w: number): Quaternion;
  67642. /**
  67643. * Adds two quaternions
  67644. * @param other defines the second operand
  67645. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67646. */
  67647. add(other: DeepImmutable<Quaternion>): Quaternion;
  67648. /**
  67649. * Add a quaternion to the current one
  67650. * @param other defines the quaternion to add
  67651. * @returns the current quaternion
  67652. */
  67653. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67654. /**
  67655. * Subtract two quaternions
  67656. * @param other defines the second operand
  67657. * @returns a new quaternion as the subtraction result of the given one from the current one
  67658. */
  67659. subtract(other: Quaternion): Quaternion;
  67660. /**
  67661. * Multiplies the current quaternion by a scale factor
  67662. * @param value defines the scale factor
  67663. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67664. */
  67665. scale(value: number): Quaternion;
  67666. /**
  67667. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67668. * @param scale defines the scale factor
  67669. * @param result defines the Quaternion object where to store the result
  67670. * @returns the unmodified current quaternion
  67671. */
  67672. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67673. /**
  67674. * Multiplies in place the current quaternion by a scale factor
  67675. * @param value defines the scale factor
  67676. * @returns the current modified quaternion
  67677. */
  67678. scaleInPlace(value: number): Quaternion;
  67679. /**
  67680. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67681. * @param scale defines the scale factor
  67682. * @param result defines the Quaternion object where to store the result
  67683. * @returns the unmodified current quaternion
  67684. */
  67685. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67686. /**
  67687. * Multiplies two quaternions
  67688. * @param q1 defines the second operand
  67689. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67690. */
  67691. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67692. /**
  67693. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67694. * @param q1 defines the second operand
  67695. * @param result defines the target quaternion
  67696. * @returns the current quaternion
  67697. */
  67698. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67699. /**
  67700. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67701. * @param q1 defines the second operand
  67702. * @returns the currentupdated quaternion
  67703. */
  67704. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67705. /**
  67706. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67707. * @param ref defines the target quaternion
  67708. * @returns the current quaternion
  67709. */
  67710. conjugateToRef(ref: Quaternion): Quaternion;
  67711. /**
  67712. * Conjugates in place (1-q) the current quaternion
  67713. * @returns the current updated quaternion
  67714. */
  67715. conjugateInPlace(): Quaternion;
  67716. /**
  67717. * Conjugates in place (1-q) the current quaternion
  67718. * @returns a new quaternion
  67719. */
  67720. conjugate(): Quaternion;
  67721. /**
  67722. * Gets length of current quaternion
  67723. * @returns the quaternion length (float)
  67724. */
  67725. length(): number;
  67726. /**
  67727. * Normalize in place the current quaternion
  67728. * @returns the current updated quaternion
  67729. */
  67730. normalize(): Quaternion;
  67731. /**
  67732. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67733. * @param order is a reserved parameter and is ignore for now
  67734. * @returns a new Vector3 containing the Euler angles
  67735. */
  67736. toEulerAngles(order?: string): Vector3;
  67737. /**
  67738. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67739. * @param result defines the vector which will be filled with the Euler angles
  67740. * @param order is a reserved parameter and is ignore for now
  67741. * @returns the current unchanged quaternion
  67742. */
  67743. toEulerAnglesToRef(result: Vector3): Quaternion;
  67744. /**
  67745. * Updates the given rotation matrix with the current quaternion values
  67746. * @param result defines the target matrix
  67747. * @returns the current unchanged quaternion
  67748. */
  67749. toRotationMatrix(result: Matrix): Quaternion;
  67750. /**
  67751. * Updates the current quaternion from the given rotation matrix values
  67752. * @param matrix defines the source matrix
  67753. * @returns the current updated quaternion
  67754. */
  67755. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67756. /**
  67757. * Creates a new quaternion from a rotation matrix
  67758. * @param matrix defines the source matrix
  67759. * @returns a new quaternion created from the given rotation matrix values
  67760. */
  67761. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67762. /**
  67763. * Updates the given quaternion with the given rotation matrix values
  67764. * @param matrix defines the source matrix
  67765. * @param result defines the target quaternion
  67766. */
  67767. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67768. /**
  67769. * Returns the dot product (float) between the quaternions "left" and "right"
  67770. * @param left defines the left operand
  67771. * @param right defines the right operand
  67772. * @returns the dot product
  67773. */
  67774. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67775. /**
  67776. * Checks if the two quaternions are close to each other
  67777. * @param quat0 defines the first quaternion to check
  67778. * @param quat1 defines the second quaternion to check
  67779. * @returns true if the two quaternions are close to each other
  67780. */
  67781. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67782. /**
  67783. * Creates an empty quaternion
  67784. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67785. */
  67786. static Zero(): Quaternion;
  67787. /**
  67788. * Inverse a given quaternion
  67789. * @param q defines the source quaternion
  67790. * @returns a new quaternion as the inverted current quaternion
  67791. */
  67792. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67793. /**
  67794. * Inverse a given quaternion
  67795. * @param q defines the source quaternion
  67796. * @param result the quaternion the result will be stored in
  67797. * @returns the result quaternion
  67798. */
  67799. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67800. /**
  67801. * Creates an identity quaternion
  67802. * @returns the identity quaternion
  67803. */
  67804. static Identity(): Quaternion;
  67805. /**
  67806. * Gets a boolean indicating if the given quaternion is identity
  67807. * @param quaternion defines the quaternion to check
  67808. * @returns true if the quaternion is identity
  67809. */
  67810. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67811. /**
  67812. * Creates a quaternion from a rotation around an axis
  67813. * @param axis defines the axis to use
  67814. * @param angle defines the angle to use
  67815. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67816. */
  67817. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67818. /**
  67819. * Creates a rotation around an axis and stores it into the given quaternion
  67820. * @param axis defines the axis to use
  67821. * @param angle defines the angle to use
  67822. * @param result defines the target quaternion
  67823. * @returns the target quaternion
  67824. */
  67825. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67826. /**
  67827. * Creates a new quaternion from data stored into an array
  67828. * @param array defines the data source
  67829. * @param offset defines the offset in the source array where the data starts
  67830. * @returns a new quaternion
  67831. */
  67832. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67833. /**
  67834. * Create a quaternion from Euler rotation angles
  67835. * @param x Pitch
  67836. * @param y Yaw
  67837. * @param z Roll
  67838. * @returns the new Quaternion
  67839. */
  67840. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67841. /**
  67842. * Updates a quaternion from Euler rotation angles
  67843. * @param x Pitch
  67844. * @param y Yaw
  67845. * @param z Roll
  67846. * @param result the quaternion to store the result
  67847. * @returns the updated quaternion
  67848. */
  67849. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67850. /**
  67851. * Create a quaternion from Euler rotation vector
  67852. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67853. * @returns the new Quaternion
  67854. */
  67855. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67856. /**
  67857. * Updates a quaternion from Euler rotation vector
  67858. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67859. * @param result the quaternion to store the result
  67860. * @returns the updated quaternion
  67861. */
  67862. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67863. /**
  67864. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67865. * @param yaw defines the rotation around Y axis
  67866. * @param pitch defines the rotation around X axis
  67867. * @param roll defines the rotation around Z axis
  67868. * @returns the new quaternion
  67869. */
  67870. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67871. /**
  67872. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67873. * @param yaw defines the rotation around Y axis
  67874. * @param pitch defines the rotation around X axis
  67875. * @param roll defines the rotation around Z axis
  67876. * @param result defines the target quaternion
  67877. */
  67878. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67879. /**
  67880. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67881. * @param alpha defines the rotation around first axis
  67882. * @param beta defines the rotation around second axis
  67883. * @param gamma defines the rotation around third axis
  67884. * @returns the new quaternion
  67885. */
  67886. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67887. /**
  67888. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67889. * @param alpha defines the rotation around first axis
  67890. * @param beta defines the rotation around second axis
  67891. * @param gamma defines the rotation around third axis
  67892. * @param result defines the target quaternion
  67893. */
  67894. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67895. /**
  67896. * 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)
  67897. * @param axis1 defines the first axis
  67898. * @param axis2 defines the second axis
  67899. * @param axis3 defines the third axis
  67900. * @returns the new quaternion
  67901. */
  67902. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67903. /**
  67904. * 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
  67905. * @param axis1 defines the first axis
  67906. * @param axis2 defines the second axis
  67907. * @param axis3 defines the third axis
  67908. * @param ref defines the target quaternion
  67909. */
  67910. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67911. /**
  67912. * Interpolates between two quaternions
  67913. * @param left defines first quaternion
  67914. * @param right defines second quaternion
  67915. * @param amount defines the gradient to use
  67916. * @returns the new interpolated quaternion
  67917. */
  67918. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67919. /**
  67920. * Interpolates between two quaternions and stores it into a target quaternion
  67921. * @param left defines first quaternion
  67922. * @param right defines second quaternion
  67923. * @param amount defines the gradient to use
  67924. * @param result defines the target quaternion
  67925. */
  67926. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67927. /**
  67928. * Interpolate between two quaternions using Hermite interpolation
  67929. * @param value1 defines first quaternion
  67930. * @param tangent1 defines the incoming tangent
  67931. * @param value2 defines second quaternion
  67932. * @param tangent2 defines the outgoing tangent
  67933. * @param amount defines the target quaternion
  67934. * @returns the new interpolated quaternion
  67935. */
  67936. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67937. }
  67938. /**
  67939. * Class used to store matrix data (4x4)
  67940. */
  67941. export class Matrix {
  67942. private static _updateFlagSeed;
  67943. private static _identityReadOnly;
  67944. private _isIdentity;
  67945. private _isIdentityDirty;
  67946. private _isIdentity3x2;
  67947. private _isIdentity3x2Dirty;
  67948. /**
  67949. * Gets the update flag of the matrix which is an unique number for the matrix.
  67950. * It will be incremented every time the matrix data change.
  67951. * You can use it to speed the comparison between two versions of the same matrix.
  67952. */
  67953. updateFlag: number;
  67954. private readonly _m;
  67955. /**
  67956. * Gets the internal data of the matrix
  67957. */
  67958. readonly m: DeepImmutable<Float32Array>;
  67959. /** @hidden */
  67960. _markAsUpdated(): void;
  67961. /** @hidden */
  67962. private _updateIdentityStatus;
  67963. /**
  67964. * Creates an empty matrix (filled with zeros)
  67965. */
  67966. constructor();
  67967. /**
  67968. * Check if the current matrix is identity
  67969. * @returns true is the matrix is the identity matrix
  67970. */
  67971. isIdentity(): boolean;
  67972. /**
  67973. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67974. * @returns true is the matrix is the identity matrix
  67975. */
  67976. isIdentityAs3x2(): boolean;
  67977. /**
  67978. * Gets the determinant of the matrix
  67979. * @returns the matrix determinant
  67980. */
  67981. determinant(): number;
  67982. /**
  67983. * Returns the matrix as a Float32Array
  67984. * @returns the matrix underlying array
  67985. */
  67986. toArray(): DeepImmutable<Float32Array>;
  67987. /**
  67988. * Returns the matrix as a Float32Array
  67989. * @returns the matrix underlying array.
  67990. */
  67991. asArray(): DeepImmutable<Float32Array>;
  67992. /**
  67993. * Inverts the current matrix in place
  67994. * @returns the current inverted matrix
  67995. */
  67996. invert(): Matrix;
  67997. /**
  67998. * Sets all the matrix elements to zero
  67999. * @returns the current matrix
  68000. */
  68001. reset(): Matrix;
  68002. /**
  68003. * Adds the current matrix with a second one
  68004. * @param other defines the matrix to add
  68005. * @returns a new matrix as the addition of the current matrix and the given one
  68006. */
  68007. add(other: DeepImmutable<Matrix>): Matrix;
  68008. /**
  68009. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68010. * @param other defines the matrix to add
  68011. * @param result defines the target matrix
  68012. * @returns the current matrix
  68013. */
  68014. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68015. /**
  68016. * Adds in place the given matrix to the current matrix
  68017. * @param other defines the second operand
  68018. * @returns the current updated matrix
  68019. */
  68020. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68021. /**
  68022. * Sets the given matrix to the current inverted Matrix
  68023. * @param other defines the target matrix
  68024. * @returns the unmodified current matrix
  68025. */
  68026. invertToRef(other: Matrix): Matrix;
  68027. /**
  68028. * add a value at the specified position in the current Matrix
  68029. * @param index the index of the value within the matrix. between 0 and 15.
  68030. * @param value the value to be added
  68031. * @returns the current updated matrix
  68032. */
  68033. addAtIndex(index: number, value: number): Matrix;
  68034. /**
  68035. * mutiply the specified position in the current Matrix by a value
  68036. * @param index the index of the value within the matrix. between 0 and 15.
  68037. * @param value the value to be added
  68038. * @returns the current updated matrix
  68039. */
  68040. multiplyAtIndex(index: number, value: number): Matrix;
  68041. /**
  68042. * Inserts the translation vector (using 3 floats) in the current matrix
  68043. * @param x defines the 1st component of the translation
  68044. * @param y defines the 2nd component of the translation
  68045. * @param z defines the 3rd component of the translation
  68046. * @returns the current updated matrix
  68047. */
  68048. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68049. /**
  68050. * Adds the translation vector (using 3 floats) in the current matrix
  68051. * @param x defines the 1st component of the translation
  68052. * @param y defines the 2nd component of the translation
  68053. * @param z defines the 3rd component of the translation
  68054. * @returns the current updated matrix
  68055. */
  68056. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68057. /**
  68058. * Inserts the translation vector in the current matrix
  68059. * @param vector3 defines the translation to insert
  68060. * @returns the current updated matrix
  68061. */
  68062. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68063. /**
  68064. * Gets the translation value of the current matrix
  68065. * @returns a new Vector3 as the extracted translation from the matrix
  68066. */
  68067. getTranslation(): Vector3;
  68068. /**
  68069. * Fill a Vector3 with the extracted translation from the matrix
  68070. * @param result defines the Vector3 where to store the translation
  68071. * @returns the current matrix
  68072. */
  68073. getTranslationToRef(result: Vector3): Matrix;
  68074. /**
  68075. * Remove rotation and scaling part from the matrix
  68076. * @returns the updated matrix
  68077. */
  68078. removeRotationAndScaling(): Matrix;
  68079. /**
  68080. * Multiply two matrices
  68081. * @param other defines the second operand
  68082. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68083. */
  68084. multiply(other: DeepImmutable<Matrix>): Matrix;
  68085. /**
  68086. * Copy the current matrix from the given one
  68087. * @param other defines the source matrix
  68088. * @returns the current updated matrix
  68089. */
  68090. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68091. /**
  68092. * Populates the given array from the starting index with the current matrix values
  68093. * @param array defines the target array
  68094. * @param offset defines the offset in the target array where to start storing values
  68095. * @returns the current matrix
  68096. */
  68097. copyToArray(array: Float32Array, offset?: number): Matrix;
  68098. /**
  68099. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68100. * @param other defines the second operand
  68101. * @param result defines the matrix where to store the multiplication
  68102. * @returns the current matrix
  68103. */
  68104. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68105. /**
  68106. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68107. * @param other defines the second operand
  68108. * @param result defines the array where to store the multiplication
  68109. * @param offset defines the offset in the target array where to start storing values
  68110. * @returns the current matrix
  68111. */
  68112. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68113. /**
  68114. * Check equality between this matrix and a second one
  68115. * @param value defines the second matrix to compare
  68116. * @returns true is the current matrix and the given one values are strictly equal
  68117. */
  68118. equals(value: DeepImmutable<Matrix>): boolean;
  68119. /**
  68120. * Clone the current matrix
  68121. * @returns a new matrix from the current matrix
  68122. */
  68123. clone(): Matrix;
  68124. /**
  68125. * Returns the name of the current matrix class
  68126. * @returns the string "Matrix"
  68127. */
  68128. getClassName(): string;
  68129. /**
  68130. * Gets the hash code of the current matrix
  68131. * @returns the hash code
  68132. */
  68133. getHashCode(): number;
  68134. /**
  68135. * Decomposes the current Matrix into a translation, rotation and scaling components
  68136. * @param scale defines the scale vector3 given as a reference to update
  68137. * @param rotation defines the rotation quaternion given as a reference to update
  68138. * @param translation defines the translation vector3 given as a reference to update
  68139. * @returns true if operation was successful
  68140. */
  68141. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68142. /**
  68143. * Gets specific row of the matrix
  68144. * @param index defines the number of the row to get
  68145. * @returns the index-th row of the current matrix as a new Vector4
  68146. */
  68147. getRow(index: number): Nullable<Vector4>;
  68148. /**
  68149. * Sets the index-th row of the current matrix to the vector4 values
  68150. * @param index defines the number of the row to set
  68151. * @param row defines the target vector4
  68152. * @returns the updated current matrix
  68153. */
  68154. setRow(index: number, row: Vector4): Matrix;
  68155. /**
  68156. * Compute the transpose of the matrix
  68157. * @returns the new transposed matrix
  68158. */
  68159. transpose(): Matrix;
  68160. /**
  68161. * Compute the transpose of the matrix and store it in a given matrix
  68162. * @param result defines the target matrix
  68163. * @returns the current matrix
  68164. */
  68165. transposeToRef(result: Matrix): Matrix;
  68166. /**
  68167. * Sets the index-th row of the current matrix with the given 4 x float values
  68168. * @param index defines the row index
  68169. * @param x defines the x component to set
  68170. * @param y defines the y component to set
  68171. * @param z defines the z component to set
  68172. * @param w defines the w component to set
  68173. * @returns the updated current matrix
  68174. */
  68175. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68176. /**
  68177. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68178. * @param scale defines the scale factor
  68179. * @returns a new matrix
  68180. */
  68181. scale(scale: number): Matrix;
  68182. /**
  68183. * Scale the current matrix values by a factor to a given result matrix
  68184. * @param scale defines the scale factor
  68185. * @param result defines the matrix to store the result
  68186. * @returns the current matrix
  68187. */
  68188. scaleToRef(scale: number, result: Matrix): Matrix;
  68189. /**
  68190. * Scale the current matrix values by a factor and add the result to a given matrix
  68191. * @param scale defines the scale factor
  68192. * @param result defines the Matrix to store the result
  68193. * @returns the current matrix
  68194. */
  68195. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68196. /**
  68197. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68198. * @param ref matrix to store the result
  68199. */
  68200. toNormalMatrix(ref: Matrix): void;
  68201. /**
  68202. * Gets only rotation part of the current matrix
  68203. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68204. */
  68205. getRotationMatrix(): Matrix;
  68206. /**
  68207. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68208. * @param result defines the target matrix to store data to
  68209. * @returns the current matrix
  68210. */
  68211. getRotationMatrixToRef(result: Matrix): Matrix;
  68212. /**
  68213. * Toggles model matrix from being right handed to left handed in place and vice versa
  68214. */
  68215. toggleModelMatrixHandInPlace(): void;
  68216. /**
  68217. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68218. */
  68219. toggleProjectionMatrixHandInPlace(): void;
  68220. /**
  68221. * Creates a matrix from an array
  68222. * @param array defines the source array
  68223. * @param offset defines an offset in the source array
  68224. * @returns a new Matrix set from the starting index of the given array
  68225. */
  68226. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68227. /**
  68228. * Copy the content of an array into a given matrix
  68229. * @param array defines the source array
  68230. * @param offset defines an offset in the source array
  68231. * @param result defines the target matrix
  68232. */
  68233. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68234. /**
  68235. * Stores an array into a matrix after having multiplied each component by a given factor
  68236. * @param array defines the source array
  68237. * @param offset defines the offset in the source array
  68238. * @param scale defines the scaling factor
  68239. * @param result defines the target matrix
  68240. */
  68241. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68242. /**
  68243. * Gets an identity matrix that must not be updated
  68244. */
  68245. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68246. /**
  68247. * Stores a list of values (16) inside a given matrix
  68248. * @param initialM11 defines 1st value of 1st row
  68249. * @param initialM12 defines 2nd value of 1st row
  68250. * @param initialM13 defines 3rd value of 1st row
  68251. * @param initialM14 defines 4th value of 1st row
  68252. * @param initialM21 defines 1st value of 2nd row
  68253. * @param initialM22 defines 2nd value of 2nd row
  68254. * @param initialM23 defines 3rd value of 2nd row
  68255. * @param initialM24 defines 4th value of 2nd row
  68256. * @param initialM31 defines 1st value of 3rd row
  68257. * @param initialM32 defines 2nd value of 3rd row
  68258. * @param initialM33 defines 3rd value of 3rd row
  68259. * @param initialM34 defines 4th value of 3rd row
  68260. * @param initialM41 defines 1st value of 4th row
  68261. * @param initialM42 defines 2nd value of 4th row
  68262. * @param initialM43 defines 3rd value of 4th row
  68263. * @param initialM44 defines 4th value of 4th row
  68264. * @param result defines the target matrix
  68265. */
  68266. 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;
  68267. /**
  68268. * Creates new matrix from a list of values (16)
  68269. * @param initialM11 defines 1st value of 1st row
  68270. * @param initialM12 defines 2nd value of 1st row
  68271. * @param initialM13 defines 3rd value of 1st row
  68272. * @param initialM14 defines 4th value of 1st row
  68273. * @param initialM21 defines 1st value of 2nd row
  68274. * @param initialM22 defines 2nd value of 2nd row
  68275. * @param initialM23 defines 3rd value of 2nd row
  68276. * @param initialM24 defines 4th value of 2nd row
  68277. * @param initialM31 defines 1st value of 3rd row
  68278. * @param initialM32 defines 2nd value of 3rd row
  68279. * @param initialM33 defines 3rd value of 3rd row
  68280. * @param initialM34 defines 4th value of 3rd row
  68281. * @param initialM41 defines 1st value of 4th row
  68282. * @param initialM42 defines 2nd value of 4th row
  68283. * @param initialM43 defines 3rd value of 4th row
  68284. * @param initialM44 defines 4th value of 4th row
  68285. * @returns the new matrix
  68286. */
  68287. 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;
  68288. /**
  68289. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68290. * @param scale defines the scale vector3
  68291. * @param rotation defines the rotation quaternion
  68292. * @param translation defines the translation vector3
  68293. * @returns a new matrix
  68294. */
  68295. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68296. /**
  68297. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68298. * @param scale defines the scale vector3
  68299. * @param rotation defines the rotation quaternion
  68300. * @param translation defines the translation vector3
  68301. * @param result defines the target matrix
  68302. */
  68303. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68304. /**
  68305. * Creates a new identity matrix
  68306. * @returns a new identity matrix
  68307. */
  68308. static Identity(): Matrix;
  68309. /**
  68310. * Creates a new identity matrix and stores the result in a given matrix
  68311. * @param result defines the target matrix
  68312. */
  68313. static IdentityToRef(result: Matrix): void;
  68314. /**
  68315. * Creates a new zero matrix
  68316. * @returns a new zero matrix
  68317. */
  68318. static Zero(): Matrix;
  68319. /**
  68320. * Creates a new rotation matrix for "angle" radians around the X axis
  68321. * @param angle defines the angle (in radians) to use
  68322. * @return the new matrix
  68323. */
  68324. static RotationX(angle: number): Matrix;
  68325. /**
  68326. * Creates a new matrix as the invert of a given matrix
  68327. * @param source defines the source matrix
  68328. * @returns the new matrix
  68329. */
  68330. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68331. /**
  68332. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68333. * @param angle defines the angle (in radians) to use
  68334. * @param result defines the target matrix
  68335. */
  68336. static RotationXToRef(angle: number, result: Matrix): void;
  68337. /**
  68338. * Creates a new rotation matrix for "angle" radians around the Y axis
  68339. * @param angle defines the angle (in radians) to use
  68340. * @return the new matrix
  68341. */
  68342. static RotationY(angle: number): Matrix;
  68343. /**
  68344. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68345. * @param angle defines the angle (in radians) to use
  68346. * @param result defines the target matrix
  68347. */
  68348. static RotationYToRef(angle: number, result: Matrix): void;
  68349. /**
  68350. * Creates a new rotation matrix for "angle" radians around the Z axis
  68351. * @param angle defines the angle (in radians) to use
  68352. * @return the new matrix
  68353. */
  68354. static RotationZ(angle: number): Matrix;
  68355. /**
  68356. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68357. * @param angle defines the angle (in radians) to use
  68358. * @param result defines the target matrix
  68359. */
  68360. static RotationZToRef(angle: number, result: Matrix): void;
  68361. /**
  68362. * Creates a new rotation matrix for "angle" radians around the given axis
  68363. * @param axis defines the axis to use
  68364. * @param angle defines the angle (in radians) to use
  68365. * @return the new matrix
  68366. */
  68367. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68368. /**
  68369. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68370. * @param axis defines the axis to use
  68371. * @param angle defines the angle (in radians) to use
  68372. * @param result defines the target matrix
  68373. */
  68374. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68375. /**
  68376. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68377. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68378. * @param from defines the vector to align
  68379. * @param to defines the vector to align to
  68380. * @param result defines the target matrix
  68381. */
  68382. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68383. /**
  68384. * Creates a rotation matrix
  68385. * @param yaw defines the yaw angle in radians (Y axis)
  68386. * @param pitch defines the pitch angle in radians (X axis)
  68387. * @param roll defines the roll angle in radians (X axis)
  68388. * @returns the new rotation matrix
  68389. */
  68390. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68391. /**
  68392. * Creates a rotation matrix and stores it in a given matrix
  68393. * @param yaw defines the yaw angle in radians (Y axis)
  68394. * @param pitch defines the pitch angle in radians (X axis)
  68395. * @param roll defines the roll angle in radians (X axis)
  68396. * @param result defines the target matrix
  68397. */
  68398. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68399. /**
  68400. * Creates a scaling matrix
  68401. * @param x defines the scale factor on X axis
  68402. * @param y defines the scale factor on Y axis
  68403. * @param z defines the scale factor on Z axis
  68404. * @returns the new matrix
  68405. */
  68406. static Scaling(x: number, y: number, z: number): Matrix;
  68407. /**
  68408. * Creates a scaling matrix and stores it in a given matrix
  68409. * @param x defines the scale factor on X axis
  68410. * @param y defines the scale factor on Y axis
  68411. * @param z defines the scale factor on Z axis
  68412. * @param result defines the target matrix
  68413. */
  68414. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68415. /**
  68416. * Creates a translation matrix
  68417. * @param x defines the translation on X axis
  68418. * @param y defines the translation on Y axis
  68419. * @param z defines the translationon Z axis
  68420. * @returns the new matrix
  68421. */
  68422. static Translation(x: number, y: number, z: number): Matrix;
  68423. /**
  68424. * Creates a translation matrix and stores it in a given matrix
  68425. * @param x defines the translation on X axis
  68426. * @param y defines the translation on Y axis
  68427. * @param z defines the translationon Z axis
  68428. * @param result defines the target matrix
  68429. */
  68430. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68431. /**
  68432. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68433. * @param startValue defines the start value
  68434. * @param endValue defines the end value
  68435. * @param gradient defines the gradient factor
  68436. * @returns the new matrix
  68437. */
  68438. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68439. /**
  68440. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68441. * @param startValue defines the start value
  68442. * @param endValue defines the end value
  68443. * @param gradient defines the gradient factor
  68444. * @param result defines the Matrix object where to store data
  68445. */
  68446. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68447. /**
  68448. * Builds a new matrix whose values are computed by:
  68449. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68450. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68451. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68452. * @param startValue defines the first matrix
  68453. * @param endValue defines the second matrix
  68454. * @param gradient defines the gradient between the two matrices
  68455. * @returns the new matrix
  68456. */
  68457. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68458. /**
  68459. * Update a matrix to values which are computed by:
  68460. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68461. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68462. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68463. * @param startValue defines the first matrix
  68464. * @param endValue defines the second matrix
  68465. * @param gradient defines the gradient between the two matrices
  68466. * @param result defines the target matrix
  68467. */
  68468. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68469. /**
  68470. * 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"
  68471. * This function works in left handed mode
  68472. * @param eye defines the final position of the entity
  68473. * @param target defines where the entity should look at
  68474. * @param up defines the up vector for the entity
  68475. * @returns the new matrix
  68476. */
  68477. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68478. /**
  68479. * 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".
  68480. * This function works in left handed mode
  68481. * @param eye defines the final position of the entity
  68482. * @param target defines where the entity should look at
  68483. * @param up defines the up vector for the entity
  68484. * @param result defines the target matrix
  68485. */
  68486. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68487. /**
  68488. * 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"
  68489. * This function works in right handed mode
  68490. * @param eye defines the final position of the entity
  68491. * @param target defines where the entity should look at
  68492. * @param up defines the up vector for the entity
  68493. * @returns the new matrix
  68494. */
  68495. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68496. /**
  68497. * 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".
  68498. * This function works in right handed mode
  68499. * @param eye defines the final position of the entity
  68500. * @param target defines where the entity should look at
  68501. * @param up defines the up vector for the entity
  68502. * @param result defines the target matrix
  68503. */
  68504. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68505. /**
  68506. * Create a left-handed orthographic projection matrix
  68507. * @param width defines the viewport width
  68508. * @param height defines the viewport height
  68509. * @param znear defines the near clip plane
  68510. * @param zfar defines the far clip plane
  68511. * @returns a new matrix as a left-handed orthographic projection matrix
  68512. */
  68513. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68514. /**
  68515. * Store a left-handed orthographic projection to a given matrix
  68516. * @param width defines the viewport width
  68517. * @param height defines the viewport height
  68518. * @param znear defines the near clip plane
  68519. * @param zfar defines the far clip plane
  68520. * @param result defines the target matrix
  68521. */
  68522. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68523. /**
  68524. * Create a left-handed orthographic projection matrix
  68525. * @param left defines the viewport left coordinate
  68526. * @param right defines the viewport right coordinate
  68527. * @param bottom defines the viewport bottom coordinate
  68528. * @param top defines the viewport top coordinate
  68529. * @param znear defines the near clip plane
  68530. * @param zfar defines the far clip plane
  68531. * @returns a new matrix as a left-handed orthographic projection matrix
  68532. */
  68533. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68534. /**
  68535. * Stores a left-handed orthographic projection into a given matrix
  68536. * @param left defines the viewport left coordinate
  68537. * @param right defines the viewport right coordinate
  68538. * @param bottom defines the viewport bottom coordinate
  68539. * @param top defines the viewport top coordinate
  68540. * @param znear defines the near clip plane
  68541. * @param zfar defines the far clip plane
  68542. * @param result defines the target matrix
  68543. */
  68544. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68545. /**
  68546. * Creates a right-handed orthographic projection matrix
  68547. * @param left defines the viewport left coordinate
  68548. * @param right defines the viewport right coordinate
  68549. * @param bottom defines the viewport bottom coordinate
  68550. * @param top defines the viewport top coordinate
  68551. * @param znear defines the near clip plane
  68552. * @param zfar defines the far clip plane
  68553. * @returns a new matrix as a right-handed orthographic projection matrix
  68554. */
  68555. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68556. /**
  68557. * Stores a right-handed orthographic projection into a given matrix
  68558. * @param left defines the viewport left coordinate
  68559. * @param right defines the viewport right coordinate
  68560. * @param bottom defines the viewport bottom coordinate
  68561. * @param top defines the viewport top coordinate
  68562. * @param znear defines the near clip plane
  68563. * @param zfar defines the far clip plane
  68564. * @param result defines the target matrix
  68565. */
  68566. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68567. /**
  68568. * Creates a left-handed perspective projection matrix
  68569. * @param width defines the viewport width
  68570. * @param height defines the viewport height
  68571. * @param znear defines the near clip plane
  68572. * @param zfar defines the far clip plane
  68573. * @returns a new matrix as a left-handed perspective projection matrix
  68574. */
  68575. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68576. /**
  68577. * Creates a left-handed perspective projection matrix
  68578. * @param fov defines the horizontal field of view
  68579. * @param aspect defines the aspect ratio
  68580. * @param znear defines the near clip plane
  68581. * @param zfar defines the far clip plane
  68582. * @returns a new matrix as a left-handed perspective projection matrix
  68583. */
  68584. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68585. /**
  68586. * Stores a left-handed perspective projection into a given matrix
  68587. * @param fov defines the horizontal field of view
  68588. * @param aspect defines the aspect ratio
  68589. * @param znear defines the near clip plane
  68590. * @param zfar defines the far clip plane
  68591. * @param result defines the target matrix
  68592. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68593. */
  68594. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68595. /**
  68596. * Creates a right-handed perspective projection matrix
  68597. * @param fov defines the horizontal field of view
  68598. * @param aspect defines the aspect ratio
  68599. * @param znear defines the near clip plane
  68600. * @param zfar defines the far clip plane
  68601. * @returns a new matrix as a right-handed perspective projection matrix
  68602. */
  68603. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68604. /**
  68605. * Stores a right-handed perspective projection into a given matrix
  68606. * @param fov defines the horizontal field of view
  68607. * @param aspect defines the aspect ratio
  68608. * @param znear defines the near clip plane
  68609. * @param zfar defines the far clip plane
  68610. * @param result defines the target matrix
  68611. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68612. */
  68613. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68614. /**
  68615. * Stores a perspective projection for WebVR info a given matrix
  68616. * @param fov defines the field of view
  68617. * @param znear defines the near clip plane
  68618. * @param zfar defines the far clip plane
  68619. * @param result defines the target matrix
  68620. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68621. */
  68622. static PerspectiveFovWebVRToRef(fov: {
  68623. upDegrees: number;
  68624. downDegrees: number;
  68625. leftDegrees: number;
  68626. rightDegrees: number;
  68627. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68628. /**
  68629. * Computes a complete transformation matrix
  68630. * @param viewport defines the viewport to use
  68631. * @param world defines the world matrix
  68632. * @param view defines the view matrix
  68633. * @param projection defines the projection matrix
  68634. * @param zmin defines the near clip plane
  68635. * @param zmax defines the far clip plane
  68636. * @returns the transformation matrix
  68637. */
  68638. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68639. /**
  68640. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68641. * @param matrix defines the matrix to use
  68642. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68643. */
  68644. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68645. /**
  68646. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68647. * @param matrix defines the matrix to use
  68648. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68649. */
  68650. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68651. /**
  68652. * Compute the transpose of a given matrix
  68653. * @param matrix defines the matrix to transpose
  68654. * @returns the new matrix
  68655. */
  68656. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68657. /**
  68658. * Compute the transpose of a matrix and store it in a target matrix
  68659. * @param matrix defines the matrix to transpose
  68660. * @param result defines the target matrix
  68661. */
  68662. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68663. /**
  68664. * Computes a reflection matrix from a plane
  68665. * @param plane defines the reflection plane
  68666. * @returns a new matrix
  68667. */
  68668. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68669. /**
  68670. * Computes a reflection matrix from a plane
  68671. * @param plane defines the reflection plane
  68672. * @param result defines the target matrix
  68673. */
  68674. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68675. /**
  68676. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68677. * @param xaxis defines the value of the 1st axis
  68678. * @param yaxis defines the value of the 2nd axis
  68679. * @param zaxis defines the value of the 3rd axis
  68680. * @param result defines the target matrix
  68681. */
  68682. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68683. /**
  68684. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68685. * @param quat defines the quaternion to use
  68686. * @param result defines the target matrix
  68687. */
  68688. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68689. }
  68690. /**
  68691. * @hidden
  68692. */
  68693. export class TmpVectors {
  68694. static Vector2: Vector2[];
  68695. static Vector3: Vector3[];
  68696. static Vector4: Vector4[];
  68697. static Quaternion: Quaternion[];
  68698. static Matrix: Matrix[];
  68699. }
  68700. }
  68701. declare module BABYLON {
  68702. /** Defines the cross module used constants to avoid circular dependncies */
  68703. export class Constants {
  68704. /** Defines that alpha blending is disabled */
  68705. static readonly ALPHA_DISABLE: number;
  68706. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68707. static readonly ALPHA_ADD: number;
  68708. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68709. static readonly ALPHA_COMBINE: number;
  68710. /** Defines that alpha blending to DEST - SRC * DEST */
  68711. static readonly ALPHA_SUBTRACT: number;
  68712. /** Defines that alpha blending to SRC * DEST */
  68713. static readonly ALPHA_MULTIPLY: number;
  68714. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68715. static readonly ALPHA_MAXIMIZED: number;
  68716. /** Defines that alpha blending to SRC + DEST */
  68717. static readonly ALPHA_ONEONE: number;
  68718. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68719. static readonly ALPHA_PREMULTIPLIED: number;
  68720. /**
  68721. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68722. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68723. */
  68724. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68725. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68726. static readonly ALPHA_INTERPOLATE: number;
  68727. /**
  68728. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68729. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68730. */
  68731. static readonly ALPHA_SCREENMODE: number;
  68732. /** Defines that the ressource is not delayed*/
  68733. static readonly DELAYLOADSTATE_NONE: number;
  68734. /** Defines that the ressource was successfully delay loaded */
  68735. static readonly DELAYLOADSTATE_LOADED: number;
  68736. /** Defines that the ressource is currently delay loading */
  68737. static readonly DELAYLOADSTATE_LOADING: number;
  68738. /** Defines that the ressource is delayed and has not started loading */
  68739. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68741. static readonly NEVER: number;
  68742. /** 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 */
  68743. static readonly ALWAYS: number;
  68744. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68745. static readonly LESS: number;
  68746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68747. static readonly EQUAL: number;
  68748. /** 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 */
  68749. static readonly LEQUAL: number;
  68750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68751. static readonly GREATER: number;
  68752. /** 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 */
  68753. static readonly GEQUAL: number;
  68754. /** 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 */
  68755. static readonly NOTEQUAL: number;
  68756. /** Passed to stencilOperation to specify that stencil value must be kept */
  68757. static readonly KEEP: number;
  68758. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68759. static readonly REPLACE: number;
  68760. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68761. static readonly INCR: number;
  68762. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68763. static readonly DECR: number;
  68764. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68765. static readonly INVERT: number;
  68766. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68767. static readonly INCR_WRAP: number;
  68768. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68769. static readonly DECR_WRAP: number;
  68770. /** Texture is not repeating outside of 0..1 UVs */
  68771. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68772. /** Texture is repeating outside of 0..1 UVs */
  68773. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68774. /** Texture is repeating and mirrored */
  68775. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68776. /** ALPHA */
  68777. static readonly TEXTUREFORMAT_ALPHA: number;
  68778. /** LUMINANCE */
  68779. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68780. /** LUMINANCE_ALPHA */
  68781. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68782. /** RGB */
  68783. static readonly TEXTUREFORMAT_RGB: number;
  68784. /** RGBA */
  68785. static readonly TEXTUREFORMAT_RGBA: number;
  68786. /** RED */
  68787. static readonly TEXTUREFORMAT_RED: number;
  68788. /** RED (2nd reference) */
  68789. static readonly TEXTUREFORMAT_R: number;
  68790. /** RG */
  68791. static readonly TEXTUREFORMAT_RG: number;
  68792. /** RED_INTEGER */
  68793. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68794. /** RED_INTEGER (2nd reference) */
  68795. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68796. /** RG_INTEGER */
  68797. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68798. /** RGB_INTEGER */
  68799. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68800. /** RGBA_INTEGER */
  68801. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68802. /** UNSIGNED_BYTE */
  68803. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68804. /** UNSIGNED_BYTE (2nd reference) */
  68805. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68806. /** FLOAT */
  68807. static readonly TEXTURETYPE_FLOAT: number;
  68808. /** HALF_FLOAT */
  68809. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68810. /** BYTE */
  68811. static readonly TEXTURETYPE_BYTE: number;
  68812. /** SHORT */
  68813. static readonly TEXTURETYPE_SHORT: number;
  68814. /** UNSIGNED_SHORT */
  68815. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68816. /** INT */
  68817. static readonly TEXTURETYPE_INT: number;
  68818. /** UNSIGNED_INT */
  68819. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68820. /** UNSIGNED_SHORT_4_4_4_4 */
  68821. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68822. /** UNSIGNED_SHORT_5_5_5_1 */
  68823. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68824. /** UNSIGNED_SHORT_5_6_5 */
  68825. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68826. /** UNSIGNED_INT_2_10_10_10_REV */
  68827. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68828. /** UNSIGNED_INT_24_8 */
  68829. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68830. /** UNSIGNED_INT_10F_11F_11F_REV */
  68831. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68832. /** UNSIGNED_INT_5_9_9_9_REV */
  68833. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68834. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68835. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68836. /** nearest is mag = nearest and min = nearest and mip = linear */
  68837. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68838. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68839. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68840. /** Trilinear is mag = linear and min = linear and mip = linear */
  68841. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68842. /** nearest is mag = nearest and min = nearest and mip = linear */
  68843. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68844. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68845. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68846. /** Trilinear is mag = linear and min = linear and mip = linear */
  68847. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68848. /** mag = nearest and min = nearest and mip = nearest */
  68849. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68850. /** mag = nearest and min = linear and mip = nearest */
  68851. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68852. /** mag = nearest and min = linear and mip = linear */
  68853. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68854. /** mag = nearest and min = linear and mip = none */
  68855. static readonly TEXTURE_NEAREST_LINEAR: number;
  68856. /** mag = nearest and min = nearest and mip = none */
  68857. static readonly TEXTURE_NEAREST_NEAREST: number;
  68858. /** mag = linear and min = nearest and mip = nearest */
  68859. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68860. /** mag = linear and min = nearest and mip = linear */
  68861. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68862. /** mag = linear and min = linear and mip = none */
  68863. static readonly TEXTURE_LINEAR_LINEAR: number;
  68864. /** mag = linear and min = nearest and mip = none */
  68865. static readonly TEXTURE_LINEAR_NEAREST: number;
  68866. /** Explicit coordinates mode */
  68867. static readonly TEXTURE_EXPLICIT_MODE: number;
  68868. /** Spherical coordinates mode */
  68869. static readonly TEXTURE_SPHERICAL_MODE: number;
  68870. /** Planar coordinates mode */
  68871. static readonly TEXTURE_PLANAR_MODE: number;
  68872. /** Cubic coordinates mode */
  68873. static readonly TEXTURE_CUBIC_MODE: number;
  68874. /** Projection coordinates mode */
  68875. static readonly TEXTURE_PROJECTION_MODE: number;
  68876. /** Skybox coordinates mode */
  68877. static readonly TEXTURE_SKYBOX_MODE: number;
  68878. /** Inverse Cubic coordinates mode */
  68879. static readonly TEXTURE_INVCUBIC_MODE: number;
  68880. /** Equirectangular coordinates mode */
  68881. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68882. /** Equirectangular Fixed coordinates mode */
  68883. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68884. /** Equirectangular Fixed Mirrored coordinates mode */
  68885. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68886. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68887. static readonly SCALEMODE_FLOOR: number;
  68888. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68889. static readonly SCALEMODE_NEAREST: number;
  68890. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68891. static readonly SCALEMODE_CEILING: number;
  68892. /**
  68893. * The dirty texture flag value
  68894. */
  68895. static readonly MATERIAL_TextureDirtyFlag: number;
  68896. /**
  68897. * The dirty light flag value
  68898. */
  68899. static readonly MATERIAL_LightDirtyFlag: number;
  68900. /**
  68901. * The dirty fresnel flag value
  68902. */
  68903. static readonly MATERIAL_FresnelDirtyFlag: number;
  68904. /**
  68905. * The dirty attribute flag value
  68906. */
  68907. static readonly MATERIAL_AttributesDirtyFlag: number;
  68908. /**
  68909. * The dirty misc flag value
  68910. */
  68911. static readonly MATERIAL_MiscDirtyFlag: number;
  68912. /**
  68913. * The all dirty flag value
  68914. */
  68915. static readonly MATERIAL_AllDirtyFlag: number;
  68916. /**
  68917. * Returns the triangle fill mode
  68918. */
  68919. static readonly MATERIAL_TriangleFillMode: number;
  68920. /**
  68921. * Returns the wireframe mode
  68922. */
  68923. static readonly MATERIAL_WireFrameFillMode: number;
  68924. /**
  68925. * Returns the point fill mode
  68926. */
  68927. static readonly MATERIAL_PointFillMode: number;
  68928. /**
  68929. * Returns the point list draw mode
  68930. */
  68931. static readonly MATERIAL_PointListDrawMode: number;
  68932. /**
  68933. * Returns the line list draw mode
  68934. */
  68935. static readonly MATERIAL_LineListDrawMode: number;
  68936. /**
  68937. * Returns the line loop draw mode
  68938. */
  68939. static readonly MATERIAL_LineLoopDrawMode: number;
  68940. /**
  68941. * Returns the line strip draw mode
  68942. */
  68943. static readonly MATERIAL_LineStripDrawMode: number;
  68944. /**
  68945. * Returns the triangle strip draw mode
  68946. */
  68947. static readonly MATERIAL_TriangleStripDrawMode: number;
  68948. /**
  68949. * Returns the triangle fan draw mode
  68950. */
  68951. static readonly MATERIAL_TriangleFanDrawMode: number;
  68952. /**
  68953. * Stores the clock-wise side orientation
  68954. */
  68955. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68956. /**
  68957. * Stores the counter clock-wise side orientation
  68958. */
  68959. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68960. /**
  68961. * Nothing
  68962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68963. */
  68964. static readonly ACTION_NothingTrigger: number;
  68965. /**
  68966. * On pick
  68967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68968. */
  68969. static readonly ACTION_OnPickTrigger: number;
  68970. /**
  68971. * On left pick
  68972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68973. */
  68974. static readonly ACTION_OnLeftPickTrigger: number;
  68975. /**
  68976. * On right pick
  68977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68978. */
  68979. static readonly ACTION_OnRightPickTrigger: number;
  68980. /**
  68981. * On center pick
  68982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68983. */
  68984. static readonly ACTION_OnCenterPickTrigger: number;
  68985. /**
  68986. * On pick down
  68987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68988. */
  68989. static readonly ACTION_OnPickDownTrigger: number;
  68990. /**
  68991. * On double pick
  68992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68993. */
  68994. static readonly ACTION_OnDoublePickTrigger: number;
  68995. /**
  68996. * On pick up
  68997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68998. */
  68999. static readonly ACTION_OnPickUpTrigger: number;
  69000. /**
  69001. * On pick out.
  69002. * This trigger will only be raised if you also declared a OnPickDown
  69003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69004. */
  69005. static readonly ACTION_OnPickOutTrigger: number;
  69006. /**
  69007. * On long press
  69008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69009. */
  69010. static readonly ACTION_OnLongPressTrigger: number;
  69011. /**
  69012. * On pointer over
  69013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69014. */
  69015. static readonly ACTION_OnPointerOverTrigger: number;
  69016. /**
  69017. * On pointer out
  69018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69019. */
  69020. static readonly ACTION_OnPointerOutTrigger: number;
  69021. /**
  69022. * On every frame
  69023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69024. */
  69025. static readonly ACTION_OnEveryFrameTrigger: number;
  69026. /**
  69027. * On intersection enter
  69028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69029. */
  69030. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69031. /**
  69032. * On intersection exit
  69033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69034. */
  69035. static readonly ACTION_OnIntersectionExitTrigger: number;
  69036. /**
  69037. * On key down
  69038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69039. */
  69040. static readonly ACTION_OnKeyDownTrigger: number;
  69041. /**
  69042. * On key up
  69043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69044. */
  69045. static readonly ACTION_OnKeyUpTrigger: number;
  69046. /**
  69047. * Billboard mode will only apply to Y axis
  69048. */
  69049. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69050. /**
  69051. * Billboard mode will apply to all axes
  69052. */
  69053. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69054. /**
  69055. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69056. */
  69057. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69058. /**
  69059. * Gets or sets base Assets URL
  69060. */
  69061. static PARTICLES_BaseAssetsUrl: string;
  69062. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69063. * Test order :
  69064. * Is the bounding sphere outside the frustum ?
  69065. * If not, are the bounding box vertices outside the frustum ?
  69066. * It not, then the cullable object is in the frustum.
  69067. */
  69068. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69069. /** Culling strategy : Bounding Sphere Only.
  69070. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69071. * It's also less accurate than the standard because some not visible objects can still be selected.
  69072. * Test : is the bounding sphere outside the frustum ?
  69073. * If not, then the cullable object is in the frustum.
  69074. */
  69075. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69076. /** Culling strategy : Optimistic Inclusion.
  69077. * This in an inclusion test first, then the standard exclusion test.
  69078. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69079. * 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.
  69080. * Anyway, it's as accurate as the standard strategy.
  69081. * Test :
  69082. * Is the cullable object bounding sphere center in the frustum ?
  69083. * If not, apply the default culling strategy.
  69084. */
  69085. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69086. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69087. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69088. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69089. * 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.
  69090. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69091. * Test :
  69092. * Is the cullable object bounding sphere center in the frustum ?
  69093. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69094. */
  69095. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69096. /**
  69097. * No logging while loading
  69098. */
  69099. static readonly SCENELOADER_NO_LOGGING: number;
  69100. /**
  69101. * Minimal logging while loading
  69102. */
  69103. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69104. /**
  69105. * Summary logging while loading
  69106. */
  69107. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69108. /**
  69109. * Detailled logging while loading
  69110. */
  69111. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69112. }
  69113. }
  69114. declare module BABYLON {
  69115. /**
  69116. * Class used to store and describe the pipeline context associated with an effect
  69117. */
  69118. export interface IPipelineContext {
  69119. /**
  69120. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69121. */
  69122. isAsync: boolean;
  69123. /**
  69124. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69125. */
  69126. isReady: boolean;
  69127. /** @hidden */
  69128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69129. }
  69130. }
  69131. declare module BABYLON {
  69132. /** @hidden */
  69133. export interface IShaderProcessor {
  69134. attributeProcessor?: (attribute: string) => string;
  69135. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69136. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69137. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69138. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69139. lineProcessor?: (line: string, isFragment: boolean) => string;
  69140. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69141. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69142. }
  69143. }
  69144. declare module BABYLON {
  69145. /** @hidden */
  69146. export interface ProcessingOptions {
  69147. defines: string[];
  69148. indexParameters: any;
  69149. isFragment: boolean;
  69150. shouldUseHighPrecisionShader: boolean;
  69151. supportsUniformBuffers: boolean;
  69152. shadersRepository: string;
  69153. includesShadersStore: {
  69154. [key: string]: string;
  69155. };
  69156. processor?: IShaderProcessor;
  69157. version: string;
  69158. platformName: string;
  69159. lookForClosingBracketForUniformBuffer?: boolean;
  69160. }
  69161. }
  69162. declare module BABYLON {
  69163. /**
  69164. * Helper to manipulate strings
  69165. */
  69166. export class StringTools {
  69167. /**
  69168. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69169. * @param str Source string
  69170. * @param suffix Suffix to search for in the source string
  69171. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69172. */
  69173. static EndsWith(str: string, suffix: string): boolean;
  69174. /**
  69175. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69176. * @param str Source string
  69177. * @param suffix Suffix to search for in the source string
  69178. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69179. */
  69180. static StartsWith(str: string, suffix: string): boolean;
  69181. }
  69182. }
  69183. declare module BABYLON {
  69184. /** @hidden */
  69185. export class ShaderCodeNode {
  69186. line: string;
  69187. children: ShaderCodeNode[];
  69188. additionalDefineKey?: string;
  69189. additionalDefineValue?: string;
  69190. isValid(preprocessors: {
  69191. [key: string]: string;
  69192. }): boolean;
  69193. process(preprocessors: {
  69194. [key: string]: string;
  69195. }, options: ProcessingOptions): string;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /** @hidden */
  69200. export class ShaderCodeCursor {
  69201. private _lines;
  69202. lineIndex: number;
  69203. readonly currentLine: string;
  69204. readonly canRead: boolean;
  69205. lines: string[];
  69206. }
  69207. }
  69208. declare module BABYLON {
  69209. /** @hidden */
  69210. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69211. process(preprocessors: {
  69212. [key: string]: string;
  69213. }, options: ProcessingOptions): string;
  69214. }
  69215. }
  69216. declare module BABYLON {
  69217. /** @hidden */
  69218. export class ShaderDefineExpression {
  69219. isTrue(preprocessors: {
  69220. [key: string]: string;
  69221. }): boolean;
  69222. }
  69223. }
  69224. declare module BABYLON {
  69225. /** @hidden */
  69226. export class ShaderCodeTestNode extends ShaderCodeNode {
  69227. testExpression: ShaderDefineExpression;
  69228. isValid(preprocessors: {
  69229. [key: string]: string;
  69230. }): boolean;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /** @hidden */
  69235. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69236. define: string;
  69237. not: boolean;
  69238. constructor(define: string, not?: boolean);
  69239. isTrue(preprocessors: {
  69240. [key: string]: string;
  69241. }): boolean;
  69242. }
  69243. }
  69244. declare module BABYLON {
  69245. /** @hidden */
  69246. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69247. leftOperand: ShaderDefineExpression;
  69248. rightOperand: ShaderDefineExpression;
  69249. isTrue(preprocessors: {
  69250. [key: string]: string;
  69251. }): boolean;
  69252. }
  69253. }
  69254. declare module BABYLON {
  69255. /** @hidden */
  69256. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69257. leftOperand: ShaderDefineExpression;
  69258. rightOperand: ShaderDefineExpression;
  69259. isTrue(preprocessors: {
  69260. [key: string]: string;
  69261. }): boolean;
  69262. }
  69263. }
  69264. declare module BABYLON {
  69265. /** @hidden */
  69266. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69267. define: string;
  69268. operand: string;
  69269. testValue: string;
  69270. constructor(define: string, operand: string, testValue: string);
  69271. isTrue(preprocessors: {
  69272. [key: string]: string;
  69273. }): boolean;
  69274. }
  69275. }
  69276. declare module BABYLON {
  69277. /**
  69278. * @ignore
  69279. * Application error to support additional information when loading a file
  69280. */
  69281. export class LoadFileError extends Error {
  69282. /** defines the optional web request */
  69283. request?: WebRequest | undefined;
  69284. private static _setPrototypeOf;
  69285. /**
  69286. * Creates a new LoadFileError
  69287. * @param message defines the message of the error
  69288. * @param request defines the optional web request
  69289. */
  69290. constructor(message: string,
  69291. /** defines the optional web request */
  69292. request?: WebRequest | undefined);
  69293. }
  69294. }
  69295. declare module BABYLON {
  69296. /**
  69297. * Class used to enable access to offline support
  69298. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69299. */
  69300. export interface IOfflineProvider {
  69301. /**
  69302. * Gets a boolean indicating if scene must be saved in the database
  69303. */
  69304. enableSceneOffline: boolean;
  69305. /**
  69306. * Gets a boolean indicating if textures must be saved in the database
  69307. */
  69308. enableTexturesOffline: boolean;
  69309. /**
  69310. * Open the offline support and make it available
  69311. * @param successCallback defines the callback to call on success
  69312. * @param errorCallback defines the callback to call on error
  69313. */
  69314. open(successCallback: () => void, errorCallback: () => void): void;
  69315. /**
  69316. * Loads an image from the offline support
  69317. * @param url defines the url to load from
  69318. * @param image defines the target DOM image
  69319. */
  69320. loadImage(url: string, image: HTMLImageElement): void;
  69321. /**
  69322. * Loads a file from offline support
  69323. * @param url defines the URL to load from
  69324. * @param sceneLoaded defines a callback to call on success
  69325. * @param progressCallBack defines a callback to call when progress changed
  69326. * @param errorCallback defines a callback to call on error
  69327. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69328. */
  69329. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * Class used to help managing file picking and drag'n'drop
  69335. * File Storage
  69336. */
  69337. export class FilesInputStore {
  69338. /**
  69339. * List of files ready to be loaded
  69340. */
  69341. static FilesToLoad: {
  69342. [key: string]: File;
  69343. };
  69344. }
  69345. }
  69346. declare module BABYLON {
  69347. /**
  69348. * Class used to define a retry strategy when error happens while loading assets
  69349. */
  69350. export class RetryStrategy {
  69351. /**
  69352. * Function used to defines an exponential back off strategy
  69353. * @param maxRetries defines the maximum number of retries (3 by default)
  69354. * @param baseInterval defines the interval between retries
  69355. * @returns the strategy function to use
  69356. */
  69357. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69358. }
  69359. }
  69360. declare module BABYLON {
  69361. /**
  69362. * @hidden
  69363. */
  69364. export class FileTools {
  69365. /**
  69366. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69367. */
  69368. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69369. /**
  69370. * Gets or sets the base URL to use to load assets
  69371. */
  69372. static BaseUrl: string;
  69373. /**
  69374. * Default behaviour for cors in the application.
  69375. * It can be a string if the expected behavior is identical in the entire app.
  69376. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69377. */
  69378. static CorsBehavior: string | ((url: string | string[]) => string);
  69379. /**
  69380. * Gets or sets a function used to pre-process url before using them to load assets
  69381. */
  69382. static PreprocessUrl: (url: string) => string;
  69383. /**
  69384. * Removes unwanted characters from an url
  69385. * @param url defines the url to clean
  69386. * @returns the cleaned url
  69387. */
  69388. private static _CleanUrl;
  69389. /**
  69390. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69391. * @param url define the url we are trying
  69392. * @param element define the dom element where to configure the cors policy
  69393. */
  69394. static SetCorsBehavior(url: string | string[], element: {
  69395. crossOrigin: string | null;
  69396. }): void;
  69397. /**
  69398. * Loads an image as an HTMLImageElement.
  69399. * @param input url string, ArrayBuffer, or Blob to load
  69400. * @param onLoad callback called when the image successfully loads
  69401. * @param onError callback called when the image fails to load
  69402. * @param offlineProvider offline provider for caching
  69403. * @returns the HTMLImageElement of the loaded image
  69404. */
  69405. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69406. /**
  69407. * Loads a file
  69408. * @param fileToLoad defines the file to load
  69409. * @param callback defines the callback to call when data is loaded
  69410. * @param progressCallBack defines the callback to call during loading process
  69411. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69412. * @returns a file request object
  69413. */
  69414. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69415. /**
  69416. * Loads a file
  69417. * @param url url string, ArrayBuffer, or Blob to load
  69418. * @param onSuccess callback called when the file successfully loads
  69419. * @param onProgress callback called while file is loading (if the server supports this mode)
  69420. * @param offlineProvider defines the offline provider for caching
  69421. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69422. * @param onError callback called when the file fails to load
  69423. * @returns a file request object
  69424. */
  69425. 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;
  69426. /**
  69427. * Checks if the loaded document was accessed via `file:`-Protocol.
  69428. * @returns boolean
  69429. */
  69430. static IsFileURL(): boolean;
  69431. }
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export class ShaderProcessor {
  69436. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69437. private static _ProcessPrecision;
  69438. private static _ExtractOperation;
  69439. private static _BuildSubExpression;
  69440. private static _BuildExpression;
  69441. private static _MoveCursorWithinIf;
  69442. private static _MoveCursor;
  69443. private static _EvaluatePreProcessors;
  69444. private static _PreparePreProcessors;
  69445. private static _ProcessShaderConversion;
  69446. private static _ProcessIncludes;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Class used to hold a RBG color
  69452. */
  69453. export class Color3 {
  69454. /**
  69455. * Defines the red component (between 0 and 1, default is 0)
  69456. */
  69457. r: number;
  69458. /**
  69459. * Defines the green component (between 0 and 1, default is 0)
  69460. */
  69461. g: number;
  69462. /**
  69463. * Defines the blue component (between 0 and 1, default is 0)
  69464. */
  69465. b: number;
  69466. /**
  69467. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69468. * @param r defines the red component (between 0 and 1, default is 0)
  69469. * @param g defines the green component (between 0 and 1, default is 0)
  69470. * @param b defines the blue component (between 0 and 1, default is 0)
  69471. */
  69472. constructor(
  69473. /**
  69474. * Defines the red component (between 0 and 1, default is 0)
  69475. */
  69476. r?: number,
  69477. /**
  69478. * Defines the green component (between 0 and 1, default is 0)
  69479. */
  69480. g?: number,
  69481. /**
  69482. * Defines the blue component (between 0 and 1, default is 0)
  69483. */
  69484. b?: number);
  69485. /**
  69486. * Creates a string with the Color3 current values
  69487. * @returns the string representation of the Color3 object
  69488. */
  69489. toString(): string;
  69490. /**
  69491. * Returns the string "Color3"
  69492. * @returns "Color3"
  69493. */
  69494. getClassName(): string;
  69495. /**
  69496. * Compute the Color3 hash code
  69497. * @returns an unique number that can be used to hash Color3 objects
  69498. */
  69499. getHashCode(): number;
  69500. /**
  69501. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69502. * @param array defines the array where to store the r,g,b components
  69503. * @param index defines an optional index in the target array to define where to start storing values
  69504. * @returns the current Color3 object
  69505. */
  69506. toArray(array: FloatArray, index?: number): Color3;
  69507. /**
  69508. * Returns a new Color4 object from the current Color3 and the given alpha
  69509. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69510. * @returns a new Color4 object
  69511. */
  69512. toColor4(alpha?: number): Color4;
  69513. /**
  69514. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69515. * @returns the new array
  69516. */
  69517. asArray(): number[];
  69518. /**
  69519. * Returns the luminance value
  69520. * @returns a float value
  69521. */
  69522. toLuminance(): number;
  69523. /**
  69524. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69525. * @param otherColor defines the second operand
  69526. * @returns the new Color3 object
  69527. */
  69528. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69529. /**
  69530. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69531. * @param otherColor defines the second operand
  69532. * @param result defines the Color3 object where to store the result
  69533. * @returns the current Color3
  69534. */
  69535. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69536. /**
  69537. * Determines equality between Color3 objects
  69538. * @param otherColor defines the second operand
  69539. * @returns true if the rgb values are equal to the given ones
  69540. */
  69541. equals(otherColor: DeepImmutable<Color3>): boolean;
  69542. /**
  69543. * Determines equality between the current Color3 object and a set of r,b,g values
  69544. * @param r defines the red component to check
  69545. * @param g defines the green component to check
  69546. * @param b defines the blue component to check
  69547. * @returns true if the rgb values are equal to the given ones
  69548. */
  69549. equalsFloats(r: number, g: number, b: number): boolean;
  69550. /**
  69551. * Multiplies in place each rgb value by scale
  69552. * @param scale defines the scaling factor
  69553. * @returns the updated Color3
  69554. */
  69555. scale(scale: number): Color3;
  69556. /**
  69557. * Multiplies the rgb values by scale and stores the result into "result"
  69558. * @param scale defines the scaling factor
  69559. * @param result defines the Color3 object where to store the result
  69560. * @returns the unmodified current Color3
  69561. */
  69562. scaleToRef(scale: number, result: Color3): Color3;
  69563. /**
  69564. * Scale the current Color3 values by a factor and add the result to a given Color3
  69565. * @param scale defines the scale factor
  69566. * @param result defines color to store the result into
  69567. * @returns the unmodified current Color3
  69568. */
  69569. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69570. /**
  69571. * Clamps the rgb values by the min and max values and stores the result into "result"
  69572. * @param min defines minimum clamping value (default is 0)
  69573. * @param max defines maximum clamping value (default is 1)
  69574. * @param result defines color to store the result into
  69575. * @returns the original Color3
  69576. */
  69577. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69578. /**
  69579. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69580. * @param otherColor defines the second operand
  69581. * @returns the new Color3
  69582. */
  69583. add(otherColor: DeepImmutable<Color3>): Color3;
  69584. /**
  69585. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69586. * @param otherColor defines the second operand
  69587. * @param result defines Color3 object to store the result into
  69588. * @returns the unmodified current Color3
  69589. */
  69590. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69591. /**
  69592. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69593. * @param otherColor defines the second operand
  69594. * @returns the new Color3
  69595. */
  69596. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69597. /**
  69598. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69599. * @param otherColor defines the second operand
  69600. * @param result defines Color3 object to store the result into
  69601. * @returns the unmodified current Color3
  69602. */
  69603. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69604. /**
  69605. * Copy the current object
  69606. * @returns a new Color3 copied the current one
  69607. */
  69608. clone(): Color3;
  69609. /**
  69610. * Copies the rgb values from the source in the current Color3
  69611. * @param source defines the source Color3 object
  69612. * @returns the updated Color3 object
  69613. */
  69614. copyFrom(source: DeepImmutable<Color3>): Color3;
  69615. /**
  69616. * Updates the Color3 rgb values from the given floats
  69617. * @param r defines the red component to read from
  69618. * @param g defines the green component to read from
  69619. * @param b defines the blue component to read from
  69620. * @returns the current Color3 object
  69621. */
  69622. copyFromFloats(r: number, g: number, b: number): Color3;
  69623. /**
  69624. * Updates the Color3 rgb values from the given floats
  69625. * @param r defines the red component to read from
  69626. * @param g defines the green component to read from
  69627. * @param b defines the blue component to read from
  69628. * @returns the current Color3 object
  69629. */
  69630. set(r: number, g: number, b: number): Color3;
  69631. /**
  69632. * Compute the Color3 hexadecimal code as a string
  69633. * @returns a string containing the hexadecimal representation of the Color3 object
  69634. */
  69635. toHexString(): string;
  69636. /**
  69637. * Computes a new Color3 converted from the current one to linear space
  69638. * @returns a new Color3 object
  69639. */
  69640. toLinearSpace(): Color3;
  69641. /**
  69642. * Converts current color in rgb space to HSV values
  69643. * @returns a new color3 representing the HSV values
  69644. */
  69645. toHSV(): Color3;
  69646. /**
  69647. * Converts current color in rgb space to HSV values
  69648. * @param result defines the Color3 where to store the HSV values
  69649. */
  69650. toHSVToRef(result: Color3): void;
  69651. /**
  69652. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69653. * @param convertedColor defines the Color3 object where to store the linear space version
  69654. * @returns the unmodified Color3
  69655. */
  69656. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69657. /**
  69658. * Computes a new Color3 converted from the current one to gamma space
  69659. * @returns a new Color3 object
  69660. */
  69661. toGammaSpace(): Color3;
  69662. /**
  69663. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69664. * @param convertedColor defines the Color3 object where to store the gamma space version
  69665. * @returns the unmodified Color3
  69666. */
  69667. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69668. private static _BlackReadOnly;
  69669. /**
  69670. * Convert Hue, saturation and value to a Color3 (RGB)
  69671. * @param hue defines the hue
  69672. * @param saturation defines the saturation
  69673. * @param value defines the value
  69674. * @param result defines the Color3 where to store the RGB values
  69675. */
  69676. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69677. /**
  69678. * Creates a new Color3 from the string containing valid hexadecimal values
  69679. * @param hex defines a string containing valid hexadecimal values
  69680. * @returns a new Color3 object
  69681. */
  69682. static FromHexString(hex: string): Color3;
  69683. /**
  69684. * Creates a new Color3 from the starting index of the given array
  69685. * @param array defines the source array
  69686. * @param offset defines an offset in the source array
  69687. * @returns a new Color3 object
  69688. */
  69689. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69690. /**
  69691. * Creates a new Color3 from integer values (< 256)
  69692. * @param r defines the red component to read from (value between 0 and 255)
  69693. * @param g defines the green component to read from (value between 0 and 255)
  69694. * @param b defines the blue component to read from (value between 0 and 255)
  69695. * @returns a new Color3 object
  69696. */
  69697. static FromInts(r: number, g: number, b: number): Color3;
  69698. /**
  69699. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69700. * @param start defines the start Color3 value
  69701. * @param end defines the end Color3 value
  69702. * @param amount defines the gradient value between start and end
  69703. * @returns a new Color3 object
  69704. */
  69705. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69706. /**
  69707. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69708. * @param left defines the start value
  69709. * @param right defines the end value
  69710. * @param amount defines the gradient factor
  69711. * @param result defines the Color3 object where to store the result
  69712. */
  69713. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69714. /**
  69715. * Returns a Color3 value containing a red color
  69716. * @returns a new Color3 object
  69717. */
  69718. static Red(): Color3;
  69719. /**
  69720. * Returns a Color3 value containing a green color
  69721. * @returns a new Color3 object
  69722. */
  69723. static Green(): Color3;
  69724. /**
  69725. * Returns a Color3 value containing a blue color
  69726. * @returns a new Color3 object
  69727. */
  69728. static Blue(): Color3;
  69729. /**
  69730. * Returns a Color3 value containing a black color
  69731. * @returns a new Color3 object
  69732. */
  69733. static Black(): Color3;
  69734. /**
  69735. * Gets a Color3 value containing a black color that must not be updated
  69736. */
  69737. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69738. /**
  69739. * Returns a Color3 value containing a white color
  69740. * @returns a new Color3 object
  69741. */
  69742. static White(): Color3;
  69743. /**
  69744. * Returns a Color3 value containing a purple color
  69745. * @returns a new Color3 object
  69746. */
  69747. static Purple(): Color3;
  69748. /**
  69749. * Returns a Color3 value containing a magenta color
  69750. * @returns a new Color3 object
  69751. */
  69752. static Magenta(): Color3;
  69753. /**
  69754. * Returns a Color3 value containing a yellow color
  69755. * @returns a new Color3 object
  69756. */
  69757. static Yellow(): Color3;
  69758. /**
  69759. * Returns a Color3 value containing a gray color
  69760. * @returns a new Color3 object
  69761. */
  69762. static Gray(): Color3;
  69763. /**
  69764. * Returns a Color3 value containing a teal color
  69765. * @returns a new Color3 object
  69766. */
  69767. static Teal(): Color3;
  69768. /**
  69769. * Returns a Color3 value containing a random color
  69770. * @returns a new Color3 object
  69771. */
  69772. static Random(): Color3;
  69773. }
  69774. /**
  69775. * Class used to hold a RBGA color
  69776. */
  69777. export class Color4 {
  69778. /**
  69779. * Defines the red component (between 0 and 1, default is 0)
  69780. */
  69781. r: number;
  69782. /**
  69783. * Defines the green component (between 0 and 1, default is 0)
  69784. */
  69785. g: number;
  69786. /**
  69787. * Defines the blue component (between 0 and 1, default is 0)
  69788. */
  69789. b: number;
  69790. /**
  69791. * Defines the alpha component (between 0 and 1, default is 1)
  69792. */
  69793. a: number;
  69794. /**
  69795. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69796. * @param r defines the red component (between 0 and 1, default is 0)
  69797. * @param g defines the green component (between 0 and 1, default is 0)
  69798. * @param b defines the blue component (between 0 and 1, default is 0)
  69799. * @param a defines the alpha component (between 0 and 1, default is 1)
  69800. */
  69801. constructor(
  69802. /**
  69803. * Defines the red component (between 0 and 1, default is 0)
  69804. */
  69805. r?: number,
  69806. /**
  69807. * Defines the green component (between 0 and 1, default is 0)
  69808. */
  69809. g?: number,
  69810. /**
  69811. * Defines the blue component (between 0 and 1, default is 0)
  69812. */
  69813. b?: number,
  69814. /**
  69815. * Defines the alpha component (between 0 and 1, default is 1)
  69816. */
  69817. a?: number);
  69818. /**
  69819. * Adds in place the given Color4 values to the current Color4 object
  69820. * @param right defines the second operand
  69821. * @returns the current updated Color4 object
  69822. */
  69823. addInPlace(right: DeepImmutable<Color4>): Color4;
  69824. /**
  69825. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69826. * @returns the new array
  69827. */
  69828. asArray(): number[];
  69829. /**
  69830. * Stores from the starting index in the given array the Color4 successive values
  69831. * @param array defines the array where to store the r,g,b components
  69832. * @param index defines an optional index in the target array to define where to start storing values
  69833. * @returns the current Color4 object
  69834. */
  69835. toArray(array: number[], index?: number): Color4;
  69836. /**
  69837. * Determines equality between Color4 objects
  69838. * @param otherColor defines the second operand
  69839. * @returns true if the rgba values are equal to the given ones
  69840. */
  69841. equals(otherColor: DeepImmutable<Color4>): boolean;
  69842. /**
  69843. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69844. * @param right defines the second operand
  69845. * @returns a new Color4 object
  69846. */
  69847. add(right: DeepImmutable<Color4>): Color4;
  69848. /**
  69849. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69850. * @param right defines the second operand
  69851. * @returns a new Color4 object
  69852. */
  69853. subtract(right: DeepImmutable<Color4>): Color4;
  69854. /**
  69855. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69856. * @param right defines the second operand
  69857. * @param result defines the Color4 object where to store the result
  69858. * @returns the current Color4 object
  69859. */
  69860. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69861. /**
  69862. * Creates a new Color4 with the current Color4 values multiplied by scale
  69863. * @param scale defines the scaling factor to apply
  69864. * @returns a new Color4 object
  69865. */
  69866. scale(scale: number): Color4;
  69867. /**
  69868. * Multiplies the current Color4 values by scale and stores the result in "result"
  69869. * @param scale defines the scaling factor to apply
  69870. * @param result defines the Color4 object where to store the result
  69871. * @returns the current unmodified Color4
  69872. */
  69873. scaleToRef(scale: number, result: Color4): Color4;
  69874. /**
  69875. * Scale the current Color4 values by a factor and add the result to a given Color4
  69876. * @param scale defines the scale factor
  69877. * @param result defines the Color4 object where to store the result
  69878. * @returns the unmodified current Color4
  69879. */
  69880. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69881. /**
  69882. * Clamps the rgb values by the min and max values and stores the result into "result"
  69883. * @param min defines minimum clamping value (default is 0)
  69884. * @param max defines maximum clamping value (default is 1)
  69885. * @param result defines color to store the result into.
  69886. * @returns the cuurent Color4
  69887. */
  69888. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69889. /**
  69890. * Multipy an Color4 value by another and return a new Color4 object
  69891. * @param color defines the Color4 value to multiply by
  69892. * @returns a new Color4 object
  69893. */
  69894. multiply(color: Color4): Color4;
  69895. /**
  69896. * Multipy a Color4 value by another and push the result in a reference value
  69897. * @param color defines the Color4 value to multiply by
  69898. * @param result defines the Color4 to fill the result in
  69899. * @returns the result Color4
  69900. */
  69901. multiplyToRef(color: Color4, result: Color4): Color4;
  69902. /**
  69903. * Creates a string with the Color4 current values
  69904. * @returns the string representation of the Color4 object
  69905. */
  69906. toString(): string;
  69907. /**
  69908. * Returns the string "Color4"
  69909. * @returns "Color4"
  69910. */
  69911. getClassName(): string;
  69912. /**
  69913. * Compute the Color4 hash code
  69914. * @returns an unique number that can be used to hash Color4 objects
  69915. */
  69916. getHashCode(): number;
  69917. /**
  69918. * Creates a new Color4 copied from the current one
  69919. * @returns a new Color4 object
  69920. */
  69921. clone(): Color4;
  69922. /**
  69923. * Copies the given Color4 values into the current one
  69924. * @param source defines the source Color4 object
  69925. * @returns the current updated Color4 object
  69926. */
  69927. copyFrom(source: Color4): Color4;
  69928. /**
  69929. * Copies the given float values into the current one
  69930. * @param r defines the red component to read from
  69931. * @param g defines the green component to read from
  69932. * @param b defines the blue component to read from
  69933. * @param a defines the alpha component to read from
  69934. * @returns the current updated Color4 object
  69935. */
  69936. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69937. /**
  69938. * Copies the given float values into the current one
  69939. * @param r defines the red component to read from
  69940. * @param g defines the green component to read from
  69941. * @param b defines the blue component to read from
  69942. * @param a defines the alpha component to read from
  69943. * @returns the current updated Color4 object
  69944. */
  69945. set(r: number, g: number, b: number, a: number): Color4;
  69946. /**
  69947. * Compute the Color4 hexadecimal code as a string
  69948. * @returns a string containing the hexadecimal representation of the Color4 object
  69949. */
  69950. toHexString(): string;
  69951. /**
  69952. * Computes a new Color4 converted from the current one to linear space
  69953. * @returns a new Color4 object
  69954. */
  69955. toLinearSpace(): Color4;
  69956. /**
  69957. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69958. * @param convertedColor defines the Color4 object where to store the linear space version
  69959. * @returns the unmodified Color4
  69960. */
  69961. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69962. /**
  69963. * Computes a new Color4 converted from the current one to gamma space
  69964. * @returns a new Color4 object
  69965. */
  69966. toGammaSpace(): Color4;
  69967. /**
  69968. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69969. * @param convertedColor defines the Color4 object where to store the gamma space version
  69970. * @returns the unmodified Color4
  69971. */
  69972. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69973. /**
  69974. * Creates a new Color4 from the string containing valid hexadecimal values
  69975. * @param hex defines a string containing valid hexadecimal values
  69976. * @returns a new Color4 object
  69977. */
  69978. static FromHexString(hex: string): Color4;
  69979. /**
  69980. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69981. * @param left defines the start value
  69982. * @param right defines the end value
  69983. * @param amount defines the gradient factor
  69984. * @returns a new Color4 object
  69985. */
  69986. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69987. /**
  69988. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69989. * @param left defines the start value
  69990. * @param right defines the end value
  69991. * @param amount defines the gradient factor
  69992. * @param result defines the Color4 object where to store data
  69993. */
  69994. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69995. /**
  69996. * Creates a new Color4 from a Color3 and an alpha value
  69997. * @param color3 defines the source Color3 to read from
  69998. * @param alpha defines the alpha component (1.0 by default)
  69999. * @returns a new Color4 object
  70000. */
  70001. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70002. /**
  70003. * Creates a new Color4 from the starting index element of the given array
  70004. * @param array defines the source array to read from
  70005. * @param offset defines the offset in the source array
  70006. * @returns a new Color4 object
  70007. */
  70008. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70009. /**
  70010. * Creates a new Color3 from integer values (< 256)
  70011. * @param r defines the red component to read from (value between 0 and 255)
  70012. * @param g defines the green component to read from (value between 0 and 255)
  70013. * @param b defines the blue component to read from (value between 0 and 255)
  70014. * @param a defines the alpha component to read from (value between 0 and 255)
  70015. * @returns a new Color3 object
  70016. */
  70017. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70018. /**
  70019. * Check the content of a given array and convert it to an array containing RGBA data
  70020. * If the original array was already containing count * 4 values then it is returned directly
  70021. * @param colors defines the array to check
  70022. * @param count defines the number of RGBA data to expect
  70023. * @returns an array containing count * 4 values (RGBA)
  70024. */
  70025. static CheckColors4(colors: number[], count: number): number[];
  70026. }
  70027. /**
  70028. * @hidden
  70029. */
  70030. export class TmpColors {
  70031. static Color3: Color3[];
  70032. static Color4: Color4[];
  70033. }
  70034. }
  70035. declare module BABYLON {
  70036. /**
  70037. * Class representing spherical harmonics coefficients to the 3rd degree
  70038. */
  70039. export class SphericalHarmonics {
  70040. /**
  70041. * Defines whether or not the harmonics have been prescaled for rendering.
  70042. */
  70043. preScaled: boolean;
  70044. /**
  70045. * The l0,0 coefficients of the spherical harmonics
  70046. */
  70047. l00: Vector3;
  70048. /**
  70049. * The l1,-1 coefficients of the spherical harmonics
  70050. */
  70051. l1_1: Vector3;
  70052. /**
  70053. * The l1,0 coefficients of the spherical harmonics
  70054. */
  70055. l10: Vector3;
  70056. /**
  70057. * The l1,1 coefficients of the spherical harmonics
  70058. */
  70059. l11: Vector3;
  70060. /**
  70061. * The l2,-2 coefficients of the spherical harmonics
  70062. */
  70063. l2_2: Vector3;
  70064. /**
  70065. * The l2,-1 coefficients of the spherical harmonics
  70066. */
  70067. l2_1: Vector3;
  70068. /**
  70069. * The l2,0 coefficients of the spherical harmonics
  70070. */
  70071. l20: Vector3;
  70072. /**
  70073. * The l2,1 coefficients of the spherical harmonics
  70074. */
  70075. l21: Vector3;
  70076. /**
  70077. * The l2,2 coefficients of the spherical harmonics
  70078. */
  70079. l22: Vector3;
  70080. /**
  70081. * Adds a light to the spherical harmonics
  70082. * @param direction the direction of the light
  70083. * @param color the color of the light
  70084. * @param deltaSolidAngle the delta solid angle of the light
  70085. */
  70086. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70087. /**
  70088. * Scales the spherical harmonics by the given amount
  70089. * @param scale the amount to scale
  70090. */
  70091. scaleInPlace(scale: number): void;
  70092. /**
  70093. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70094. *
  70095. * ```
  70096. * E_lm = A_l * L_lm
  70097. * ```
  70098. *
  70099. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70100. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70101. * the scaling factors are given in equation 9.
  70102. */
  70103. convertIncidentRadianceToIrradiance(): void;
  70104. /**
  70105. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70106. *
  70107. * ```
  70108. * L = (1/pi) * E * rho
  70109. * ```
  70110. *
  70111. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70112. */
  70113. convertIrradianceToLambertianRadiance(): void;
  70114. /**
  70115. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70116. * required operations at run time.
  70117. *
  70118. * This is simply done by scaling back the SH with Ylm constants parameter.
  70119. * The trigonometric part being applied by the shader at run time.
  70120. */
  70121. preScaleForRendering(): void;
  70122. /**
  70123. * Constructs a spherical harmonics from an array.
  70124. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70125. * @returns the spherical harmonics
  70126. */
  70127. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70128. /**
  70129. * Gets the spherical harmonics from polynomial
  70130. * @param polynomial the spherical polynomial
  70131. * @returns the spherical harmonics
  70132. */
  70133. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70134. }
  70135. /**
  70136. * Class representing spherical polynomial coefficients to the 3rd degree
  70137. */
  70138. export class SphericalPolynomial {
  70139. private _harmonics;
  70140. /**
  70141. * The spherical harmonics used to create the polynomials.
  70142. */
  70143. readonly preScaledHarmonics: SphericalHarmonics;
  70144. /**
  70145. * The x coefficients of the spherical polynomial
  70146. */
  70147. x: Vector3;
  70148. /**
  70149. * The y coefficients of the spherical polynomial
  70150. */
  70151. y: Vector3;
  70152. /**
  70153. * The z coefficients of the spherical polynomial
  70154. */
  70155. z: Vector3;
  70156. /**
  70157. * The xx coefficients of the spherical polynomial
  70158. */
  70159. xx: Vector3;
  70160. /**
  70161. * The yy coefficients of the spherical polynomial
  70162. */
  70163. yy: Vector3;
  70164. /**
  70165. * The zz coefficients of the spherical polynomial
  70166. */
  70167. zz: Vector3;
  70168. /**
  70169. * The xy coefficients of the spherical polynomial
  70170. */
  70171. xy: Vector3;
  70172. /**
  70173. * The yz coefficients of the spherical polynomial
  70174. */
  70175. yz: Vector3;
  70176. /**
  70177. * The zx coefficients of the spherical polynomial
  70178. */
  70179. zx: Vector3;
  70180. /**
  70181. * Adds an ambient color to the spherical polynomial
  70182. * @param color the color to add
  70183. */
  70184. addAmbient(color: Color3): void;
  70185. /**
  70186. * Scales the spherical polynomial by the given amount
  70187. * @param scale the amount to scale
  70188. */
  70189. scaleInPlace(scale: number): void;
  70190. /**
  70191. * Gets the spherical polynomial from harmonics
  70192. * @param harmonics the spherical harmonics
  70193. * @returns the spherical polynomial
  70194. */
  70195. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70196. /**
  70197. * Constructs a spherical polynomial from an array.
  70198. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70199. * @returns the spherical polynomial
  70200. */
  70201. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70202. }
  70203. }
  70204. declare module BABYLON {
  70205. /**
  70206. * Define options used to create a render target texture
  70207. */
  70208. export class RenderTargetCreationOptions {
  70209. /**
  70210. * Specifies is mipmaps must be generated
  70211. */
  70212. generateMipMaps?: boolean;
  70213. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70214. generateDepthBuffer?: boolean;
  70215. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70216. generateStencilBuffer?: boolean;
  70217. /** Defines texture type (int by default) */
  70218. type?: number;
  70219. /** Defines sampling mode (trilinear by default) */
  70220. samplingMode?: number;
  70221. /** Defines format (RGBA by default) */
  70222. format?: number;
  70223. }
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * @hidden
  70228. **/
  70229. export class _AlphaState {
  70230. private _isAlphaBlendDirty;
  70231. private _isBlendFunctionParametersDirty;
  70232. private _isBlendEquationParametersDirty;
  70233. private _isBlendConstantsDirty;
  70234. private _alphaBlend;
  70235. private _blendFunctionParameters;
  70236. private _blendEquationParameters;
  70237. private _blendConstants;
  70238. /**
  70239. * Initializes the state.
  70240. */
  70241. constructor();
  70242. readonly isDirty: boolean;
  70243. alphaBlend: boolean;
  70244. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70245. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70246. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70247. reset(): void;
  70248. apply(gl: WebGLRenderingContext): void;
  70249. }
  70250. }
  70251. declare module BABYLON {
  70252. /**
  70253. * @hidden
  70254. **/
  70255. export class _DepthCullingState {
  70256. private _isDepthTestDirty;
  70257. private _isDepthMaskDirty;
  70258. private _isDepthFuncDirty;
  70259. private _isCullFaceDirty;
  70260. private _isCullDirty;
  70261. private _isZOffsetDirty;
  70262. private _isFrontFaceDirty;
  70263. private _depthTest;
  70264. private _depthMask;
  70265. private _depthFunc;
  70266. private _cull;
  70267. private _cullFace;
  70268. private _zOffset;
  70269. private _frontFace;
  70270. /**
  70271. * Initializes the state.
  70272. */
  70273. constructor();
  70274. readonly isDirty: boolean;
  70275. zOffset: number;
  70276. cullFace: Nullable<number>;
  70277. cull: Nullable<boolean>;
  70278. depthFunc: Nullable<number>;
  70279. depthMask: boolean;
  70280. depthTest: boolean;
  70281. frontFace: Nullable<number>;
  70282. reset(): void;
  70283. apply(gl: WebGLRenderingContext): void;
  70284. }
  70285. }
  70286. declare module BABYLON {
  70287. /**
  70288. * @hidden
  70289. **/
  70290. export class _StencilState {
  70291. /** 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 */
  70292. static readonly ALWAYS: number;
  70293. /** Passed to stencilOperation to specify that stencil value must be kept */
  70294. static readonly KEEP: number;
  70295. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70296. static readonly REPLACE: number;
  70297. private _isStencilTestDirty;
  70298. private _isStencilMaskDirty;
  70299. private _isStencilFuncDirty;
  70300. private _isStencilOpDirty;
  70301. private _stencilTest;
  70302. private _stencilMask;
  70303. private _stencilFunc;
  70304. private _stencilFuncRef;
  70305. private _stencilFuncMask;
  70306. private _stencilOpStencilFail;
  70307. private _stencilOpDepthFail;
  70308. private _stencilOpStencilDepthPass;
  70309. readonly isDirty: boolean;
  70310. stencilFunc: number;
  70311. stencilFuncRef: number;
  70312. stencilFuncMask: number;
  70313. stencilOpStencilFail: number;
  70314. stencilOpDepthFail: number;
  70315. stencilOpStencilDepthPass: number;
  70316. stencilMask: number;
  70317. stencilTest: boolean;
  70318. constructor();
  70319. reset(): void;
  70320. apply(gl: WebGLRenderingContext): void;
  70321. }
  70322. }
  70323. declare module BABYLON {
  70324. /**
  70325. * @hidden
  70326. **/
  70327. export class _TimeToken {
  70328. _startTimeQuery: Nullable<WebGLQuery>;
  70329. _endTimeQuery: Nullable<WebGLQuery>;
  70330. _timeElapsedQuery: Nullable<WebGLQuery>;
  70331. _timeElapsedQueryEnded: boolean;
  70332. }
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * Class used to evalaute queries containing `and` and `or` operators
  70337. */
  70338. export class AndOrNotEvaluator {
  70339. /**
  70340. * Evaluate a query
  70341. * @param query defines the query to evaluate
  70342. * @param evaluateCallback defines the callback used to filter result
  70343. * @returns true if the query matches
  70344. */
  70345. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70346. private static _HandleParenthesisContent;
  70347. private static _SimplifyNegation;
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. /**
  70352. * Class used to store custom tags
  70353. */
  70354. export class Tags {
  70355. /**
  70356. * Adds support for tags on the given object
  70357. * @param obj defines the object to use
  70358. */
  70359. static EnableFor(obj: any): void;
  70360. /**
  70361. * Removes tags support
  70362. * @param obj defines the object to use
  70363. */
  70364. static DisableFor(obj: any): void;
  70365. /**
  70366. * Gets a boolean indicating if the given object has tags
  70367. * @param obj defines the object to use
  70368. * @returns a boolean
  70369. */
  70370. static HasTags(obj: any): boolean;
  70371. /**
  70372. * Gets the tags available on a given object
  70373. * @param obj defines the object to use
  70374. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70375. * @returns the tags
  70376. */
  70377. static GetTags(obj: any, asString?: boolean): any;
  70378. /**
  70379. * Adds tags to an object
  70380. * @param obj defines the object to use
  70381. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70382. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70383. */
  70384. static AddTagsTo(obj: any, tagsString: string): void;
  70385. /**
  70386. * @hidden
  70387. */
  70388. static _AddTagTo(obj: any, tag: string): void;
  70389. /**
  70390. * Removes specific tags from a specific object
  70391. * @param obj defines the object to use
  70392. * @param tagsString defines the tags to remove
  70393. */
  70394. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70395. /**
  70396. * @hidden
  70397. */
  70398. static _RemoveTagFrom(obj: any, tag: string): void;
  70399. /**
  70400. * Defines if tags hosted on an object match a given query
  70401. * @param obj defines the object to use
  70402. * @param tagsQuery defines the tag query
  70403. * @returns a boolean
  70404. */
  70405. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70406. }
  70407. }
  70408. declare module BABYLON {
  70409. /**
  70410. * Defines potential orientation for back face culling
  70411. */
  70412. export enum Orientation {
  70413. /**
  70414. * Clockwise
  70415. */
  70416. CW = 0,
  70417. /** Counter clockwise */
  70418. CCW = 1
  70419. }
  70420. /** Class used to represent a Bezier curve */
  70421. export class BezierCurve {
  70422. /**
  70423. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70424. * @param t defines the time
  70425. * @param x1 defines the left coordinate on X axis
  70426. * @param y1 defines the left coordinate on Y axis
  70427. * @param x2 defines the right coordinate on X axis
  70428. * @param y2 defines the right coordinate on Y axis
  70429. * @returns the interpolated value
  70430. */
  70431. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70432. }
  70433. /**
  70434. * Defines angle representation
  70435. */
  70436. export class Angle {
  70437. private _radians;
  70438. /**
  70439. * Creates an Angle object of "radians" radians (float).
  70440. * @param radians the angle in radians
  70441. */
  70442. constructor(radians: number);
  70443. /**
  70444. * Get value in degrees
  70445. * @returns the Angle value in degrees (float)
  70446. */
  70447. degrees(): number;
  70448. /**
  70449. * Get value in radians
  70450. * @returns the Angle value in radians (float)
  70451. */
  70452. radians(): number;
  70453. /**
  70454. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70455. * @param a defines first vector
  70456. * @param b defines second vector
  70457. * @returns a new Angle
  70458. */
  70459. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70460. /**
  70461. * Gets a new Angle object from the given float in radians
  70462. * @param radians defines the angle value in radians
  70463. * @returns a new Angle
  70464. */
  70465. static FromRadians(radians: number): Angle;
  70466. /**
  70467. * Gets a new Angle object from the given float in degrees
  70468. * @param degrees defines the angle value in degrees
  70469. * @returns a new Angle
  70470. */
  70471. static FromDegrees(degrees: number): Angle;
  70472. }
  70473. /**
  70474. * This represents an arc in a 2d space.
  70475. */
  70476. export class Arc2 {
  70477. /** Defines the start point of the arc */
  70478. startPoint: Vector2;
  70479. /** Defines the mid point of the arc */
  70480. midPoint: Vector2;
  70481. /** Defines the end point of the arc */
  70482. endPoint: Vector2;
  70483. /**
  70484. * Defines the center point of the arc.
  70485. */
  70486. centerPoint: Vector2;
  70487. /**
  70488. * Defines the radius of the arc.
  70489. */
  70490. radius: number;
  70491. /**
  70492. * Defines the angle of the arc (from mid point to end point).
  70493. */
  70494. angle: Angle;
  70495. /**
  70496. * Defines the start angle of the arc (from start point to middle point).
  70497. */
  70498. startAngle: Angle;
  70499. /**
  70500. * Defines the orientation of the arc (clock wise/counter clock wise).
  70501. */
  70502. orientation: Orientation;
  70503. /**
  70504. * Creates an Arc object from the three given points : start, middle and end.
  70505. * @param startPoint Defines the start point of the arc
  70506. * @param midPoint Defines the midlle point of the arc
  70507. * @param endPoint Defines the end point of the arc
  70508. */
  70509. constructor(
  70510. /** Defines the start point of the arc */
  70511. startPoint: Vector2,
  70512. /** Defines the mid point of the arc */
  70513. midPoint: Vector2,
  70514. /** Defines the end point of the arc */
  70515. endPoint: Vector2);
  70516. }
  70517. /**
  70518. * Represents a 2D path made up of multiple 2D points
  70519. */
  70520. export class Path2 {
  70521. private _points;
  70522. private _length;
  70523. /**
  70524. * If the path start and end point are the same
  70525. */
  70526. closed: boolean;
  70527. /**
  70528. * Creates a Path2 object from the starting 2D coordinates x and y.
  70529. * @param x the starting points x value
  70530. * @param y the starting points y value
  70531. */
  70532. constructor(x: number, y: number);
  70533. /**
  70534. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70535. * @param x the added points x value
  70536. * @param y the added points y value
  70537. * @returns the updated Path2.
  70538. */
  70539. addLineTo(x: number, y: number): Path2;
  70540. /**
  70541. * 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.
  70542. * @param midX middle point x value
  70543. * @param midY middle point y value
  70544. * @param endX end point x value
  70545. * @param endY end point y value
  70546. * @param numberOfSegments (default: 36)
  70547. * @returns the updated Path2.
  70548. */
  70549. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70550. /**
  70551. * Closes the Path2.
  70552. * @returns the Path2.
  70553. */
  70554. close(): Path2;
  70555. /**
  70556. * Gets the sum of the distance between each sequential point in the path
  70557. * @returns the Path2 total length (float).
  70558. */
  70559. length(): number;
  70560. /**
  70561. * Gets the points which construct the path
  70562. * @returns the Path2 internal array of points.
  70563. */
  70564. getPoints(): Vector2[];
  70565. /**
  70566. * Retreives the point at the distance aways from the starting point
  70567. * @param normalizedLengthPosition the length along the path to retreive the point from
  70568. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70569. */
  70570. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70571. /**
  70572. * Creates a new path starting from an x and y position
  70573. * @param x starting x value
  70574. * @param y starting y value
  70575. * @returns a new Path2 starting at the coordinates (x, y).
  70576. */
  70577. static StartingAt(x: number, y: number): Path2;
  70578. }
  70579. /**
  70580. * Represents a 3D path made up of multiple 3D points
  70581. */
  70582. export class Path3D {
  70583. /**
  70584. * an array of Vector3, the curve axis of the Path3D
  70585. */
  70586. path: Vector3[];
  70587. private _curve;
  70588. private _distances;
  70589. private _tangents;
  70590. private _normals;
  70591. private _binormals;
  70592. private _raw;
  70593. /**
  70594. * new Path3D(path, normal, raw)
  70595. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70596. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70597. * @param path an array of Vector3, the curve axis of the Path3D
  70598. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70599. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70600. */
  70601. constructor(
  70602. /**
  70603. * an array of Vector3, the curve axis of the Path3D
  70604. */
  70605. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70606. /**
  70607. * Returns the Path3D array of successive Vector3 designing its curve.
  70608. * @returns the Path3D array of successive Vector3 designing its curve.
  70609. */
  70610. getCurve(): Vector3[];
  70611. /**
  70612. * Returns an array populated with tangent vectors on each Path3D curve point.
  70613. * @returns an array populated with tangent vectors on each Path3D curve point.
  70614. */
  70615. getTangents(): Vector3[];
  70616. /**
  70617. * Returns an array populated with normal vectors on each Path3D curve point.
  70618. * @returns an array populated with normal vectors on each Path3D curve point.
  70619. */
  70620. getNormals(): Vector3[];
  70621. /**
  70622. * Returns an array populated with binormal vectors on each Path3D curve point.
  70623. * @returns an array populated with binormal vectors on each Path3D curve point.
  70624. */
  70625. getBinormals(): Vector3[];
  70626. /**
  70627. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70628. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70629. */
  70630. getDistances(): number[];
  70631. /**
  70632. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70633. * @param path path which all values are copied into the curves points
  70634. * @param firstNormal which should be projected onto the curve
  70635. * @returns the same object updated.
  70636. */
  70637. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70638. private _compute;
  70639. private _getFirstNonNullVector;
  70640. private _getLastNonNullVector;
  70641. private _normalVector;
  70642. }
  70643. /**
  70644. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70645. * A Curve3 is designed from a series of successive Vector3.
  70646. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70647. */
  70648. export class Curve3 {
  70649. private _points;
  70650. private _length;
  70651. /**
  70652. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70653. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70654. * @param v1 (Vector3) the control point
  70655. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70656. * @param nbPoints (integer) the wanted number of points in the curve
  70657. * @returns the created Curve3
  70658. */
  70659. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70660. /**
  70661. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70662. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70663. * @param v1 (Vector3) the first control point
  70664. * @param v2 (Vector3) the second control point
  70665. * @param v3 (Vector3) the end point of the Cubic Bezier
  70666. * @param nbPoints (integer) the wanted number of points in the curve
  70667. * @returns the created Curve3
  70668. */
  70669. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70670. /**
  70671. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70672. * @param p1 (Vector3) the origin point of the Hermite Spline
  70673. * @param t1 (Vector3) the tangent vector at the origin point
  70674. * @param p2 (Vector3) the end point of the Hermite Spline
  70675. * @param t2 (Vector3) the tangent vector at the end point
  70676. * @param nbPoints (integer) the wanted number of points in the curve
  70677. * @returns the created Curve3
  70678. */
  70679. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70680. /**
  70681. * Returns a Curve3 object along a CatmullRom Spline curve :
  70682. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70683. * @param nbPoints (integer) the wanted number of points between each curve control points
  70684. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70685. * @returns the created Curve3
  70686. */
  70687. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70688. /**
  70689. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70690. * A Curve3 is designed from a series of successive Vector3.
  70691. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70692. * @param points points which make up the curve
  70693. */
  70694. constructor(points: Vector3[]);
  70695. /**
  70696. * @returns the Curve3 stored array of successive Vector3
  70697. */
  70698. getPoints(): Vector3[];
  70699. /**
  70700. * @returns the computed length (float) of the curve.
  70701. */
  70702. length(): number;
  70703. /**
  70704. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70705. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70706. * curveA and curveB keep unchanged.
  70707. * @param curve the curve to continue from this curve
  70708. * @returns the newly constructed curve
  70709. */
  70710. continue(curve: DeepImmutable<Curve3>): Curve3;
  70711. private _computeLength;
  70712. }
  70713. }
  70714. declare module BABYLON {
  70715. /**
  70716. * This represents the main contract an easing function should follow.
  70717. * Easing functions are used throughout the animation system.
  70718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70719. */
  70720. export interface IEasingFunction {
  70721. /**
  70722. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70723. * of the easing function.
  70724. * The link below provides some of the most common examples of easing functions.
  70725. * @see https://easings.net/
  70726. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70727. * @returns the corresponding value on the curve defined by the easing function
  70728. */
  70729. ease(gradient: number): number;
  70730. }
  70731. /**
  70732. * Base class used for every default easing function.
  70733. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70734. */
  70735. export class EasingFunction implements IEasingFunction {
  70736. /**
  70737. * Interpolation follows the mathematical formula associated with the easing function.
  70738. */
  70739. static readonly EASINGMODE_EASEIN: number;
  70740. /**
  70741. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70742. */
  70743. static readonly EASINGMODE_EASEOUT: number;
  70744. /**
  70745. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70746. */
  70747. static readonly EASINGMODE_EASEINOUT: number;
  70748. private _easingMode;
  70749. /**
  70750. * Sets the easing mode of the current function.
  70751. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70752. */
  70753. setEasingMode(easingMode: number): void;
  70754. /**
  70755. * Gets the current easing mode.
  70756. * @returns the easing mode
  70757. */
  70758. getEasingMode(): number;
  70759. /**
  70760. * @hidden
  70761. */
  70762. easeInCore(gradient: number): number;
  70763. /**
  70764. * Given an input gradient between 0 and 1, this returns the corresponding value
  70765. * of the easing function.
  70766. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70767. * @returns the corresponding value on the curve defined by the easing function
  70768. */
  70769. ease(gradient: number): number;
  70770. }
  70771. /**
  70772. * Easing function with a circle shape (see link below).
  70773. * @see https://easings.net/#easeInCirc
  70774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70775. */
  70776. export class CircleEase extends EasingFunction implements IEasingFunction {
  70777. /** @hidden */
  70778. easeInCore(gradient: number): number;
  70779. }
  70780. /**
  70781. * Easing function with a ease back shape (see link below).
  70782. * @see https://easings.net/#easeInBack
  70783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70784. */
  70785. export class BackEase extends EasingFunction implements IEasingFunction {
  70786. /** Defines the amplitude of the function */
  70787. amplitude: number;
  70788. /**
  70789. * Instantiates a back ease easing
  70790. * @see https://easings.net/#easeInBack
  70791. * @param amplitude Defines the amplitude of the function
  70792. */
  70793. constructor(
  70794. /** Defines the amplitude of the function */
  70795. amplitude?: number);
  70796. /** @hidden */
  70797. easeInCore(gradient: number): number;
  70798. }
  70799. /**
  70800. * Easing function with a bouncing shape (see link below).
  70801. * @see https://easings.net/#easeInBounce
  70802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70803. */
  70804. export class BounceEase extends EasingFunction implements IEasingFunction {
  70805. /** Defines the number of bounces */
  70806. bounces: number;
  70807. /** Defines the amplitude of the bounce */
  70808. bounciness: number;
  70809. /**
  70810. * Instantiates a bounce easing
  70811. * @see https://easings.net/#easeInBounce
  70812. * @param bounces Defines the number of bounces
  70813. * @param bounciness Defines the amplitude of the bounce
  70814. */
  70815. constructor(
  70816. /** Defines the number of bounces */
  70817. bounces?: number,
  70818. /** Defines the amplitude of the bounce */
  70819. bounciness?: number);
  70820. /** @hidden */
  70821. easeInCore(gradient: number): number;
  70822. }
  70823. /**
  70824. * Easing function with a power of 3 shape (see link below).
  70825. * @see https://easings.net/#easeInCubic
  70826. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70827. */
  70828. export class CubicEase extends EasingFunction implements IEasingFunction {
  70829. /** @hidden */
  70830. easeInCore(gradient: number): number;
  70831. }
  70832. /**
  70833. * Easing function with an elastic shape (see link below).
  70834. * @see https://easings.net/#easeInElastic
  70835. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70836. */
  70837. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70838. /** Defines the number of oscillations*/
  70839. oscillations: number;
  70840. /** Defines the amplitude of the oscillations*/
  70841. springiness: number;
  70842. /**
  70843. * Instantiates an elastic easing function
  70844. * @see https://easings.net/#easeInElastic
  70845. * @param oscillations Defines the number of oscillations
  70846. * @param springiness Defines the amplitude of the oscillations
  70847. */
  70848. constructor(
  70849. /** Defines the number of oscillations*/
  70850. oscillations?: number,
  70851. /** Defines the amplitude of the oscillations*/
  70852. springiness?: number);
  70853. /** @hidden */
  70854. easeInCore(gradient: number): number;
  70855. }
  70856. /**
  70857. * Easing function with an exponential shape (see link below).
  70858. * @see https://easings.net/#easeInExpo
  70859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70860. */
  70861. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70862. /** Defines the exponent of the function */
  70863. exponent: number;
  70864. /**
  70865. * Instantiates an exponential easing function
  70866. * @see https://easings.net/#easeInExpo
  70867. * @param exponent Defines the exponent of the function
  70868. */
  70869. constructor(
  70870. /** Defines the exponent of the function */
  70871. exponent?: number);
  70872. /** @hidden */
  70873. easeInCore(gradient: number): number;
  70874. }
  70875. /**
  70876. * Easing function with a power shape (see link below).
  70877. * @see https://easings.net/#easeInQuad
  70878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70879. */
  70880. export class PowerEase extends EasingFunction implements IEasingFunction {
  70881. /** Defines the power of the function */
  70882. power: number;
  70883. /**
  70884. * Instantiates an power base easing function
  70885. * @see https://easings.net/#easeInQuad
  70886. * @param power Defines the power of the function
  70887. */
  70888. constructor(
  70889. /** Defines the power of the function */
  70890. power?: number);
  70891. /** @hidden */
  70892. easeInCore(gradient: number): number;
  70893. }
  70894. /**
  70895. * Easing function with a power of 2 shape (see link below).
  70896. * @see https://easings.net/#easeInQuad
  70897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70898. */
  70899. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70900. /** @hidden */
  70901. easeInCore(gradient: number): number;
  70902. }
  70903. /**
  70904. * Easing function with a power of 4 shape (see link below).
  70905. * @see https://easings.net/#easeInQuart
  70906. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70907. */
  70908. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70909. /** @hidden */
  70910. easeInCore(gradient: number): number;
  70911. }
  70912. /**
  70913. * Easing function with a power of 5 shape (see link below).
  70914. * @see https://easings.net/#easeInQuint
  70915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70916. */
  70917. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70918. /** @hidden */
  70919. easeInCore(gradient: number): number;
  70920. }
  70921. /**
  70922. * Easing function with a sin shape (see link below).
  70923. * @see https://easings.net/#easeInSine
  70924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70925. */
  70926. export class SineEase extends EasingFunction implements IEasingFunction {
  70927. /** @hidden */
  70928. easeInCore(gradient: number): number;
  70929. }
  70930. /**
  70931. * Easing function with a bezier shape (see link below).
  70932. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70934. */
  70935. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70936. /** Defines the x component of the start tangent in the bezier curve */
  70937. x1: number;
  70938. /** Defines the y component of the start tangent in the bezier curve */
  70939. y1: number;
  70940. /** Defines the x component of the end tangent in the bezier curve */
  70941. x2: number;
  70942. /** Defines the y component of the end tangent in the bezier curve */
  70943. y2: number;
  70944. /**
  70945. * Instantiates a bezier function
  70946. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70947. * @param x1 Defines the x component of the start tangent in the bezier curve
  70948. * @param y1 Defines the y component of the start tangent in the bezier curve
  70949. * @param x2 Defines the x component of the end tangent in the bezier curve
  70950. * @param y2 Defines the y component of the end tangent in the bezier curve
  70951. */
  70952. constructor(
  70953. /** Defines the x component of the start tangent in the bezier curve */
  70954. x1?: number,
  70955. /** Defines the y component of the start tangent in the bezier curve */
  70956. y1?: number,
  70957. /** Defines the x component of the end tangent in the bezier curve */
  70958. x2?: number,
  70959. /** Defines the y component of the end tangent in the bezier curve */
  70960. y2?: number);
  70961. /** @hidden */
  70962. easeInCore(gradient: number): number;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. /**
  70967. * Defines an interface which represents an animation key frame
  70968. */
  70969. export interface IAnimationKey {
  70970. /**
  70971. * Frame of the key frame
  70972. */
  70973. frame: number;
  70974. /**
  70975. * Value at the specifies key frame
  70976. */
  70977. value: any;
  70978. /**
  70979. * The input tangent for the cubic hermite spline
  70980. */
  70981. inTangent?: any;
  70982. /**
  70983. * The output tangent for the cubic hermite spline
  70984. */
  70985. outTangent?: any;
  70986. /**
  70987. * The animation interpolation type
  70988. */
  70989. interpolation?: AnimationKeyInterpolation;
  70990. }
  70991. /**
  70992. * Enum for the animation key frame interpolation type
  70993. */
  70994. export enum AnimationKeyInterpolation {
  70995. /**
  70996. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70997. */
  70998. STEP = 1
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * Represents the range of an animation
  71004. */
  71005. export class AnimationRange {
  71006. /**The name of the animation range**/
  71007. name: string;
  71008. /**The starting frame of the animation */
  71009. from: number;
  71010. /**The ending frame of the animation*/
  71011. to: number;
  71012. /**
  71013. * Initializes the range of an animation
  71014. * @param name The name of the animation range
  71015. * @param from The starting frame of the animation
  71016. * @param to The ending frame of the animation
  71017. */
  71018. constructor(
  71019. /**The name of the animation range**/
  71020. name: string,
  71021. /**The starting frame of the animation */
  71022. from: number,
  71023. /**The ending frame of the animation*/
  71024. to: number);
  71025. /**
  71026. * Makes a copy of the animation range
  71027. * @returns A copy of the animation range
  71028. */
  71029. clone(): AnimationRange;
  71030. }
  71031. }
  71032. declare module BABYLON {
  71033. /**
  71034. * Composed of a frame, and an action function
  71035. */
  71036. export class AnimationEvent {
  71037. /** The frame for which the event is triggered **/
  71038. frame: number;
  71039. /** The event to perform when triggered **/
  71040. action: (currentFrame: number) => void;
  71041. /** Specifies if the event should be triggered only once**/
  71042. onlyOnce?: boolean | undefined;
  71043. /**
  71044. * Specifies if the animation event is done
  71045. */
  71046. isDone: boolean;
  71047. /**
  71048. * Initializes the animation event
  71049. * @param frame The frame for which the event is triggered
  71050. * @param action The event to perform when triggered
  71051. * @param onlyOnce Specifies if the event should be triggered only once
  71052. */
  71053. constructor(
  71054. /** The frame for which the event is triggered **/
  71055. frame: number,
  71056. /** The event to perform when triggered **/
  71057. action: (currentFrame: number) => void,
  71058. /** Specifies if the event should be triggered only once**/
  71059. onlyOnce?: boolean | undefined);
  71060. /** @hidden */
  71061. _clone(): AnimationEvent;
  71062. }
  71063. }
  71064. declare module BABYLON {
  71065. /**
  71066. * Interface used to define a behavior
  71067. */
  71068. export interface Behavior<T> {
  71069. /** gets or sets behavior's name */
  71070. name: string;
  71071. /**
  71072. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71073. */
  71074. init(): void;
  71075. /**
  71076. * Called when the behavior is attached to a target
  71077. * @param target defines the target where the behavior is attached to
  71078. */
  71079. attach(target: T): void;
  71080. /**
  71081. * Called when the behavior is detached from its target
  71082. */
  71083. detach(): void;
  71084. }
  71085. /**
  71086. * Interface implemented by classes supporting behaviors
  71087. */
  71088. export interface IBehaviorAware<T> {
  71089. /**
  71090. * Attach a behavior
  71091. * @param behavior defines the behavior to attach
  71092. * @returns the current host
  71093. */
  71094. addBehavior(behavior: Behavior<T>): T;
  71095. /**
  71096. * Remove a behavior from the current object
  71097. * @param behavior defines the behavior to detach
  71098. * @returns the current host
  71099. */
  71100. removeBehavior(behavior: Behavior<T>): T;
  71101. /**
  71102. * Gets a behavior using its name to search
  71103. * @param name defines the name to search
  71104. * @returns the behavior or null if not found
  71105. */
  71106. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71107. }
  71108. }
  71109. declare module BABYLON {
  71110. /**
  71111. * Defines an array and its length.
  71112. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71113. */
  71114. export interface ISmartArrayLike<T> {
  71115. /**
  71116. * The data of the array.
  71117. */
  71118. data: Array<T>;
  71119. /**
  71120. * The active length of the array.
  71121. */
  71122. length: number;
  71123. }
  71124. /**
  71125. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71126. */
  71127. export class SmartArray<T> implements ISmartArrayLike<T> {
  71128. /**
  71129. * The full set of data from the array.
  71130. */
  71131. data: Array<T>;
  71132. /**
  71133. * The active length of the array.
  71134. */
  71135. length: number;
  71136. protected _id: number;
  71137. /**
  71138. * Instantiates a Smart Array.
  71139. * @param capacity defines the default capacity of the array.
  71140. */
  71141. constructor(capacity: number);
  71142. /**
  71143. * Pushes a value at the end of the active data.
  71144. * @param value defines the object to push in the array.
  71145. */
  71146. push(value: T): void;
  71147. /**
  71148. * Iterates over the active data and apply the lambda to them.
  71149. * @param func defines the action to apply on each value.
  71150. */
  71151. forEach(func: (content: T) => void): void;
  71152. /**
  71153. * Sorts the full sets of data.
  71154. * @param compareFn defines the comparison function to apply.
  71155. */
  71156. sort(compareFn: (a: T, b: T) => number): void;
  71157. /**
  71158. * Resets the active data to an empty array.
  71159. */
  71160. reset(): void;
  71161. /**
  71162. * Releases all the data from the array as well as the array.
  71163. */
  71164. dispose(): void;
  71165. /**
  71166. * Concats the active data with a given array.
  71167. * @param array defines the data to concatenate with.
  71168. */
  71169. concat(array: any): void;
  71170. /**
  71171. * Returns the position of a value in the active data.
  71172. * @param value defines the value to find the index for
  71173. * @returns the index if found in the active data otherwise -1
  71174. */
  71175. indexOf(value: T): number;
  71176. /**
  71177. * Returns whether an element is part of the active data.
  71178. * @param value defines the value to look for
  71179. * @returns true if found in the active data otherwise false
  71180. */
  71181. contains(value: T): boolean;
  71182. private static _GlobalId;
  71183. }
  71184. /**
  71185. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71186. * The data in this array can only be present once
  71187. */
  71188. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71189. private _duplicateId;
  71190. /**
  71191. * Pushes a value at the end of the active data.
  71192. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71193. * @param value defines the object to push in the array.
  71194. */
  71195. push(value: T): void;
  71196. /**
  71197. * Pushes a value at the end of the active data.
  71198. * If the data is already present, it won t be added again
  71199. * @param value defines the object to push in the array.
  71200. * @returns true if added false if it was already present
  71201. */
  71202. pushNoDuplicate(value: T): boolean;
  71203. /**
  71204. * Resets the active data to an empty array.
  71205. */
  71206. reset(): void;
  71207. /**
  71208. * Concats the active data with a given array.
  71209. * This ensures no dupplicate will be present in the result.
  71210. * @param array defines the data to concatenate with.
  71211. */
  71212. concatWithNoDuplicate(array: any): void;
  71213. }
  71214. }
  71215. declare module BABYLON {
  71216. /**
  71217. * @ignore
  71218. * This is a list of all the different input types that are available in the application.
  71219. * Fo instance: ArcRotateCameraGamepadInput...
  71220. */
  71221. export var CameraInputTypes: {};
  71222. /**
  71223. * This is the contract to implement in order to create a new input class.
  71224. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71225. */
  71226. export interface ICameraInput<TCamera extends Camera> {
  71227. /**
  71228. * Defines the camera the input is attached to.
  71229. */
  71230. camera: Nullable<TCamera>;
  71231. /**
  71232. * Gets the class name of the current intput.
  71233. * @returns the class name
  71234. */
  71235. getClassName(): string;
  71236. /**
  71237. * Get the friendly name associated with the input class.
  71238. * @returns the input friendly name
  71239. */
  71240. getSimpleName(): string;
  71241. /**
  71242. * Attach the input controls to a specific dom element to get the input from.
  71243. * @param element Defines the element the controls should be listened from
  71244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71245. */
  71246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71247. /**
  71248. * Detach the current controls from the specified dom element.
  71249. * @param element Defines the element to stop listening the inputs from
  71250. */
  71251. detachControl(element: Nullable<HTMLElement>): void;
  71252. /**
  71253. * Update the current camera state depending on the inputs that have been used this frame.
  71254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71255. */
  71256. checkInputs?: () => void;
  71257. }
  71258. /**
  71259. * Represents a map of input types to input instance or input index to input instance.
  71260. */
  71261. export interface CameraInputsMap<TCamera extends Camera> {
  71262. /**
  71263. * Accessor to the input by input type.
  71264. */
  71265. [name: string]: ICameraInput<TCamera>;
  71266. /**
  71267. * Accessor to the input by input index.
  71268. */
  71269. [idx: number]: ICameraInput<TCamera>;
  71270. }
  71271. /**
  71272. * This represents the input manager used within a camera.
  71273. * It helps dealing with all the different kind of input attached to a camera.
  71274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71275. */
  71276. export class CameraInputsManager<TCamera extends Camera> {
  71277. /**
  71278. * Defines the list of inputs attahed to the camera.
  71279. */
  71280. attached: CameraInputsMap<TCamera>;
  71281. /**
  71282. * Defines the dom element the camera is collecting inputs from.
  71283. * This is null if the controls have not been attached.
  71284. */
  71285. attachedElement: Nullable<HTMLElement>;
  71286. /**
  71287. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71288. */
  71289. noPreventDefault: boolean;
  71290. /**
  71291. * Defined the camera the input manager belongs to.
  71292. */
  71293. camera: TCamera;
  71294. /**
  71295. * Update the current camera state depending on the inputs that have been used this frame.
  71296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71297. */
  71298. checkInputs: () => void;
  71299. /**
  71300. * Instantiate a new Camera Input Manager.
  71301. * @param camera Defines the camera the input manager blongs to
  71302. */
  71303. constructor(camera: TCamera);
  71304. /**
  71305. * Add an input method to a camera
  71306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71307. * @param input camera input method
  71308. */
  71309. add(input: ICameraInput<TCamera>): void;
  71310. /**
  71311. * Remove a specific input method from a camera
  71312. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71313. * @param inputToRemove camera input method
  71314. */
  71315. remove(inputToRemove: ICameraInput<TCamera>): void;
  71316. /**
  71317. * Remove a specific input type from a camera
  71318. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71319. * @param inputType the type of the input to remove
  71320. */
  71321. removeByType(inputType: string): void;
  71322. private _addCheckInputs;
  71323. /**
  71324. * Attach the input controls to the currently attached dom element to listen the events from.
  71325. * @param input Defines the input to attach
  71326. */
  71327. attachInput(input: ICameraInput<TCamera>): void;
  71328. /**
  71329. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71330. * @param element Defines the dom element to collect the events from
  71331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71332. */
  71333. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71334. /**
  71335. * Detach the current manager inputs controls from a specific dom element.
  71336. * @param element Defines the dom element to collect the events from
  71337. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71338. */
  71339. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71340. /**
  71341. * Rebuild the dynamic inputCheck function from the current list of
  71342. * defined inputs in the manager.
  71343. */
  71344. rebuildInputCheck(): void;
  71345. /**
  71346. * Remove all attached input methods from a camera
  71347. */
  71348. clear(): void;
  71349. /**
  71350. * Serialize the current input manager attached to a camera.
  71351. * This ensures than once parsed,
  71352. * the input associated to the camera will be identical to the current ones
  71353. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71354. */
  71355. serialize(serializedCamera: any): void;
  71356. /**
  71357. * Parses an input manager serialized JSON to restore the previous list of inputs
  71358. * and states associated to a camera.
  71359. * @param parsedCamera Defines the JSON to parse
  71360. */
  71361. parse(parsedCamera: any): void;
  71362. }
  71363. }
  71364. declare module BABYLON {
  71365. /**
  71366. * @hidden
  71367. */
  71368. export class IntersectionInfo {
  71369. bu: Nullable<number>;
  71370. bv: Nullable<number>;
  71371. distance: number;
  71372. faceId: number;
  71373. subMeshId: number;
  71374. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71375. }
  71376. }
  71377. declare module BABYLON {
  71378. /**
  71379. * Represens a plane by the equation ax + by + cz + d = 0
  71380. */
  71381. export class Plane {
  71382. private static _TmpMatrix;
  71383. /**
  71384. * Normal of the plane (a,b,c)
  71385. */
  71386. normal: Vector3;
  71387. /**
  71388. * d component of the plane
  71389. */
  71390. d: number;
  71391. /**
  71392. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71393. * @param a a component of the plane
  71394. * @param b b component of the plane
  71395. * @param c c component of the plane
  71396. * @param d d component of the plane
  71397. */
  71398. constructor(a: number, b: number, c: number, d: number);
  71399. /**
  71400. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71401. */
  71402. asArray(): number[];
  71403. /**
  71404. * @returns a new plane copied from the current Plane.
  71405. */
  71406. clone(): Plane;
  71407. /**
  71408. * @returns the string "Plane".
  71409. */
  71410. getClassName(): string;
  71411. /**
  71412. * @returns the Plane hash code.
  71413. */
  71414. getHashCode(): number;
  71415. /**
  71416. * Normalize the current Plane in place.
  71417. * @returns the updated Plane.
  71418. */
  71419. normalize(): Plane;
  71420. /**
  71421. * Applies a transformation the plane and returns the result
  71422. * @param transformation the transformation matrix to be applied to the plane
  71423. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71424. */
  71425. transform(transformation: DeepImmutable<Matrix>): Plane;
  71426. /**
  71427. * Calcualtte the dot product between the point and the plane normal
  71428. * @param point point to calculate the dot product with
  71429. * @returns the dot product (float) of the point coordinates and the plane normal.
  71430. */
  71431. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71432. /**
  71433. * Updates the current Plane from the plane defined by the three given points.
  71434. * @param point1 one of the points used to contruct the plane
  71435. * @param point2 one of the points used to contruct the plane
  71436. * @param point3 one of the points used to contruct the plane
  71437. * @returns the updated Plane.
  71438. */
  71439. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71440. /**
  71441. * Checks if the plane is facing a given direction
  71442. * @param direction the direction to check if the plane is facing
  71443. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71444. * @returns True is the vector "direction" is the same side than the plane normal.
  71445. */
  71446. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71447. /**
  71448. * Calculates the distance to a point
  71449. * @param point point to calculate distance to
  71450. * @returns the signed distance (float) from the given point to the Plane.
  71451. */
  71452. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71453. /**
  71454. * Creates a plane from an array
  71455. * @param array the array to create a plane from
  71456. * @returns a new Plane from the given array.
  71457. */
  71458. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71459. /**
  71460. * Creates a plane from three points
  71461. * @param point1 point used to create the plane
  71462. * @param point2 point used to create the plane
  71463. * @param point3 point used to create the plane
  71464. * @returns a new Plane defined by the three given points.
  71465. */
  71466. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71467. /**
  71468. * Creates a plane from an origin point and a normal
  71469. * @param origin origin of the plane to be constructed
  71470. * @param normal normal of the plane to be constructed
  71471. * @returns a new Plane the normal vector to this plane at the given origin point.
  71472. * Note : the vector "normal" is updated because normalized.
  71473. */
  71474. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71475. /**
  71476. * Calculates the distance from a plane and a point
  71477. * @param origin origin of the plane to be constructed
  71478. * @param normal normal of the plane to be constructed
  71479. * @param point point to calculate distance to
  71480. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71481. */
  71482. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71483. }
  71484. }
  71485. declare module BABYLON {
  71486. /**
  71487. * Class used to store bounding sphere information
  71488. */
  71489. export class BoundingSphere {
  71490. /**
  71491. * Gets the center of the bounding sphere in local space
  71492. */
  71493. readonly center: Vector3;
  71494. /**
  71495. * Radius of the bounding sphere in local space
  71496. */
  71497. radius: number;
  71498. /**
  71499. * Gets the center of the bounding sphere in world space
  71500. */
  71501. readonly centerWorld: Vector3;
  71502. /**
  71503. * Radius of the bounding sphere in world space
  71504. */
  71505. radiusWorld: number;
  71506. /**
  71507. * Gets the minimum vector in local space
  71508. */
  71509. readonly minimum: Vector3;
  71510. /**
  71511. * Gets the maximum vector in local space
  71512. */
  71513. readonly maximum: Vector3;
  71514. private _worldMatrix;
  71515. private static readonly TmpVector3;
  71516. /**
  71517. * Creates a new bounding sphere
  71518. * @param min defines the minimum vector (in local space)
  71519. * @param max defines the maximum vector (in local space)
  71520. * @param worldMatrix defines the new world matrix
  71521. */
  71522. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71523. /**
  71524. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71525. * @param min defines the new minimum vector (in local space)
  71526. * @param max defines the new maximum vector (in local space)
  71527. * @param worldMatrix defines the new world matrix
  71528. */
  71529. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71530. /**
  71531. * Scale the current bounding sphere by applying a scale factor
  71532. * @param factor defines the scale factor to apply
  71533. * @returns the current bounding box
  71534. */
  71535. scale(factor: number): BoundingSphere;
  71536. /**
  71537. * Gets the world matrix of the bounding box
  71538. * @returns a matrix
  71539. */
  71540. getWorldMatrix(): DeepImmutable<Matrix>;
  71541. /** @hidden */
  71542. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71543. /**
  71544. * Tests if the bounding sphere is intersecting the frustum planes
  71545. * @param frustumPlanes defines the frustum planes to test
  71546. * @returns true if there is an intersection
  71547. */
  71548. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71549. /**
  71550. * Tests if the bounding sphere center is in between the frustum planes.
  71551. * Used for optimistic fast inclusion.
  71552. * @param frustumPlanes defines the frustum planes to test
  71553. * @returns true if the sphere center is in between the frustum planes
  71554. */
  71555. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71556. /**
  71557. * Tests if a point is inside the bounding sphere
  71558. * @param point defines the point to test
  71559. * @returns true if the point is inside the bounding sphere
  71560. */
  71561. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71562. /**
  71563. * Checks if two sphere intersct
  71564. * @param sphere0 sphere 0
  71565. * @param sphere1 sphere 1
  71566. * @returns true if the speres intersect
  71567. */
  71568. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71569. }
  71570. }
  71571. declare module BABYLON {
  71572. /**
  71573. * Class used to store bounding box information
  71574. */
  71575. export class BoundingBox implements ICullable {
  71576. /**
  71577. * Gets the 8 vectors representing the bounding box in local space
  71578. */
  71579. readonly vectors: Vector3[];
  71580. /**
  71581. * Gets the center of the bounding box in local space
  71582. */
  71583. readonly center: Vector3;
  71584. /**
  71585. * Gets the center of the bounding box in world space
  71586. */
  71587. readonly centerWorld: Vector3;
  71588. /**
  71589. * Gets the extend size in local space
  71590. */
  71591. readonly extendSize: Vector3;
  71592. /**
  71593. * Gets the extend size in world space
  71594. */
  71595. readonly extendSizeWorld: Vector3;
  71596. /**
  71597. * Gets the OBB (object bounding box) directions
  71598. */
  71599. readonly directions: Vector3[];
  71600. /**
  71601. * Gets the 8 vectors representing the bounding box in world space
  71602. */
  71603. readonly vectorsWorld: Vector3[];
  71604. /**
  71605. * Gets the minimum vector in world space
  71606. */
  71607. readonly minimumWorld: Vector3;
  71608. /**
  71609. * Gets the maximum vector in world space
  71610. */
  71611. readonly maximumWorld: Vector3;
  71612. /**
  71613. * Gets the minimum vector in local space
  71614. */
  71615. readonly minimum: Vector3;
  71616. /**
  71617. * Gets the maximum vector in local space
  71618. */
  71619. readonly maximum: Vector3;
  71620. private _worldMatrix;
  71621. private static readonly TmpVector3;
  71622. /**
  71623. * @hidden
  71624. */
  71625. _tag: number;
  71626. /**
  71627. * Creates a new bounding box
  71628. * @param min defines the minimum vector (in local space)
  71629. * @param max defines the maximum vector (in local space)
  71630. * @param worldMatrix defines the new world matrix
  71631. */
  71632. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71633. /**
  71634. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71635. * @param min defines the new minimum vector (in local space)
  71636. * @param max defines the new maximum vector (in local space)
  71637. * @param worldMatrix defines the new world matrix
  71638. */
  71639. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71640. /**
  71641. * Scale the current bounding box by applying a scale factor
  71642. * @param factor defines the scale factor to apply
  71643. * @returns the current bounding box
  71644. */
  71645. scale(factor: number): BoundingBox;
  71646. /**
  71647. * Gets the world matrix of the bounding box
  71648. * @returns a matrix
  71649. */
  71650. getWorldMatrix(): DeepImmutable<Matrix>;
  71651. /** @hidden */
  71652. _update(world: DeepImmutable<Matrix>): void;
  71653. /**
  71654. * Tests if the bounding box is intersecting the frustum planes
  71655. * @param frustumPlanes defines the frustum planes to test
  71656. * @returns true if there is an intersection
  71657. */
  71658. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71659. /**
  71660. * Tests if the bounding box is entirely inside the frustum planes
  71661. * @param frustumPlanes defines the frustum planes to test
  71662. * @returns true if there is an inclusion
  71663. */
  71664. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71665. /**
  71666. * Tests if a point is inside the bounding box
  71667. * @param point defines the point to test
  71668. * @returns true if the point is inside the bounding box
  71669. */
  71670. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71671. /**
  71672. * Tests if the bounding box intersects with a bounding sphere
  71673. * @param sphere defines the sphere to test
  71674. * @returns true if there is an intersection
  71675. */
  71676. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71677. /**
  71678. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71679. * @param min defines the min vector to use
  71680. * @param max defines the max vector to use
  71681. * @returns true if there is an intersection
  71682. */
  71683. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71684. /**
  71685. * Tests if two bounding boxes are intersections
  71686. * @param box0 defines the first box to test
  71687. * @param box1 defines the second box to test
  71688. * @returns true if there is an intersection
  71689. */
  71690. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71691. /**
  71692. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71693. * @param minPoint defines the minimum vector of the bounding box
  71694. * @param maxPoint defines the maximum vector of the bounding box
  71695. * @param sphereCenter defines the sphere center
  71696. * @param sphereRadius defines the sphere radius
  71697. * @returns true if there is an intersection
  71698. */
  71699. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71700. /**
  71701. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71702. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71703. * @param frustumPlanes defines the frustum planes to test
  71704. * @return true if there is an inclusion
  71705. */
  71706. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71707. /**
  71708. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71709. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71710. * @param frustumPlanes defines the frustum planes to test
  71711. * @return true if there is an intersection
  71712. */
  71713. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /** @hidden */
  71718. export class Collider {
  71719. /** Define if a collision was found */
  71720. collisionFound: boolean;
  71721. /**
  71722. * Define last intersection point in local space
  71723. */
  71724. intersectionPoint: Vector3;
  71725. /**
  71726. * Define last collided mesh
  71727. */
  71728. collidedMesh: Nullable<AbstractMesh>;
  71729. private _collisionPoint;
  71730. private _planeIntersectionPoint;
  71731. private _tempVector;
  71732. private _tempVector2;
  71733. private _tempVector3;
  71734. private _tempVector4;
  71735. private _edge;
  71736. private _baseToVertex;
  71737. private _destinationPoint;
  71738. private _slidePlaneNormal;
  71739. private _displacementVector;
  71740. /** @hidden */
  71741. _radius: Vector3;
  71742. /** @hidden */
  71743. _retry: number;
  71744. private _velocity;
  71745. private _basePoint;
  71746. private _epsilon;
  71747. /** @hidden */
  71748. _velocityWorldLength: number;
  71749. /** @hidden */
  71750. _basePointWorld: Vector3;
  71751. private _velocityWorld;
  71752. private _normalizedVelocity;
  71753. /** @hidden */
  71754. _initialVelocity: Vector3;
  71755. /** @hidden */
  71756. _initialPosition: Vector3;
  71757. private _nearestDistance;
  71758. private _collisionMask;
  71759. collisionMask: number;
  71760. /**
  71761. * Gets the plane normal used to compute the sliding response (in local space)
  71762. */
  71763. readonly slidePlaneNormal: Vector3;
  71764. /** @hidden */
  71765. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71766. /** @hidden */
  71767. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71768. /** @hidden */
  71769. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71770. /** @hidden */
  71771. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71772. /** @hidden */
  71773. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71774. /** @hidden */
  71775. _getResponse(pos: Vector3, vel: Vector3): void;
  71776. }
  71777. }
  71778. declare module BABYLON {
  71779. /**
  71780. * Interface for cullable objects
  71781. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71782. */
  71783. export interface ICullable {
  71784. /**
  71785. * Checks if the object or part of the object is in the frustum
  71786. * @param frustumPlanes Camera near/planes
  71787. * @returns true if the object is in frustum otherwise false
  71788. */
  71789. isInFrustum(frustumPlanes: Plane[]): boolean;
  71790. /**
  71791. * Checks if a cullable object (mesh...) is in the camera frustum
  71792. * Unlike isInFrustum this cheks the full bounding box
  71793. * @param frustumPlanes Camera near/planes
  71794. * @returns true if the object is in frustum otherwise false
  71795. */
  71796. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71797. }
  71798. /**
  71799. * Info for a bounding data of a mesh
  71800. */
  71801. export class BoundingInfo implements ICullable {
  71802. /**
  71803. * Bounding box for the mesh
  71804. */
  71805. readonly boundingBox: BoundingBox;
  71806. /**
  71807. * Bounding sphere for the mesh
  71808. */
  71809. readonly boundingSphere: BoundingSphere;
  71810. private _isLocked;
  71811. private static readonly TmpVector3;
  71812. /**
  71813. * Constructs bounding info
  71814. * @param minimum min vector of the bounding box/sphere
  71815. * @param maximum max vector of the bounding box/sphere
  71816. * @param worldMatrix defines the new world matrix
  71817. */
  71818. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71819. /**
  71820. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71821. * @param min defines the new minimum vector (in local space)
  71822. * @param max defines the new maximum vector (in local space)
  71823. * @param worldMatrix defines the new world matrix
  71824. */
  71825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71826. /**
  71827. * min vector of the bounding box/sphere
  71828. */
  71829. readonly minimum: Vector3;
  71830. /**
  71831. * max vector of the bounding box/sphere
  71832. */
  71833. readonly maximum: Vector3;
  71834. /**
  71835. * If the info is locked and won't be updated to avoid perf overhead
  71836. */
  71837. isLocked: boolean;
  71838. /**
  71839. * Updates the bounding sphere and box
  71840. * @param world world matrix to be used to update
  71841. */
  71842. update(world: DeepImmutable<Matrix>): void;
  71843. /**
  71844. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71845. * @param center New center of the bounding info
  71846. * @param extend New extend of the bounding info
  71847. * @returns the current bounding info
  71848. */
  71849. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71850. /**
  71851. * Scale the current bounding info by applying a scale factor
  71852. * @param factor defines the scale factor to apply
  71853. * @returns the current bounding info
  71854. */
  71855. scale(factor: number): BoundingInfo;
  71856. /**
  71857. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71858. * @param frustumPlanes defines the frustum to test
  71859. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71860. * @returns true if the bounding info is in the frustum planes
  71861. */
  71862. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71863. /**
  71864. * Gets the world distance between the min and max points of the bounding box
  71865. */
  71866. readonly diagonalLength: number;
  71867. /**
  71868. * Checks if a cullable object (mesh...) is in the camera frustum
  71869. * Unlike isInFrustum this cheks the full bounding box
  71870. * @param frustumPlanes Camera near/planes
  71871. * @returns true if the object is in frustum otherwise false
  71872. */
  71873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71874. /** @hidden */
  71875. _checkCollision(collider: Collider): boolean;
  71876. /**
  71877. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71878. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71879. * @param point the point to check intersection with
  71880. * @returns if the point intersects
  71881. */
  71882. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71883. /**
  71884. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71885. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71886. * @param boundingInfo the bounding info to check intersection with
  71887. * @param precise if the intersection should be done using OBB
  71888. * @returns if the bounding info intersects
  71889. */
  71890. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71891. }
  71892. }
  71893. declare module BABYLON {
  71894. /**
  71895. * Extracts minimum and maximum values from a list of indexed positions
  71896. * @param positions defines the positions to use
  71897. * @param indices defines the indices to the positions
  71898. * @param indexStart defines the start index
  71899. * @param indexCount defines the end index
  71900. * @param bias defines bias value to add to the result
  71901. * @return minimum and maximum values
  71902. */
  71903. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71904. minimum: Vector3;
  71905. maximum: Vector3;
  71906. };
  71907. /**
  71908. * Extracts minimum and maximum values from a list of positions
  71909. * @param positions defines the positions to use
  71910. * @param start defines the start index in the positions array
  71911. * @param count defines the number of positions to handle
  71912. * @param bias defines bias value to add to the result
  71913. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71914. * @return minimum and maximum values
  71915. */
  71916. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71917. minimum: Vector3;
  71918. maximum: Vector3;
  71919. };
  71920. }
  71921. declare module BABYLON {
  71922. /**
  71923. * Enum that determines the text-wrapping mode to use.
  71924. */
  71925. export enum InspectableType {
  71926. /**
  71927. * Checkbox for booleans
  71928. */
  71929. Checkbox = 0,
  71930. /**
  71931. * Sliders for numbers
  71932. */
  71933. Slider = 1,
  71934. /**
  71935. * Vector3
  71936. */
  71937. Vector3 = 2,
  71938. /**
  71939. * Quaternions
  71940. */
  71941. Quaternion = 3,
  71942. /**
  71943. * Color3
  71944. */
  71945. Color3 = 4,
  71946. /**
  71947. * String
  71948. */
  71949. String = 5
  71950. }
  71951. /**
  71952. * Interface used to define custom inspectable properties.
  71953. * This interface is used by the inspector to display custom property grids
  71954. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71955. */
  71956. export interface IInspectable {
  71957. /**
  71958. * Gets the label to display
  71959. */
  71960. label: string;
  71961. /**
  71962. * Gets the name of the property to edit
  71963. */
  71964. propertyName: string;
  71965. /**
  71966. * Gets the type of the editor to use
  71967. */
  71968. type: InspectableType;
  71969. /**
  71970. * Gets the minimum value of the property when using in "slider" mode
  71971. */
  71972. min?: number;
  71973. /**
  71974. * Gets the maximum value of the property when using in "slider" mode
  71975. */
  71976. max?: number;
  71977. /**
  71978. * Gets the setp to use when using in "slider" mode
  71979. */
  71980. step?: number;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * Class used to provide helper for timing
  71986. */
  71987. export class TimingTools {
  71988. /**
  71989. * Polyfill for setImmediate
  71990. * @param action defines the action to execute after the current execution block
  71991. */
  71992. static SetImmediate(action: () => void): void;
  71993. }
  71994. }
  71995. declare module BABYLON {
  71996. /**
  71997. * Class used to enable instatition of objects by class name
  71998. */
  71999. export class InstantiationTools {
  72000. /**
  72001. * Use this object to register external classes like custom textures or material
  72002. * to allow the laoders to instantiate them
  72003. */
  72004. static RegisteredExternalClasses: {
  72005. [key: string]: Object;
  72006. };
  72007. /**
  72008. * Tries to instantiate a new object from a given class name
  72009. * @param className defines the class name to instantiate
  72010. * @returns the new object or null if the system was not able to do the instantiation
  72011. */
  72012. static Instantiate(className: string): any;
  72013. }
  72014. }
  72015. declare module BABYLON {
  72016. /**
  72017. * This represents the required contract to create a new type of texture loader.
  72018. */
  72019. export interface IInternalTextureLoader {
  72020. /**
  72021. * Defines wether the loader supports cascade loading the different faces.
  72022. */
  72023. supportCascades: boolean;
  72024. /**
  72025. * This returns if the loader support the current file information.
  72026. * @param extension defines the file extension of the file being loaded
  72027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72028. * @param fallback defines the fallback internal texture if any
  72029. * @param isBase64 defines whether the texture is encoded as a base64
  72030. * @param isBuffer defines whether the texture data are stored as a buffer
  72031. * @returns true if the loader can load the specified file
  72032. */
  72033. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72034. /**
  72035. * Transform the url before loading if required.
  72036. * @param rootUrl the url of the texture
  72037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72038. * @returns the transformed texture
  72039. */
  72040. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72041. /**
  72042. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72043. * @param rootUrl the url of the texture
  72044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72045. * @returns the fallback texture
  72046. */
  72047. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72048. /**
  72049. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72050. * @param data contains the texture data
  72051. * @param texture defines the BabylonJS internal texture
  72052. * @param createPolynomials will be true if polynomials have been requested
  72053. * @param onLoad defines the callback to trigger once the texture is ready
  72054. * @param onError defines the callback to trigger in case of error
  72055. */
  72056. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72057. /**
  72058. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72059. * @param data contains the texture data
  72060. * @param texture defines the BabylonJS internal texture
  72061. * @param callback defines the method to call once ready to upload
  72062. */
  72063. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. interface Engine {
  72068. /**
  72069. * Creates a depth stencil cube texture.
  72070. * This is only available in WebGL 2.
  72071. * @param size The size of face edge in the cube texture.
  72072. * @param options The options defining the cube texture.
  72073. * @returns The cube texture
  72074. */
  72075. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72076. /**
  72077. * Creates a cube texture
  72078. * @param rootUrl defines the url where the files to load is located
  72079. * @param scene defines the current scene
  72080. * @param files defines the list of files to load (1 per face)
  72081. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72082. * @param onLoad defines an optional callback raised when the texture is loaded
  72083. * @param onError defines an optional callback raised if there is an issue to load the texture
  72084. * @param format defines the format of the data
  72085. * @param forcedExtension defines the extension to use to pick the right loader
  72086. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72087. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72088. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72089. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72090. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72091. * @returns the cube texture as an InternalTexture
  72092. */
  72093. 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;
  72094. /**
  72095. * Creates a cube texture
  72096. * @param rootUrl defines the url where the files to load is located
  72097. * @param scene defines the current scene
  72098. * @param files defines the list of files to load (1 per face)
  72099. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72100. * @param onLoad defines an optional callback raised when the texture is loaded
  72101. * @param onError defines an optional callback raised if there is an issue to load the texture
  72102. * @param format defines the format of the data
  72103. * @param forcedExtension defines the extension to use to pick the right loader
  72104. * @returns the cube texture as an InternalTexture
  72105. */
  72106. 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;
  72107. /**
  72108. * Creates a cube texture
  72109. * @param rootUrl defines the url where the files to load is located
  72110. * @param scene defines the current scene
  72111. * @param files defines the list of files to load (1 per face)
  72112. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72113. * @param onLoad defines an optional callback raised when the texture is loaded
  72114. * @param onError defines an optional callback raised if there is an issue to load the texture
  72115. * @param format defines the format of the data
  72116. * @param forcedExtension defines the extension to use to pick the right loader
  72117. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72118. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72119. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72120. * @returns the cube texture as an InternalTexture
  72121. */
  72122. 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;
  72123. /** @hidden */
  72124. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72125. /** @hidden */
  72126. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72127. /** @hidden */
  72128. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72129. /** @hidden */
  72130. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72131. }
  72132. }
  72133. declare module BABYLON {
  72134. /**
  72135. * Class for creating a cube texture
  72136. */
  72137. export class CubeTexture extends BaseTexture {
  72138. private _delayedOnLoad;
  72139. /**
  72140. * The url of the texture
  72141. */
  72142. url: string;
  72143. /**
  72144. * Gets or sets the center of the bounding box associated with the cube texture.
  72145. * It must define where the camera used to render the texture was set
  72146. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72147. */
  72148. boundingBoxPosition: Vector3;
  72149. private _boundingBoxSize;
  72150. /**
  72151. * Gets or sets the size of the bounding box associated with the cube texture
  72152. * When defined, the cubemap will switch to local mode
  72153. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72154. * @example https://www.babylonjs-playground.com/#RNASML
  72155. */
  72156. /**
  72157. * Returns the bounding box size
  72158. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72159. */
  72160. boundingBoxSize: Vector3;
  72161. protected _rotationY: number;
  72162. /**
  72163. * Sets texture matrix rotation angle around Y axis in radians.
  72164. */
  72165. /**
  72166. * Gets texture matrix rotation angle around Y axis radians.
  72167. */
  72168. rotationY: number;
  72169. /**
  72170. * Are mip maps generated for this texture or not.
  72171. */
  72172. readonly noMipmap: boolean;
  72173. private _noMipmap;
  72174. private _files;
  72175. private _extensions;
  72176. private _textureMatrix;
  72177. private _format;
  72178. private _createPolynomials;
  72179. /** @hidden */
  72180. _prefiltered: boolean;
  72181. /**
  72182. * Creates a cube texture from an array of image urls
  72183. * @param files defines an array of image urls
  72184. * @param scene defines the hosting scene
  72185. * @param noMipmap specifies if mip maps are not used
  72186. * @returns a cube texture
  72187. */
  72188. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72189. /**
  72190. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72191. * @param url defines the url of the prefiltered texture
  72192. * @param scene defines the scene the texture is attached to
  72193. * @param forcedExtension defines the extension of the file if different from the url
  72194. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72195. * @return the prefiltered texture
  72196. */
  72197. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72198. /**
  72199. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72200. * as prefiltered data.
  72201. * @param rootUrl defines the url of the texture or the root name of the six images
  72202. * @param scene defines the scene the texture is attached to
  72203. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72204. * @param noMipmap defines if mipmaps should be created or not
  72205. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72206. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72207. * @param onError defines a callback triggered in case of error during load
  72208. * @param format defines the internal format to use for the texture once loaded
  72209. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72210. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72211. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72212. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72213. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72214. * @return the cube texture
  72215. */
  72216. 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);
  72217. /**
  72218. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72219. */
  72220. readonly isPrefiltered: boolean;
  72221. /**
  72222. * Get the current class name of the texture useful for serialization or dynamic coding.
  72223. * @returns "CubeTexture"
  72224. */
  72225. getClassName(): string;
  72226. /**
  72227. * Update the url (and optional buffer) of this texture if url was null during construction.
  72228. * @param url the url of the texture
  72229. * @param forcedExtension defines the extension to use
  72230. * @param onLoad callback called when the texture is loaded (defaults to null)
  72231. */
  72232. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72233. /**
  72234. * Delays loading of the cube texture
  72235. * @param forcedExtension defines the extension to use
  72236. */
  72237. delayLoad(forcedExtension?: string): void;
  72238. /**
  72239. * Returns the reflection texture matrix
  72240. * @returns the reflection texture matrix
  72241. */
  72242. getReflectionTextureMatrix(): Matrix;
  72243. /**
  72244. * Sets the reflection texture matrix
  72245. * @param value Reflection texture matrix
  72246. */
  72247. setReflectionTextureMatrix(value: Matrix): void;
  72248. /**
  72249. * Parses text to create a cube texture
  72250. * @param parsedTexture define the serialized text to read from
  72251. * @param scene defines the hosting scene
  72252. * @param rootUrl defines the root url of the cube texture
  72253. * @returns a cube texture
  72254. */
  72255. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72256. /**
  72257. * Makes a clone, or deep copy, of the cube texture
  72258. * @returns a new cube texture
  72259. */
  72260. clone(): CubeTexture;
  72261. }
  72262. }
  72263. declare module BABYLON {
  72264. /**
  72265. * Manages the defines for the Material
  72266. */
  72267. export class MaterialDefines {
  72268. /** @hidden */
  72269. protected _keys: string[];
  72270. private _isDirty;
  72271. /** @hidden */
  72272. _renderId: number;
  72273. /** @hidden */
  72274. _areLightsDirty: boolean;
  72275. /** @hidden */
  72276. _areAttributesDirty: boolean;
  72277. /** @hidden */
  72278. _areTexturesDirty: boolean;
  72279. /** @hidden */
  72280. _areFresnelDirty: boolean;
  72281. /** @hidden */
  72282. _areMiscDirty: boolean;
  72283. /** @hidden */
  72284. _areImageProcessingDirty: boolean;
  72285. /** @hidden */
  72286. _normals: boolean;
  72287. /** @hidden */
  72288. _uvs: boolean;
  72289. /** @hidden */
  72290. _needNormals: boolean;
  72291. /** @hidden */
  72292. _needUVs: boolean;
  72293. [id: string]: any;
  72294. /**
  72295. * Specifies if the material needs to be re-calculated
  72296. */
  72297. readonly isDirty: boolean;
  72298. /**
  72299. * Marks the material to indicate that it has been re-calculated
  72300. */
  72301. markAsProcessed(): void;
  72302. /**
  72303. * Marks the material to indicate that it needs to be re-calculated
  72304. */
  72305. markAsUnprocessed(): void;
  72306. /**
  72307. * Marks the material to indicate all of its defines need to be re-calculated
  72308. */
  72309. markAllAsDirty(): void;
  72310. /**
  72311. * Marks the material to indicate that image processing needs to be re-calculated
  72312. */
  72313. markAsImageProcessingDirty(): void;
  72314. /**
  72315. * Marks the material to indicate the lights need to be re-calculated
  72316. */
  72317. markAsLightDirty(): void;
  72318. /**
  72319. * Marks the attribute state as changed
  72320. */
  72321. markAsAttributesDirty(): void;
  72322. /**
  72323. * Marks the texture state as changed
  72324. */
  72325. markAsTexturesDirty(): void;
  72326. /**
  72327. * Marks the fresnel state as changed
  72328. */
  72329. markAsFresnelDirty(): void;
  72330. /**
  72331. * Marks the misc state as changed
  72332. */
  72333. markAsMiscDirty(): void;
  72334. /**
  72335. * Rebuilds the material defines
  72336. */
  72337. rebuild(): void;
  72338. /**
  72339. * Specifies if two material defines are equal
  72340. * @param other - A material define instance to compare to
  72341. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72342. */
  72343. isEqual(other: MaterialDefines): boolean;
  72344. /**
  72345. * Clones this instance's defines to another instance
  72346. * @param other - material defines to clone values to
  72347. */
  72348. cloneTo(other: MaterialDefines): void;
  72349. /**
  72350. * Resets the material define values
  72351. */
  72352. reset(): void;
  72353. /**
  72354. * Converts the material define values to a string
  72355. * @returns - String of material define information
  72356. */
  72357. toString(): string;
  72358. }
  72359. }
  72360. declare module BABYLON {
  72361. /**
  72362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72364. * 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;
  72365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72366. */
  72367. export class ColorCurves {
  72368. private _dirty;
  72369. private _tempColor;
  72370. private _globalCurve;
  72371. private _highlightsCurve;
  72372. private _midtonesCurve;
  72373. private _shadowsCurve;
  72374. private _positiveCurve;
  72375. private _negativeCurve;
  72376. private _globalHue;
  72377. private _globalDensity;
  72378. private _globalSaturation;
  72379. private _globalExposure;
  72380. /**
  72381. * Gets the global Hue value.
  72382. * 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).
  72383. */
  72384. /**
  72385. * Sets the global Hue value.
  72386. * 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).
  72387. */
  72388. globalHue: number;
  72389. /**
  72390. * Gets the global Density value.
  72391. * 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.
  72392. * Values less than zero provide a filter of opposite hue.
  72393. */
  72394. /**
  72395. * Sets the global Density value.
  72396. * 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.
  72397. * Values less than zero provide a filter of opposite hue.
  72398. */
  72399. globalDensity: number;
  72400. /**
  72401. * Gets the global Saturation value.
  72402. * 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.
  72403. */
  72404. /**
  72405. * Sets the global Saturation value.
  72406. * 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.
  72407. */
  72408. globalSaturation: number;
  72409. /**
  72410. * Gets the global Exposure value.
  72411. * 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.
  72412. */
  72413. /**
  72414. * Sets the global Exposure value.
  72415. * 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.
  72416. */
  72417. globalExposure: number;
  72418. private _highlightsHue;
  72419. private _highlightsDensity;
  72420. private _highlightsSaturation;
  72421. private _highlightsExposure;
  72422. /**
  72423. * Gets the highlights Hue value.
  72424. * 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).
  72425. */
  72426. /**
  72427. * Sets the highlights Hue value.
  72428. * 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).
  72429. */
  72430. highlightsHue: number;
  72431. /**
  72432. * Gets the highlights Density value.
  72433. * 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.
  72434. * Values less than zero provide a filter of opposite hue.
  72435. */
  72436. /**
  72437. * Sets the highlights Density value.
  72438. * 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.
  72439. * Values less than zero provide a filter of opposite hue.
  72440. */
  72441. highlightsDensity: number;
  72442. /**
  72443. * Gets the highlights Saturation value.
  72444. * 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.
  72445. */
  72446. /**
  72447. * Sets the highlights Saturation value.
  72448. * 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.
  72449. */
  72450. highlightsSaturation: number;
  72451. /**
  72452. * Gets the highlights Exposure value.
  72453. * 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.
  72454. */
  72455. /**
  72456. * Sets the highlights Exposure value.
  72457. * 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.
  72458. */
  72459. highlightsExposure: number;
  72460. private _midtonesHue;
  72461. private _midtonesDensity;
  72462. private _midtonesSaturation;
  72463. private _midtonesExposure;
  72464. /**
  72465. * Gets the midtones Hue value.
  72466. * 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).
  72467. */
  72468. /**
  72469. * Sets the midtones Hue value.
  72470. * 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).
  72471. */
  72472. midtonesHue: number;
  72473. /**
  72474. * Gets the midtones Density value.
  72475. * 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.
  72476. * Values less than zero provide a filter of opposite hue.
  72477. */
  72478. /**
  72479. * Sets the midtones Density value.
  72480. * 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.
  72481. * Values less than zero provide a filter of opposite hue.
  72482. */
  72483. midtonesDensity: number;
  72484. /**
  72485. * Gets the midtones Saturation value.
  72486. * 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.
  72487. */
  72488. /**
  72489. * Sets the midtones Saturation value.
  72490. * 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.
  72491. */
  72492. midtonesSaturation: number;
  72493. /**
  72494. * Gets the midtones Exposure value.
  72495. * 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.
  72496. */
  72497. /**
  72498. * Sets the midtones Exposure value.
  72499. * 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.
  72500. */
  72501. midtonesExposure: number;
  72502. private _shadowsHue;
  72503. private _shadowsDensity;
  72504. private _shadowsSaturation;
  72505. private _shadowsExposure;
  72506. /**
  72507. * Gets the shadows Hue value.
  72508. * 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).
  72509. */
  72510. /**
  72511. * Sets the shadows Hue value.
  72512. * 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).
  72513. */
  72514. shadowsHue: number;
  72515. /**
  72516. * Gets the shadows Density value.
  72517. * 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.
  72518. * Values less than zero provide a filter of opposite hue.
  72519. */
  72520. /**
  72521. * Sets the shadows Density value.
  72522. * 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.
  72523. * Values less than zero provide a filter of opposite hue.
  72524. */
  72525. shadowsDensity: number;
  72526. /**
  72527. * Gets the shadows Saturation value.
  72528. * 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.
  72529. */
  72530. /**
  72531. * Sets the shadows Saturation value.
  72532. * 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.
  72533. */
  72534. shadowsSaturation: number;
  72535. /**
  72536. * Gets the shadows Exposure value.
  72537. * 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.
  72538. */
  72539. /**
  72540. * Sets the shadows Exposure value.
  72541. * 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.
  72542. */
  72543. shadowsExposure: number;
  72544. /**
  72545. * Returns the class name
  72546. * @returns The class name
  72547. */
  72548. getClassName(): string;
  72549. /**
  72550. * Binds the color curves to the shader.
  72551. * @param colorCurves The color curve to bind
  72552. * @param effect The effect to bind to
  72553. * @param positiveUniform The positive uniform shader parameter
  72554. * @param neutralUniform The neutral uniform shader parameter
  72555. * @param negativeUniform The negative uniform shader parameter
  72556. */
  72557. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72558. /**
  72559. * Prepare the list of uniforms associated with the ColorCurves effects.
  72560. * @param uniformsList The list of uniforms used in the effect
  72561. */
  72562. static PrepareUniforms(uniformsList: string[]): void;
  72563. /**
  72564. * Returns color grading data based on a hue, density, saturation and exposure value.
  72565. * @param filterHue The hue of the color filter.
  72566. * @param filterDensity The density of the color filter.
  72567. * @param saturation The saturation.
  72568. * @param exposure The exposure.
  72569. * @param result The result data container.
  72570. */
  72571. private getColorGradingDataToRef;
  72572. /**
  72573. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72574. * @param value The input slider value in range [-100,100].
  72575. * @returns Adjusted value.
  72576. */
  72577. private static applyColorGradingSliderNonlinear;
  72578. /**
  72579. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72580. * @param hue The hue (H) input.
  72581. * @param saturation The saturation (S) input.
  72582. * @param brightness The brightness (B) input.
  72583. * @result An RGBA color represented as Vector4.
  72584. */
  72585. private static fromHSBToRef;
  72586. /**
  72587. * Returns a value clamped between min and max
  72588. * @param value The value to clamp
  72589. * @param min The minimum of value
  72590. * @param max The maximum of value
  72591. * @returns The clamped value.
  72592. */
  72593. private static clamp;
  72594. /**
  72595. * Clones the current color curve instance.
  72596. * @return The cloned curves
  72597. */
  72598. clone(): ColorCurves;
  72599. /**
  72600. * Serializes the current color curve instance to a json representation.
  72601. * @return a JSON representation
  72602. */
  72603. serialize(): any;
  72604. /**
  72605. * Parses the color curve from a json representation.
  72606. * @param source the JSON source to parse
  72607. * @return The parsed curves
  72608. */
  72609. static Parse(source: any): ColorCurves;
  72610. }
  72611. }
  72612. declare module BABYLON {
  72613. /**
  72614. * Interface to follow in your material defines to integrate easily the
  72615. * Image proccessing functions.
  72616. * @hidden
  72617. */
  72618. export interface IImageProcessingConfigurationDefines {
  72619. IMAGEPROCESSING: boolean;
  72620. VIGNETTE: boolean;
  72621. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72622. VIGNETTEBLENDMODEOPAQUE: boolean;
  72623. TONEMAPPING: boolean;
  72624. TONEMAPPING_ACES: boolean;
  72625. CONTRAST: boolean;
  72626. EXPOSURE: boolean;
  72627. COLORCURVES: boolean;
  72628. COLORGRADING: boolean;
  72629. COLORGRADING3D: boolean;
  72630. SAMPLER3DGREENDEPTH: boolean;
  72631. SAMPLER3DBGRMAP: boolean;
  72632. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72633. }
  72634. /**
  72635. * @hidden
  72636. */
  72637. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72638. IMAGEPROCESSING: boolean;
  72639. VIGNETTE: boolean;
  72640. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72641. VIGNETTEBLENDMODEOPAQUE: boolean;
  72642. TONEMAPPING: boolean;
  72643. TONEMAPPING_ACES: boolean;
  72644. CONTRAST: boolean;
  72645. COLORCURVES: boolean;
  72646. COLORGRADING: boolean;
  72647. COLORGRADING3D: boolean;
  72648. SAMPLER3DGREENDEPTH: boolean;
  72649. SAMPLER3DBGRMAP: boolean;
  72650. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72651. EXPOSURE: boolean;
  72652. constructor();
  72653. }
  72654. /**
  72655. * This groups together the common properties used for image processing either in direct forward pass
  72656. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72657. * or not.
  72658. */
  72659. export class ImageProcessingConfiguration {
  72660. /**
  72661. * Default tone mapping applied in BabylonJS.
  72662. */
  72663. static readonly TONEMAPPING_STANDARD: number;
  72664. /**
  72665. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72666. * to other engines rendering to increase portability.
  72667. */
  72668. static readonly TONEMAPPING_ACES: number;
  72669. /**
  72670. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72671. */
  72672. colorCurves: Nullable<ColorCurves>;
  72673. private _colorCurvesEnabled;
  72674. /**
  72675. * Gets wether the color curves effect is enabled.
  72676. */
  72677. /**
  72678. * Sets wether the color curves effect is enabled.
  72679. */
  72680. colorCurvesEnabled: boolean;
  72681. private _colorGradingTexture;
  72682. /**
  72683. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72684. */
  72685. /**
  72686. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72687. */
  72688. colorGradingTexture: Nullable<BaseTexture>;
  72689. private _colorGradingEnabled;
  72690. /**
  72691. * Gets wether the color grading effect is enabled.
  72692. */
  72693. /**
  72694. * Sets wether the color grading effect is enabled.
  72695. */
  72696. colorGradingEnabled: boolean;
  72697. private _colorGradingWithGreenDepth;
  72698. /**
  72699. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72700. */
  72701. /**
  72702. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72703. */
  72704. colorGradingWithGreenDepth: boolean;
  72705. private _colorGradingBGR;
  72706. /**
  72707. * Gets wether the color grading texture contains BGR values.
  72708. */
  72709. /**
  72710. * Sets wether the color grading texture contains BGR values.
  72711. */
  72712. colorGradingBGR: boolean;
  72713. /** @hidden */
  72714. _exposure: number;
  72715. /**
  72716. * Gets the Exposure used in the effect.
  72717. */
  72718. /**
  72719. * Sets the Exposure used in the effect.
  72720. */
  72721. exposure: number;
  72722. private _toneMappingEnabled;
  72723. /**
  72724. * Gets wether the tone mapping effect is enabled.
  72725. */
  72726. /**
  72727. * Sets wether the tone mapping effect is enabled.
  72728. */
  72729. toneMappingEnabled: boolean;
  72730. private _toneMappingType;
  72731. /**
  72732. * Gets the type of tone mapping effect.
  72733. */
  72734. /**
  72735. * Sets the type of tone mapping effect used in BabylonJS.
  72736. */
  72737. toneMappingType: number;
  72738. protected _contrast: number;
  72739. /**
  72740. * Gets the contrast used in the effect.
  72741. */
  72742. /**
  72743. * Sets the contrast used in the effect.
  72744. */
  72745. contrast: number;
  72746. /**
  72747. * Vignette stretch size.
  72748. */
  72749. vignetteStretch: number;
  72750. /**
  72751. * Vignette centre X Offset.
  72752. */
  72753. vignetteCentreX: number;
  72754. /**
  72755. * Vignette centre Y Offset.
  72756. */
  72757. vignetteCentreY: number;
  72758. /**
  72759. * Vignette weight or intensity of the vignette effect.
  72760. */
  72761. vignetteWeight: number;
  72762. /**
  72763. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72764. * if vignetteEnabled is set to true.
  72765. */
  72766. vignetteColor: Color4;
  72767. /**
  72768. * Camera field of view used by the Vignette effect.
  72769. */
  72770. vignetteCameraFov: number;
  72771. private _vignetteBlendMode;
  72772. /**
  72773. * Gets the vignette blend mode allowing different kind of effect.
  72774. */
  72775. /**
  72776. * Sets the vignette blend mode allowing different kind of effect.
  72777. */
  72778. vignetteBlendMode: number;
  72779. private _vignetteEnabled;
  72780. /**
  72781. * Gets wether the vignette effect is enabled.
  72782. */
  72783. /**
  72784. * Sets wether the vignette effect is enabled.
  72785. */
  72786. vignetteEnabled: boolean;
  72787. private _applyByPostProcess;
  72788. /**
  72789. * Gets wether the image processing is applied through a post process or not.
  72790. */
  72791. /**
  72792. * Sets wether the image processing is applied through a post process or not.
  72793. */
  72794. applyByPostProcess: boolean;
  72795. private _isEnabled;
  72796. /**
  72797. * Gets wether the image processing is enabled or not.
  72798. */
  72799. /**
  72800. * Sets wether the image processing is enabled or not.
  72801. */
  72802. isEnabled: boolean;
  72803. /**
  72804. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72805. */
  72806. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72807. /**
  72808. * Method called each time the image processing information changes requires to recompile the effect.
  72809. */
  72810. protected _updateParameters(): void;
  72811. /**
  72812. * Gets the current class name.
  72813. * @return "ImageProcessingConfiguration"
  72814. */
  72815. getClassName(): string;
  72816. /**
  72817. * Prepare the list of uniforms associated with the Image Processing effects.
  72818. * @param uniforms The list of uniforms used in the effect
  72819. * @param defines the list of defines currently in use
  72820. */
  72821. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72822. /**
  72823. * Prepare the list of samplers associated with the Image Processing effects.
  72824. * @param samplersList The list of uniforms used in the effect
  72825. * @param defines the list of defines currently in use
  72826. */
  72827. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72828. /**
  72829. * Prepare the list of defines associated to the shader.
  72830. * @param defines the list of defines to complete
  72831. * @param forPostProcess Define if we are currently in post process mode or not
  72832. */
  72833. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72834. /**
  72835. * Returns true if all the image processing information are ready.
  72836. * @returns True if ready, otherwise, false
  72837. */
  72838. isReady(): boolean;
  72839. /**
  72840. * Binds the image processing to the shader.
  72841. * @param effect The effect to bind to
  72842. * @param aspectRatio Define the current aspect ratio of the effect
  72843. */
  72844. bind(effect: Effect, aspectRatio?: number): void;
  72845. /**
  72846. * Clones the current image processing instance.
  72847. * @return The cloned image processing
  72848. */
  72849. clone(): ImageProcessingConfiguration;
  72850. /**
  72851. * Serializes the current image processing instance to a json representation.
  72852. * @return a JSON representation
  72853. */
  72854. serialize(): any;
  72855. /**
  72856. * Parses the image processing from a json representation.
  72857. * @param source the JSON source to parse
  72858. * @return The parsed image processing
  72859. */
  72860. static Parse(source: any): ImageProcessingConfiguration;
  72861. private static _VIGNETTEMODE_MULTIPLY;
  72862. private static _VIGNETTEMODE_OPAQUE;
  72863. /**
  72864. * Used to apply the vignette as a mix with the pixel color.
  72865. */
  72866. static readonly VIGNETTEMODE_MULTIPLY: number;
  72867. /**
  72868. * Used to apply the vignette as a replacement of the pixel color.
  72869. */
  72870. static readonly VIGNETTEMODE_OPAQUE: number;
  72871. }
  72872. }
  72873. declare module BABYLON {
  72874. /** @hidden */
  72875. export var postprocessVertexShader: {
  72876. name: string;
  72877. shader: string;
  72878. };
  72879. }
  72880. declare module BABYLON {
  72881. /** Defines supported spaces */
  72882. export enum Space {
  72883. /** Local (object) space */
  72884. LOCAL = 0,
  72885. /** World space */
  72886. WORLD = 1,
  72887. /** Bone space */
  72888. BONE = 2
  72889. }
  72890. /** Defines the 3 main axes */
  72891. export class Axis {
  72892. /** X axis */
  72893. static X: Vector3;
  72894. /** Y axis */
  72895. static Y: Vector3;
  72896. /** Z axis */
  72897. static Z: Vector3;
  72898. }
  72899. }
  72900. declare module BABYLON {
  72901. /**
  72902. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72903. * This is the base of the follow, arc rotate cameras and Free camera
  72904. * @see http://doc.babylonjs.com/features/cameras
  72905. */
  72906. export class TargetCamera extends Camera {
  72907. private static _RigCamTransformMatrix;
  72908. private static _TargetTransformMatrix;
  72909. private static _TargetFocalPoint;
  72910. /**
  72911. * Define the current direction the camera is moving to
  72912. */
  72913. cameraDirection: Vector3;
  72914. /**
  72915. * Define the current rotation the camera is rotating to
  72916. */
  72917. cameraRotation: Vector2;
  72918. /**
  72919. * When set, the up vector of the camera will be updated by the rotation of the camera
  72920. */
  72921. updateUpVectorFromRotation: boolean;
  72922. private _tmpQuaternion;
  72923. /**
  72924. * Define the current rotation of the camera
  72925. */
  72926. rotation: Vector3;
  72927. /**
  72928. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72929. */
  72930. rotationQuaternion: Quaternion;
  72931. /**
  72932. * Define the current speed of the camera
  72933. */
  72934. speed: number;
  72935. /**
  72936. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72937. * around all axis.
  72938. */
  72939. noRotationConstraint: boolean;
  72940. /**
  72941. * Define the current target of the camera as an object or a position.
  72942. */
  72943. lockedTarget: any;
  72944. /** @hidden */
  72945. _currentTarget: Vector3;
  72946. /** @hidden */
  72947. _initialFocalDistance: number;
  72948. /** @hidden */
  72949. _viewMatrix: Matrix;
  72950. /** @hidden */
  72951. _camMatrix: Matrix;
  72952. /** @hidden */
  72953. _cameraTransformMatrix: Matrix;
  72954. /** @hidden */
  72955. _cameraRotationMatrix: Matrix;
  72956. /** @hidden */
  72957. _referencePoint: Vector3;
  72958. /** @hidden */
  72959. _transformedReferencePoint: Vector3;
  72960. protected _globalCurrentTarget: Vector3;
  72961. protected _globalCurrentUpVector: Vector3;
  72962. /** @hidden */
  72963. _reset: () => void;
  72964. private _defaultUp;
  72965. /**
  72966. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72967. * This is the base of the follow, arc rotate cameras and Free camera
  72968. * @see http://doc.babylonjs.com/features/cameras
  72969. * @param name Defines the name of the camera in the scene
  72970. * @param position Defines the start position of the camera in the scene
  72971. * @param scene Defines the scene the camera belongs to
  72972. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72973. */
  72974. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72975. /**
  72976. * Gets the position in front of the camera at a given distance.
  72977. * @param distance The distance from the camera we want the position to be
  72978. * @returns the position
  72979. */
  72980. getFrontPosition(distance: number): Vector3;
  72981. /** @hidden */
  72982. _getLockedTargetPosition(): Nullable<Vector3>;
  72983. private _storedPosition;
  72984. private _storedRotation;
  72985. private _storedRotationQuaternion;
  72986. /**
  72987. * Store current camera state of the camera (fov, position, rotation, etc..)
  72988. * @returns the camera
  72989. */
  72990. storeState(): Camera;
  72991. /**
  72992. * Restored camera state. You must call storeState() first
  72993. * @returns whether it was successful or not
  72994. * @hidden
  72995. */
  72996. _restoreStateValues(): boolean;
  72997. /** @hidden */
  72998. _initCache(): void;
  72999. /** @hidden */
  73000. _updateCache(ignoreParentClass?: boolean): void;
  73001. /** @hidden */
  73002. _isSynchronizedViewMatrix(): boolean;
  73003. /** @hidden */
  73004. _computeLocalCameraSpeed(): number;
  73005. /**
  73006. * Defines the target the camera should look at.
  73007. * @param target Defines the new target as a Vector or a mesh
  73008. */
  73009. setTarget(target: Vector3): void;
  73010. /**
  73011. * Return the current target position of the camera. This value is expressed in local space.
  73012. * @returns the target position
  73013. */
  73014. getTarget(): Vector3;
  73015. /** @hidden */
  73016. _decideIfNeedsToMove(): boolean;
  73017. /** @hidden */
  73018. _updatePosition(): void;
  73019. /** @hidden */
  73020. _checkInputs(): void;
  73021. protected _updateCameraRotationMatrix(): void;
  73022. /**
  73023. * 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)
  73024. * @returns the current camera
  73025. */
  73026. private _rotateUpVectorWithCameraRotationMatrix;
  73027. private _cachedRotationZ;
  73028. private _cachedQuaternionRotationZ;
  73029. /** @hidden */
  73030. _getViewMatrix(): Matrix;
  73031. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73032. /**
  73033. * @hidden
  73034. */
  73035. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73036. /**
  73037. * @hidden
  73038. */
  73039. _updateRigCameras(): void;
  73040. private _getRigCamPositionAndTarget;
  73041. /**
  73042. * Gets the current object class name.
  73043. * @return the class name
  73044. */
  73045. getClassName(): string;
  73046. }
  73047. }
  73048. declare module BABYLON {
  73049. /**
  73050. * Gather the list of keyboard event types as constants.
  73051. */
  73052. export class KeyboardEventTypes {
  73053. /**
  73054. * The keydown event is fired when a key becomes active (pressed).
  73055. */
  73056. static readonly KEYDOWN: number;
  73057. /**
  73058. * The keyup event is fired when a key has been released.
  73059. */
  73060. static readonly KEYUP: number;
  73061. }
  73062. /**
  73063. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73064. */
  73065. export class KeyboardInfo {
  73066. /**
  73067. * Defines the type of event (KeyboardEventTypes)
  73068. */
  73069. type: number;
  73070. /**
  73071. * Defines the related dom event
  73072. */
  73073. event: KeyboardEvent;
  73074. /**
  73075. * Instantiates a new keyboard info.
  73076. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73077. * @param type Defines the type of event (KeyboardEventTypes)
  73078. * @param event Defines the related dom event
  73079. */
  73080. constructor(
  73081. /**
  73082. * Defines the type of event (KeyboardEventTypes)
  73083. */
  73084. type: number,
  73085. /**
  73086. * Defines the related dom event
  73087. */
  73088. event: KeyboardEvent);
  73089. }
  73090. /**
  73091. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73092. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73093. */
  73094. export class KeyboardInfoPre extends KeyboardInfo {
  73095. /**
  73096. * Defines the type of event (KeyboardEventTypes)
  73097. */
  73098. type: number;
  73099. /**
  73100. * Defines the related dom event
  73101. */
  73102. event: KeyboardEvent;
  73103. /**
  73104. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73105. */
  73106. skipOnPointerObservable: boolean;
  73107. /**
  73108. * Instantiates a new keyboard pre info.
  73109. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73110. * @param type Defines the type of event (KeyboardEventTypes)
  73111. * @param event Defines the related dom event
  73112. */
  73113. constructor(
  73114. /**
  73115. * Defines the type of event (KeyboardEventTypes)
  73116. */
  73117. type: number,
  73118. /**
  73119. * Defines the related dom event
  73120. */
  73121. event: KeyboardEvent);
  73122. }
  73123. }
  73124. declare module BABYLON {
  73125. /**
  73126. * Manage the keyboard inputs to control the movement of a free camera.
  73127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73128. */
  73129. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73130. /**
  73131. * Defines the camera the input is attached to.
  73132. */
  73133. camera: FreeCamera;
  73134. /**
  73135. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73136. */
  73137. keysUp: number[];
  73138. /**
  73139. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73140. */
  73141. keysDown: number[];
  73142. /**
  73143. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73144. */
  73145. keysLeft: number[];
  73146. /**
  73147. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73148. */
  73149. keysRight: number[];
  73150. private _keys;
  73151. private _onCanvasBlurObserver;
  73152. private _onKeyboardObserver;
  73153. private _engine;
  73154. private _scene;
  73155. /**
  73156. * Attach the input controls to a specific dom element to get the input from.
  73157. * @param element Defines the element the controls should be listened from
  73158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73159. */
  73160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73161. /**
  73162. * Detach the current controls from the specified dom element.
  73163. * @param element Defines the element to stop listening the inputs from
  73164. */
  73165. detachControl(element: Nullable<HTMLElement>): void;
  73166. /**
  73167. * Update the current camera state depending on the inputs that have been used this frame.
  73168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73169. */
  73170. checkInputs(): void;
  73171. /**
  73172. * Gets the class name of the current intput.
  73173. * @returns the class name
  73174. */
  73175. getClassName(): string;
  73176. /** @hidden */
  73177. _onLostFocus(): void;
  73178. /**
  73179. * Get the friendly name associated with the input class.
  73180. * @returns the input friendly name
  73181. */
  73182. getSimpleName(): string;
  73183. }
  73184. }
  73185. declare module BABYLON {
  73186. /**
  73187. * Interface describing all the common properties and methods a shadow light needs to implement.
  73188. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73189. * as well as binding the different shadow properties to the effects.
  73190. */
  73191. export interface IShadowLight extends Light {
  73192. /**
  73193. * The light id in the scene (used in scene.findLighById for instance)
  73194. */
  73195. id: string;
  73196. /**
  73197. * The position the shdow will be casted from.
  73198. */
  73199. position: Vector3;
  73200. /**
  73201. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73202. */
  73203. direction: Vector3;
  73204. /**
  73205. * The transformed position. Position of the light in world space taking parenting in account.
  73206. */
  73207. transformedPosition: Vector3;
  73208. /**
  73209. * The transformed direction. Direction of the light in world space taking parenting in account.
  73210. */
  73211. transformedDirection: Vector3;
  73212. /**
  73213. * The friendly name of the light in the scene.
  73214. */
  73215. name: string;
  73216. /**
  73217. * Defines the shadow projection clipping minimum z value.
  73218. */
  73219. shadowMinZ: number;
  73220. /**
  73221. * Defines the shadow projection clipping maximum z value.
  73222. */
  73223. shadowMaxZ: number;
  73224. /**
  73225. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73226. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73227. */
  73228. computeTransformedInformation(): boolean;
  73229. /**
  73230. * Gets the scene the light belongs to.
  73231. * @returns The scene
  73232. */
  73233. getScene(): Scene;
  73234. /**
  73235. * Callback defining a custom Projection Matrix Builder.
  73236. * This can be used to override the default projection matrix computation.
  73237. */
  73238. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73239. /**
  73240. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73241. * @param matrix The materix to updated with the projection information
  73242. * @param viewMatrix The transform matrix of the light
  73243. * @param renderList The list of mesh to render in the map
  73244. * @returns The current light
  73245. */
  73246. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73247. /**
  73248. * Gets the current depth scale used in ESM.
  73249. * @returns The scale
  73250. */
  73251. getDepthScale(): number;
  73252. /**
  73253. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73254. * @returns true if a cube texture needs to be use
  73255. */
  73256. needCube(): boolean;
  73257. /**
  73258. * Detects if the projection matrix requires to be recomputed this frame.
  73259. * @returns true if it requires to be recomputed otherwise, false.
  73260. */
  73261. needProjectionMatrixCompute(): boolean;
  73262. /**
  73263. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73264. */
  73265. forceProjectionMatrixCompute(): void;
  73266. /**
  73267. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73268. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73269. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73270. */
  73271. getShadowDirection(faceIndex?: number): Vector3;
  73272. /**
  73273. * Gets the minZ used for shadow according to both the scene and the light.
  73274. * @param activeCamera The camera we are returning the min for
  73275. * @returns the depth min z
  73276. */
  73277. getDepthMinZ(activeCamera: Camera): number;
  73278. /**
  73279. * Gets the maxZ used for shadow according to both the scene and the light.
  73280. * @param activeCamera The camera we are returning the max for
  73281. * @returns the depth max z
  73282. */
  73283. getDepthMaxZ(activeCamera: Camera): number;
  73284. }
  73285. /**
  73286. * Base implementation IShadowLight
  73287. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73288. */
  73289. export abstract class ShadowLight extends Light implements IShadowLight {
  73290. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73291. protected _position: Vector3;
  73292. protected _setPosition(value: Vector3): void;
  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. /**
  73298. * Sets the position the shadow will be casted from. Also use as the light position for both
  73299. * point and spot lights.
  73300. */
  73301. position: Vector3;
  73302. protected _direction: Vector3;
  73303. protected _setDirection(value: Vector3): void;
  73304. /**
  73305. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73306. * Also use as the light direction on spot and directional lights.
  73307. */
  73308. /**
  73309. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73310. * Also use as the light direction on spot and directional lights.
  73311. */
  73312. direction: Vector3;
  73313. private _shadowMinZ;
  73314. /**
  73315. * Gets the shadow projection clipping minimum z value.
  73316. */
  73317. /**
  73318. * Sets the shadow projection clipping minimum z value.
  73319. */
  73320. shadowMinZ: number;
  73321. private _shadowMaxZ;
  73322. /**
  73323. * Sets the shadow projection clipping maximum z value.
  73324. */
  73325. /**
  73326. * Gets the shadow projection clipping maximum z value.
  73327. */
  73328. shadowMaxZ: number;
  73329. /**
  73330. * Callback defining a custom Projection Matrix Builder.
  73331. * This can be used to override the default projection matrix computation.
  73332. */
  73333. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73334. /**
  73335. * The transformed position. Position of the light in world space taking parenting in account.
  73336. */
  73337. transformedPosition: Vector3;
  73338. /**
  73339. * The transformed direction. Direction of the light in world space taking parenting in account.
  73340. */
  73341. transformedDirection: Vector3;
  73342. private _needProjectionMatrixCompute;
  73343. /**
  73344. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73345. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73346. */
  73347. computeTransformedInformation(): boolean;
  73348. /**
  73349. * Return the depth scale used for the shadow map.
  73350. * @returns the depth scale.
  73351. */
  73352. getDepthScale(): number;
  73353. /**
  73354. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73355. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73356. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73357. */
  73358. getShadowDirection(faceIndex?: number): Vector3;
  73359. /**
  73360. * Returns the ShadowLight absolute position in the World.
  73361. * @returns the position vector in world space
  73362. */
  73363. getAbsolutePosition(): Vector3;
  73364. /**
  73365. * Sets the ShadowLight direction toward the passed target.
  73366. * @param target The point to target in local space
  73367. * @returns the updated ShadowLight direction
  73368. */
  73369. setDirectionToTarget(target: Vector3): Vector3;
  73370. /**
  73371. * Returns the light rotation in euler definition.
  73372. * @returns the x y z rotation in local space.
  73373. */
  73374. getRotation(): Vector3;
  73375. /**
  73376. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73377. * @returns true if a cube texture needs to be use
  73378. */
  73379. needCube(): boolean;
  73380. /**
  73381. * Detects if the projection matrix requires to be recomputed this frame.
  73382. * @returns true if it requires to be recomputed otherwise, false.
  73383. */
  73384. needProjectionMatrixCompute(): boolean;
  73385. /**
  73386. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73387. */
  73388. forceProjectionMatrixCompute(): void;
  73389. /** @hidden */
  73390. _initCache(): void;
  73391. /** @hidden */
  73392. _isSynchronized(): boolean;
  73393. /**
  73394. * Computes the world matrix of the node
  73395. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73396. * @returns the world matrix
  73397. */
  73398. computeWorldMatrix(force?: boolean): Matrix;
  73399. /**
  73400. * Gets the minZ used for shadow according to both the scene and the light.
  73401. * @param activeCamera The camera we are returning the min for
  73402. * @returns the depth min z
  73403. */
  73404. getDepthMinZ(activeCamera: Camera): number;
  73405. /**
  73406. * Gets the maxZ used for shadow according to both the scene and the light.
  73407. * @param activeCamera The camera we are returning the max for
  73408. * @returns the depth max z
  73409. */
  73410. getDepthMaxZ(activeCamera: Camera): number;
  73411. /**
  73412. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73413. * @param matrix The materix to updated with the projection information
  73414. * @param viewMatrix The transform matrix of the light
  73415. * @param renderList The list of mesh to render in the map
  73416. * @returns The current light
  73417. */
  73418. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73419. }
  73420. }
  73421. declare module BABYLON {
  73422. /**
  73423. * "Static Class" containing the most commonly used helper while dealing with material for
  73424. * rendering purpose.
  73425. *
  73426. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73427. *
  73428. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73429. */
  73430. export class MaterialHelper {
  73431. /**
  73432. * Bind the current view position to an effect.
  73433. * @param effect The effect to be bound
  73434. * @param scene The scene the eyes position is used from
  73435. */
  73436. static BindEyePosition(effect: Effect, scene: Scene): void;
  73437. /**
  73438. * Helps preparing the defines values about the UVs in used in the effect.
  73439. * UVs are shared as much as we can accross channels in the shaders.
  73440. * @param texture The texture we are preparing the UVs for
  73441. * @param defines The defines to update
  73442. * @param key The channel key "diffuse", "specular"... used in the shader
  73443. */
  73444. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73445. /**
  73446. * Binds a texture matrix value to its corrsponding uniform
  73447. * @param texture The texture to bind the matrix for
  73448. * @param uniformBuffer The uniform buffer receivin the data
  73449. * @param key The channel key "diffuse", "specular"... used in the shader
  73450. */
  73451. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73452. /**
  73453. * Gets the current status of the fog (should it be enabled?)
  73454. * @param mesh defines the mesh to evaluate for fog support
  73455. * @param scene defines the hosting scene
  73456. * @returns true if fog must be enabled
  73457. */
  73458. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73459. /**
  73460. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73461. * @param mesh defines the current mesh
  73462. * @param scene defines the current scene
  73463. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73464. * @param pointsCloud defines if point cloud rendering has to be turned on
  73465. * @param fogEnabled defines if fog has to be turned on
  73466. * @param alphaTest defines if alpha testing has to be turned on
  73467. * @param defines defines the current list of defines
  73468. */
  73469. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73470. /**
  73471. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73472. * @param scene defines the current scene
  73473. * @param engine defines the current engine
  73474. * @param defines specifies the list of active defines
  73475. * @param useInstances defines if instances have to be turned on
  73476. * @param useClipPlane defines if clip plane have to be turned on
  73477. */
  73478. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73479. /**
  73480. * Prepares the defines for bones
  73481. * @param mesh The mesh containing the geometry data we will draw
  73482. * @param defines The defines to update
  73483. */
  73484. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73485. /**
  73486. * Prepares the defines for morph targets
  73487. * @param mesh The mesh containing the geometry data we will draw
  73488. * @param defines The defines to update
  73489. */
  73490. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73491. /**
  73492. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73493. * @param mesh The mesh containing the geometry data we will draw
  73494. * @param defines The defines to update
  73495. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73496. * @param useBones Precise whether bones should be used or not (override mesh info)
  73497. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73498. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73499. * @returns false if defines are considered not dirty and have not been checked
  73500. */
  73501. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73502. /**
  73503. * Prepares the defines related to multiview
  73504. * @param scene The scene we are intending to draw
  73505. * @param defines The defines to update
  73506. */
  73507. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73508. /**
  73509. * Prepares the defines related to the light information passed in parameter
  73510. * @param scene The scene we are intending to draw
  73511. * @param mesh The mesh the effect is compiling for
  73512. * @param light The light the effect is compiling for
  73513. * @param lightIndex The index of the light
  73514. * @param defines The defines to update
  73515. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73516. * @param state Defines the current state regarding what is needed (normals, etc...)
  73517. */
  73518. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73519. needNormals: boolean;
  73520. needRebuild: boolean;
  73521. shadowEnabled: boolean;
  73522. specularEnabled: boolean;
  73523. lightmapMode: boolean;
  73524. }): void;
  73525. /**
  73526. * Prepares the defines related to the light information passed in parameter
  73527. * @param scene The scene we are intending to draw
  73528. * @param mesh The mesh the effect is compiling for
  73529. * @param defines The defines to update
  73530. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73531. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73532. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73533. * @returns true if normals will be required for the rest of the effect
  73534. */
  73535. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73536. /**
  73537. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73538. * @param lightIndex defines the light index
  73539. * @param uniformsList The uniform list
  73540. * @param samplersList The sampler list
  73541. * @param projectedLightTexture defines if projected texture must be used
  73542. * @param uniformBuffersList defines an optional list of uniform buffers
  73543. */
  73544. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73545. /**
  73546. * Prepares the uniforms and samplers list to be used in the effect
  73547. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73548. * @param samplersList The sampler list
  73549. * @param defines The defines helping in the list generation
  73550. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73551. */
  73552. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73553. /**
  73554. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73555. * @param defines The defines to update while falling back
  73556. * @param fallbacks The authorized effect fallbacks
  73557. * @param maxSimultaneousLights The maximum number of lights allowed
  73558. * @param rank the current rank of the Effect
  73559. * @returns The newly affected rank
  73560. */
  73561. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73562. private static _TmpMorphInfluencers;
  73563. /**
  73564. * Prepares the list of attributes required for morph targets according to the effect defines.
  73565. * @param attribs The current list of supported attribs
  73566. * @param mesh The mesh to prepare the morph targets attributes for
  73567. * @param influencers The number of influencers
  73568. */
  73569. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73570. /**
  73571. * Prepares the list of attributes required for morph targets according to the effect defines.
  73572. * @param attribs The current list of supported attribs
  73573. * @param mesh The mesh to prepare the morph targets attributes for
  73574. * @param defines The current Defines of the effect
  73575. */
  73576. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73577. /**
  73578. * Prepares the list of attributes required for bones according to the effect defines.
  73579. * @param attribs The current list of supported attribs
  73580. * @param mesh The mesh to prepare the bones attributes for
  73581. * @param defines The current Defines of the effect
  73582. * @param fallbacks The current efffect fallback strategy
  73583. */
  73584. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73585. /**
  73586. * Check and prepare the list of attributes required for instances according to the effect defines.
  73587. * @param attribs The current list of supported attribs
  73588. * @param defines The current MaterialDefines of the effect
  73589. */
  73590. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73591. /**
  73592. * Add the list of attributes required for instances to the attribs array.
  73593. * @param attribs The current list of supported attribs
  73594. */
  73595. static PushAttributesForInstances(attribs: string[]): void;
  73596. /**
  73597. * Binds the light shadow information to the effect for the given mesh.
  73598. * @param light The light containing the generator
  73599. * @param scene The scene the lights belongs to
  73600. * @param mesh The mesh we are binding the information to render
  73601. * @param lightIndex The light index in the effect used to render the mesh
  73602. * @param effect The effect we are binding the data to
  73603. */
  73604. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73605. /**
  73606. * Binds the light information to the effect.
  73607. * @param light The light containing the generator
  73608. * @param effect The effect we are binding the data to
  73609. * @param lightIndex The light index in the effect used to render
  73610. */
  73611. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73612. /**
  73613. * Binds the lights information from the scene to the effect for the given mesh.
  73614. * @param light Light to bind
  73615. * @param lightIndex Light index
  73616. * @param scene The scene where the light belongs to
  73617. * @param mesh The mesh we are binding the information to render
  73618. * @param effect The effect we are binding the data to
  73619. * @param useSpecular Defines if specular is supported
  73620. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73621. */
  73622. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73623. /**
  73624. * Binds the lights information from the scene to the effect for the given mesh.
  73625. * @param scene The scene the lights belongs to
  73626. * @param mesh The mesh we are binding the information to render
  73627. * @param effect The effect we are binding the data to
  73628. * @param defines The generated defines for the effect
  73629. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73630. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73631. */
  73632. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73633. private static _tempFogColor;
  73634. /**
  73635. * Binds the fog information from the scene to the effect for the given mesh.
  73636. * @param scene The scene the lights belongs to
  73637. * @param mesh The mesh we are binding the information to render
  73638. * @param effect The effect we are binding the data to
  73639. * @param linearSpace Defines if the fog effect is applied in linear space
  73640. */
  73641. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73642. /**
  73643. * Binds the bones information from the mesh to the effect.
  73644. * @param mesh The mesh we are binding the information to render
  73645. * @param effect The effect we are binding the data to
  73646. */
  73647. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73648. /**
  73649. * Binds the morph targets information from the mesh to the effect.
  73650. * @param abstractMesh The mesh we are binding the information to render
  73651. * @param effect The effect we are binding the data to
  73652. */
  73653. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73654. /**
  73655. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73656. * @param defines The generated defines used in the effect
  73657. * @param effect The effect we are binding the data to
  73658. * @param scene The scene we are willing to render with logarithmic scale for
  73659. */
  73660. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73661. /**
  73662. * Binds the clip plane information from the scene to the effect.
  73663. * @param scene The scene the clip plane information are extracted from
  73664. * @param effect The effect we are binding the data to
  73665. */
  73666. static BindClipPlane(effect: Effect, scene: Scene): void;
  73667. }
  73668. }
  73669. declare module BABYLON {
  73670. /** @hidden */
  73671. export var packingFunctions: {
  73672. name: string;
  73673. shader: string;
  73674. };
  73675. }
  73676. declare module BABYLON {
  73677. /** @hidden */
  73678. export var shadowMapPixelShader: {
  73679. name: string;
  73680. shader: string;
  73681. };
  73682. }
  73683. declare module BABYLON {
  73684. /** @hidden */
  73685. export var bonesDeclaration: {
  73686. name: string;
  73687. shader: string;
  73688. };
  73689. }
  73690. declare module BABYLON {
  73691. /** @hidden */
  73692. export var morphTargetsVertexGlobalDeclaration: {
  73693. name: string;
  73694. shader: string;
  73695. };
  73696. }
  73697. declare module BABYLON {
  73698. /** @hidden */
  73699. export var morphTargetsVertexDeclaration: {
  73700. name: string;
  73701. shader: string;
  73702. };
  73703. }
  73704. declare module BABYLON {
  73705. /** @hidden */
  73706. export var instancesDeclaration: {
  73707. name: string;
  73708. shader: string;
  73709. };
  73710. }
  73711. declare module BABYLON {
  73712. /** @hidden */
  73713. export var helperFunctions: {
  73714. name: string;
  73715. shader: string;
  73716. };
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export var morphTargetsVertex: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module BABYLON {
  73726. /** @hidden */
  73727. export var instancesVertex: {
  73728. name: string;
  73729. shader: string;
  73730. };
  73731. }
  73732. declare module BABYLON {
  73733. /** @hidden */
  73734. export var bonesVertex: {
  73735. name: string;
  73736. shader: string;
  73737. };
  73738. }
  73739. declare module BABYLON {
  73740. /** @hidden */
  73741. export var shadowMapVertexShader: {
  73742. name: string;
  73743. shader: string;
  73744. };
  73745. }
  73746. declare module BABYLON {
  73747. /** @hidden */
  73748. export var depthBoxBlurPixelShader: {
  73749. name: string;
  73750. shader: string;
  73751. };
  73752. }
  73753. declare module BABYLON {
  73754. /**
  73755. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73756. */
  73757. export interface ICustomShaderOptions {
  73758. /**
  73759. * Gets or sets the custom shader name to use
  73760. */
  73761. shaderName: string;
  73762. /**
  73763. * The list of attribute names used in the shader
  73764. */
  73765. attributes?: string[];
  73766. /**
  73767. * The list of unifrom names used in the shader
  73768. */
  73769. uniforms?: string[];
  73770. /**
  73771. * The list of sampler names used in the shader
  73772. */
  73773. samplers?: string[];
  73774. /**
  73775. * The list of defines used in the shader
  73776. */
  73777. defines?: string[];
  73778. }
  73779. /**
  73780. * Interface to implement to create a shadow generator compatible with BJS.
  73781. */
  73782. export interface IShadowGenerator {
  73783. /**
  73784. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73785. * @returns The render target texture if present otherwise, null
  73786. */
  73787. getShadowMap(): Nullable<RenderTargetTexture>;
  73788. /**
  73789. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73790. * @returns The render target texture if the shadow map is present otherwise, null
  73791. */
  73792. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73793. /**
  73794. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73795. * @param subMesh The submesh we want to render in the shadow map
  73796. * @param useInstances Defines wether will draw in the map using instances
  73797. * @returns true if ready otherwise, false
  73798. */
  73799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73800. /**
  73801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73802. * @param defines Defines of the material we want to update
  73803. * @param lightIndex Index of the light in the enabled light list of the material
  73804. */
  73805. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73806. /**
  73807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73808. * defined in the generator but impacting the effect).
  73809. * It implies the unifroms available on the materials are the standard BJS ones.
  73810. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73811. * @param effect The effect we are binfing the information for
  73812. */
  73813. bindShadowLight(lightIndex: string, effect: Effect): void;
  73814. /**
  73815. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73816. * (eq to shadow prjection matrix * light transform matrix)
  73817. * @returns The transform matrix used to create the shadow map
  73818. */
  73819. getTransformMatrix(): Matrix;
  73820. /**
  73821. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73822. * Cube and 2D textures for instance.
  73823. */
  73824. recreateShadowMap(): void;
  73825. /**
  73826. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73827. * @param onCompiled Callback triggered at the and of the effects compilation
  73828. * @param options Sets of optional options forcing the compilation with different modes
  73829. */
  73830. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73831. useInstances: boolean;
  73832. }>): void;
  73833. /**
  73834. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73835. * @param options Sets of optional options forcing the compilation with different modes
  73836. * @returns A promise that resolves when the compilation completes
  73837. */
  73838. forceCompilationAsync(options?: Partial<{
  73839. useInstances: boolean;
  73840. }>): Promise<void>;
  73841. /**
  73842. * Serializes the shadow generator setup to a json object.
  73843. * @returns The serialized JSON object
  73844. */
  73845. serialize(): any;
  73846. /**
  73847. * Disposes the Shadow map and related Textures and effects.
  73848. */
  73849. dispose(): void;
  73850. }
  73851. /**
  73852. * Default implementation IShadowGenerator.
  73853. * This is the main object responsible of generating shadows in the framework.
  73854. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73855. */
  73856. export class ShadowGenerator implements IShadowGenerator {
  73857. /**
  73858. * Shadow generator mode None: no filtering applied.
  73859. */
  73860. static readonly FILTER_NONE: number;
  73861. /**
  73862. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73863. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73864. */
  73865. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73866. /**
  73867. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73868. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73869. */
  73870. static readonly FILTER_POISSONSAMPLING: number;
  73871. /**
  73872. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73873. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73874. */
  73875. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73876. /**
  73877. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73878. * edge artifacts on steep falloff.
  73879. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73880. */
  73881. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73882. /**
  73883. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73884. * edge artifacts on steep falloff.
  73885. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73886. */
  73887. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73888. /**
  73889. * Shadow generator mode PCF: Percentage Closer Filtering
  73890. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73891. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73892. */
  73893. static readonly FILTER_PCF: number;
  73894. /**
  73895. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73896. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73897. * Contact Hardening
  73898. */
  73899. static readonly FILTER_PCSS: number;
  73900. /**
  73901. * Reserved for PCF and PCSS
  73902. * Highest Quality.
  73903. *
  73904. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73905. *
  73906. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73907. */
  73908. static readonly QUALITY_HIGH: number;
  73909. /**
  73910. * Reserved for PCF and PCSS
  73911. * Good tradeoff for quality/perf cross devices
  73912. *
  73913. * Execute PCF on a 3*3 kernel.
  73914. *
  73915. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73916. */
  73917. static readonly QUALITY_MEDIUM: number;
  73918. /**
  73919. * Reserved for PCF and PCSS
  73920. * The lowest quality but the fastest.
  73921. *
  73922. * Execute PCF on a 1*1 kernel.
  73923. *
  73924. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73925. */
  73926. static readonly QUALITY_LOW: number;
  73927. /** Gets or sets the custom shader name to use */
  73928. customShaderOptions: ICustomShaderOptions;
  73929. /**
  73930. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73931. */
  73932. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73933. /**
  73934. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73935. */
  73936. onAfterShadowMapRenderObservable: Observable<Effect>;
  73937. /**
  73938. * Observable triggered before a mesh is rendered in the shadow map.
  73939. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73940. */
  73941. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73942. /**
  73943. * Observable triggered after a mesh is rendered in the shadow map.
  73944. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73945. */
  73946. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73947. private _bias;
  73948. /**
  73949. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73950. */
  73951. /**
  73952. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73953. */
  73954. bias: number;
  73955. private _normalBias;
  73956. /**
  73957. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73958. */
  73959. /**
  73960. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73961. */
  73962. normalBias: number;
  73963. private _blurBoxOffset;
  73964. /**
  73965. * Gets the blur box offset: offset applied during the blur pass.
  73966. * Only useful if useKernelBlur = false
  73967. */
  73968. /**
  73969. * Sets the blur box offset: offset applied during the blur pass.
  73970. * Only useful if useKernelBlur = false
  73971. */
  73972. blurBoxOffset: number;
  73973. private _blurScale;
  73974. /**
  73975. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73976. * 2 means half of the size.
  73977. */
  73978. /**
  73979. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73980. * 2 means half of the size.
  73981. */
  73982. blurScale: number;
  73983. private _blurKernel;
  73984. /**
  73985. * Gets the blur kernel: kernel size of the blur pass.
  73986. * Only useful if useKernelBlur = true
  73987. */
  73988. /**
  73989. * Sets the blur kernel: kernel size of the blur pass.
  73990. * Only useful if useKernelBlur = true
  73991. */
  73992. blurKernel: number;
  73993. private _useKernelBlur;
  73994. /**
  73995. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73996. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73997. */
  73998. /**
  73999. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74000. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74001. */
  74002. useKernelBlur: boolean;
  74003. private _depthScale;
  74004. /**
  74005. * Gets the depth scale used in ESM mode.
  74006. */
  74007. /**
  74008. * Sets the depth scale used in ESM mode.
  74009. * This can override the scale stored on the light.
  74010. */
  74011. depthScale: number;
  74012. private _filter;
  74013. /**
  74014. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74015. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74016. */
  74017. /**
  74018. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74019. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74020. */
  74021. filter: number;
  74022. /**
  74023. * Gets if the current filter is set to Poisson Sampling.
  74024. */
  74025. /**
  74026. * Sets the current filter to Poisson Sampling.
  74027. */
  74028. usePoissonSampling: boolean;
  74029. /**
  74030. * Gets if the current filter is set to ESM.
  74031. */
  74032. /**
  74033. * Sets the current filter is to ESM.
  74034. */
  74035. useExponentialShadowMap: boolean;
  74036. /**
  74037. * Gets if the current filter is set to filtered ESM.
  74038. */
  74039. /**
  74040. * Gets if the current filter is set to filtered ESM.
  74041. */
  74042. useBlurExponentialShadowMap: boolean;
  74043. /**
  74044. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74045. * exponential to prevent steep falloff artifacts).
  74046. */
  74047. /**
  74048. * Sets the current filter to "close ESM" (using the inverse of the
  74049. * exponential to prevent steep falloff artifacts).
  74050. */
  74051. useCloseExponentialShadowMap: boolean;
  74052. /**
  74053. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74054. * exponential to prevent steep falloff artifacts).
  74055. */
  74056. /**
  74057. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74058. * exponential to prevent steep falloff artifacts).
  74059. */
  74060. useBlurCloseExponentialShadowMap: boolean;
  74061. /**
  74062. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74063. */
  74064. /**
  74065. * Sets the current filter to "PCF" (percentage closer filtering).
  74066. */
  74067. usePercentageCloserFiltering: boolean;
  74068. private _filteringQuality;
  74069. /**
  74070. * Gets the PCF or PCSS Quality.
  74071. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74072. */
  74073. /**
  74074. * Sets the PCF or PCSS Quality.
  74075. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74076. */
  74077. filteringQuality: number;
  74078. /**
  74079. * Gets if the current filter is set to "PCSS" (contact hardening).
  74080. */
  74081. /**
  74082. * Sets the current filter to "PCSS" (contact hardening).
  74083. */
  74084. useContactHardeningShadow: boolean;
  74085. private _contactHardeningLightSizeUVRatio;
  74086. /**
  74087. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74088. * Using a ratio helps keeping shape stability independently of the map size.
  74089. *
  74090. * It does not account for the light projection as it was having too much
  74091. * instability during the light setup or during light position changes.
  74092. *
  74093. * Only valid if useContactHardeningShadow is true.
  74094. */
  74095. /**
  74096. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74097. * Using a ratio helps keeping shape stability independently of the map size.
  74098. *
  74099. * It does not account for the light projection as it was having too much
  74100. * instability during the light setup or during light position changes.
  74101. *
  74102. * Only valid if useContactHardeningShadow is true.
  74103. */
  74104. contactHardeningLightSizeUVRatio: number;
  74105. private _darkness;
  74106. /** Gets or sets the actual darkness of a shadow */
  74107. darkness: number;
  74108. /**
  74109. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74110. * 0 means strongest and 1 would means no shadow.
  74111. * @returns the darkness.
  74112. */
  74113. getDarkness(): number;
  74114. /**
  74115. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74116. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74117. * @returns the shadow generator allowing fluent coding.
  74118. */
  74119. setDarkness(darkness: number): ShadowGenerator;
  74120. private _transparencyShadow;
  74121. /** Gets or sets the ability to have transparent shadow */
  74122. transparencyShadow: boolean;
  74123. /**
  74124. * Sets the ability to have transparent shadow (boolean).
  74125. * @param transparent True if transparent else False
  74126. * @returns the shadow generator allowing fluent coding
  74127. */
  74128. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74129. private _shadowMap;
  74130. private _shadowMap2;
  74131. /**
  74132. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74133. * @returns The render target texture if present otherwise, null
  74134. */
  74135. getShadowMap(): Nullable<RenderTargetTexture>;
  74136. /**
  74137. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74138. * @returns The render target texture if the shadow map is present otherwise, null
  74139. */
  74140. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74141. /**
  74142. * Gets the class name of that object
  74143. * @returns "ShadowGenerator"
  74144. */
  74145. getClassName(): string;
  74146. /**
  74147. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74148. * @param mesh Mesh to add
  74149. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74150. * @returns the Shadow Generator itself
  74151. */
  74152. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74153. /**
  74154. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74155. * @param mesh Mesh to remove
  74156. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74157. * @returns the Shadow Generator itself
  74158. */
  74159. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74160. /**
  74161. * Controls the extent to which the shadows fade out at the edge of the frustum
  74162. * Used only by directionals and spots
  74163. */
  74164. frustumEdgeFalloff: number;
  74165. private _light;
  74166. /**
  74167. * Returns the associated light object.
  74168. * @returns the light generating the shadow
  74169. */
  74170. getLight(): IShadowLight;
  74171. /**
  74172. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74173. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74174. * It might on the other hand introduce peter panning.
  74175. */
  74176. forceBackFacesOnly: boolean;
  74177. private _scene;
  74178. private _lightDirection;
  74179. private _effect;
  74180. private _viewMatrix;
  74181. private _projectionMatrix;
  74182. private _transformMatrix;
  74183. private _cachedPosition;
  74184. private _cachedDirection;
  74185. private _cachedDefines;
  74186. private _currentRenderID;
  74187. private _boxBlurPostprocess;
  74188. private _kernelBlurXPostprocess;
  74189. private _kernelBlurYPostprocess;
  74190. private _blurPostProcesses;
  74191. private _mapSize;
  74192. private _currentFaceIndex;
  74193. private _currentFaceIndexCache;
  74194. private _textureType;
  74195. private _defaultTextureMatrix;
  74196. /** @hidden */
  74197. static _SceneComponentInitialization: (scene: Scene) => void;
  74198. /**
  74199. * Creates a ShadowGenerator object.
  74200. * A ShadowGenerator is the required tool to use the shadows.
  74201. * Each light casting shadows needs to use its own ShadowGenerator.
  74202. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74203. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74204. * @param light The light object generating the shadows.
  74205. * @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.
  74206. */
  74207. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74208. private _initializeGenerator;
  74209. private _initializeShadowMap;
  74210. private _initializeBlurRTTAndPostProcesses;
  74211. private _renderForShadowMap;
  74212. private _renderSubMeshForShadowMap;
  74213. private _applyFilterValues;
  74214. /**
  74215. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74216. * @param onCompiled Callback triggered at the and of the effects compilation
  74217. * @param options Sets of optional options forcing the compilation with different modes
  74218. */
  74219. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74220. useInstances: boolean;
  74221. }>): void;
  74222. /**
  74223. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74224. * @param options Sets of optional options forcing the compilation with different modes
  74225. * @returns A promise that resolves when the compilation completes
  74226. */
  74227. forceCompilationAsync(options?: Partial<{
  74228. useInstances: boolean;
  74229. }>): Promise<void>;
  74230. /**
  74231. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74232. * @param subMesh The submesh we want to render in the shadow map
  74233. * @param useInstances Defines wether will draw in the map using instances
  74234. * @returns true if ready otherwise, false
  74235. */
  74236. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74237. /**
  74238. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74239. * @param defines Defines of the material we want to update
  74240. * @param lightIndex Index of the light in the enabled light list of the material
  74241. */
  74242. prepareDefines(defines: any, lightIndex: number): void;
  74243. /**
  74244. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74245. * defined in the generator but impacting the effect).
  74246. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74247. * @param effect The effect we are binfing the information for
  74248. */
  74249. bindShadowLight(lightIndex: string, effect: Effect): void;
  74250. /**
  74251. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74252. * (eq to shadow prjection matrix * light transform matrix)
  74253. * @returns The transform matrix used to create the shadow map
  74254. */
  74255. getTransformMatrix(): Matrix;
  74256. /**
  74257. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74258. * Cube and 2D textures for instance.
  74259. */
  74260. recreateShadowMap(): void;
  74261. private _disposeBlurPostProcesses;
  74262. private _disposeRTTandPostProcesses;
  74263. /**
  74264. * Disposes the ShadowGenerator.
  74265. * Returns nothing.
  74266. */
  74267. dispose(): void;
  74268. /**
  74269. * Serializes the shadow generator setup to a json object.
  74270. * @returns The serialized JSON object
  74271. */
  74272. serialize(): any;
  74273. /**
  74274. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74275. * @param parsedShadowGenerator The JSON object to parse
  74276. * @param scene The scene to create the shadow map for
  74277. * @returns The parsed shadow generator
  74278. */
  74279. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74280. }
  74281. }
  74282. declare module BABYLON {
  74283. /**
  74284. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74285. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74286. * 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.
  74287. */
  74288. export abstract class Light extends Node {
  74289. /**
  74290. * Falloff Default: light is falling off following the material specification:
  74291. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74292. */
  74293. static readonly FALLOFF_DEFAULT: number;
  74294. /**
  74295. * Falloff Physical: light is falling off following the inverse squared distance law.
  74296. */
  74297. static readonly FALLOFF_PHYSICAL: number;
  74298. /**
  74299. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74300. * to enhance interoperability with other engines.
  74301. */
  74302. static readonly FALLOFF_GLTF: number;
  74303. /**
  74304. * Falloff Standard: light is falling off like in the standard material
  74305. * to enhance interoperability with other materials.
  74306. */
  74307. static readonly FALLOFF_STANDARD: number;
  74308. /**
  74309. * If every light affecting the material is in this lightmapMode,
  74310. * material.lightmapTexture adds or multiplies
  74311. * (depends on material.useLightmapAsShadowmap)
  74312. * after every other light calculations.
  74313. */
  74314. static readonly LIGHTMAP_DEFAULT: number;
  74315. /**
  74316. * material.lightmapTexture as only diffuse lighting from this light
  74317. * adds only specular lighting from this light
  74318. * adds dynamic shadows
  74319. */
  74320. static readonly LIGHTMAP_SPECULAR: number;
  74321. /**
  74322. * material.lightmapTexture as only lighting
  74323. * no light calculation from this light
  74324. * only adds dynamic shadows from this light
  74325. */
  74326. static readonly LIGHTMAP_SHADOWSONLY: number;
  74327. /**
  74328. * Each light type uses the default quantity according to its type:
  74329. * point/spot lights use luminous intensity
  74330. * directional lights use illuminance
  74331. */
  74332. static readonly INTENSITYMODE_AUTOMATIC: number;
  74333. /**
  74334. * lumen (lm)
  74335. */
  74336. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74337. /**
  74338. * candela (lm/sr)
  74339. */
  74340. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74341. /**
  74342. * lux (lm/m^2)
  74343. */
  74344. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74345. /**
  74346. * nit (cd/m^2)
  74347. */
  74348. static readonly INTENSITYMODE_LUMINANCE: number;
  74349. /**
  74350. * Light type const id of the point light.
  74351. */
  74352. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74353. /**
  74354. * Light type const id of the directional light.
  74355. */
  74356. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74357. /**
  74358. * Light type const id of the spot light.
  74359. */
  74360. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74361. /**
  74362. * Light type const id of the hemispheric light.
  74363. */
  74364. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74365. /**
  74366. * Diffuse gives the basic color to an object.
  74367. */
  74368. diffuse: Color3;
  74369. /**
  74370. * Specular produces a highlight color on an object.
  74371. * Note: This is note affecting PBR materials.
  74372. */
  74373. specular: Color3;
  74374. /**
  74375. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74376. * falling off base on range or angle.
  74377. * This can be set to any values in Light.FALLOFF_x.
  74378. *
  74379. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74380. * other types of materials.
  74381. */
  74382. falloffType: number;
  74383. /**
  74384. * Strength of the light.
  74385. * Note: By default it is define in the framework own unit.
  74386. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74387. */
  74388. intensity: number;
  74389. private _range;
  74390. protected _inverseSquaredRange: number;
  74391. /**
  74392. * Defines how far from the source the light is impacting in scene units.
  74393. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74394. */
  74395. /**
  74396. * Defines how far from the source the light is impacting in scene units.
  74397. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74398. */
  74399. range: number;
  74400. /**
  74401. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74402. * of light.
  74403. */
  74404. private _photometricScale;
  74405. private _intensityMode;
  74406. /**
  74407. * Gets the photometric scale used to interpret the intensity.
  74408. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74409. */
  74410. /**
  74411. * Sets the photometric scale used to interpret the intensity.
  74412. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74413. */
  74414. intensityMode: number;
  74415. private _radius;
  74416. /**
  74417. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74418. */
  74419. /**
  74420. * sets the light radius used by PBR Materials to simulate soft area lights.
  74421. */
  74422. radius: number;
  74423. private _renderPriority;
  74424. /**
  74425. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74426. * exceeding the number allowed of the materials.
  74427. */
  74428. renderPriority: number;
  74429. private _shadowEnabled;
  74430. /**
  74431. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74432. * the current shadow generator.
  74433. */
  74434. /**
  74435. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74436. * the current shadow generator.
  74437. */
  74438. shadowEnabled: boolean;
  74439. private _includedOnlyMeshes;
  74440. /**
  74441. * Gets the only meshes impacted by this light.
  74442. */
  74443. /**
  74444. * Sets the only meshes impacted by this light.
  74445. */
  74446. includedOnlyMeshes: AbstractMesh[];
  74447. private _excludedMeshes;
  74448. /**
  74449. * Gets the meshes not impacted by this light.
  74450. */
  74451. /**
  74452. * Sets the meshes not impacted by this light.
  74453. */
  74454. excludedMeshes: AbstractMesh[];
  74455. private _excludeWithLayerMask;
  74456. /**
  74457. * Gets the layer id use to find what meshes are not impacted by the light.
  74458. * Inactive if 0
  74459. */
  74460. /**
  74461. * Sets the layer id use to find what meshes are not impacted by the light.
  74462. * Inactive if 0
  74463. */
  74464. excludeWithLayerMask: number;
  74465. private _includeOnlyWithLayerMask;
  74466. /**
  74467. * Gets the layer id use to find what meshes are impacted by the light.
  74468. * Inactive if 0
  74469. */
  74470. /**
  74471. * Sets the layer id use to find what meshes are impacted by the light.
  74472. * Inactive if 0
  74473. */
  74474. includeOnlyWithLayerMask: number;
  74475. private _lightmapMode;
  74476. /**
  74477. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74478. */
  74479. /**
  74480. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74481. */
  74482. lightmapMode: number;
  74483. /**
  74484. * Shadow generator associted to the light.
  74485. * @hidden Internal use only.
  74486. */
  74487. _shadowGenerator: Nullable<IShadowGenerator>;
  74488. /**
  74489. * @hidden Internal use only.
  74490. */
  74491. _excludedMeshesIds: string[];
  74492. /**
  74493. * @hidden Internal use only.
  74494. */
  74495. _includedOnlyMeshesIds: string[];
  74496. /**
  74497. * The current light unifom buffer.
  74498. * @hidden Internal use only.
  74499. */
  74500. _uniformBuffer: UniformBuffer;
  74501. /**
  74502. * Creates a Light object in the scene.
  74503. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74504. * @param name The firendly name of the light
  74505. * @param scene The scene the light belongs too
  74506. */
  74507. constructor(name: string, scene: Scene);
  74508. protected abstract _buildUniformLayout(): void;
  74509. /**
  74510. * Sets the passed Effect "effect" with the Light information.
  74511. * @param effect The effect to update
  74512. * @param lightIndex The index of the light in the effect to update
  74513. * @returns The light
  74514. */
  74515. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74516. /**
  74517. * Returns the string "Light".
  74518. * @returns the class name
  74519. */
  74520. getClassName(): string;
  74521. /** @hidden */
  74522. readonly _isLight: boolean;
  74523. /**
  74524. * Converts the light information to a readable string for debug purpose.
  74525. * @param fullDetails Supports for multiple levels of logging within scene loading
  74526. * @returns the human readable light info
  74527. */
  74528. toString(fullDetails?: boolean): string;
  74529. /** @hidden */
  74530. protected _syncParentEnabledState(): void;
  74531. /**
  74532. * Set the enabled state of this node.
  74533. * @param value - the new enabled state
  74534. */
  74535. setEnabled(value: boolean): void;
  74536. /**
  74537. * Returns the Light associated shadow generator if any.
  74538. * @return the associated shadow generator.
  74539. */
  74540. getShadowGenerator(): Nullable<IShadowGenerator>;
  74541. /**
  74542. * Returns a Vector3, the absolute light position in the World.
  74543. * @returns the world space position of the light
  74544. */
  74545. getAbsolutePosition(): Vector3;
  74546. /**
  74547. * Specifies if the light will affect the passed mesh.
  74548. * @param mesh The mesh to test against the light
  74549. * @return true the mesh is affected otherwise, false.
  74550. */
  74551. canAffectMesh(mesh: AbstractMesh): boolean;
  74552. /**
  74553. * Sort function to order lights for rendering.
  74554. * @param a First Light object to compare to second.
  74555. * @param b Second Light object to compare first.
  74556. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74557. */
  74558. static CompareLightsPriority(a: Light, b: Light): number;
  74559. /**
  74560. * Releases resources associated with this node.
  74561. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74562. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74563. */
  74564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74565. /**
  74566. * Returns the light type ID (integer).
  74567. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74568. */
  74569. getTypeID(): number;
  74570. /**
  74571. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74572. * @returns the scaled intensity in intensity mode unit
  74573. */
  74574. getScaledIntensity(): number;
  74575. /**
  74576. * Returns a new Light object, named "name", from the current one.
  74577. * @param name The name of the cloned light
  74578. * @returns the new created light
  74579. */
  74580. clone(name: string): Nullable<Light>;
  74581. /**
  74582. * Serializes the current light into a Serialization object.
  74583. * @returns the serialized object.
  74584. */
  74585. serialize(): any;
  74586. /**
  74587. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74588. * This new light is named "name" and added to the passed scene.
  74589. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74590. * @param name The friendly name of the light
  74591. * @param scene The scene the new light will belong to
  74592. * @returns the constructor function
  74593. */
  74594. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74595. /**
  74596. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74597. * @param parsedLight The JSON representation of the light
  74598. * @param scene The scene to create the parsed light in
  74599. * @returns the created light after parsing
  74600. */
  74601. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74602. private _hookArrayForExcluded;
  74603. private _hookArrayForIncludedOnly;
  74604. private _resyncMeshes;
  74605. /**
  74606. * Forces the meshes to update their light related information in their rendering used effects
  74607. * @hidden Internal Use Only
  74608. */
  74609. _markMeshesAsLightDirty(): void;
  74610. /**
  74611. * Recomputes the cached photometric scale if needed.
  74612. */
  74613. private _computePhotometricScale;
  74614. /**
  74615. * Returns the Photometric Scale according to the light type and intensity mode.
  74616. */
  74617. private _getPhotometricScale;
  74618. /**
  74619. * Reorder the light in the scene according to their defined priority.
  74620. * @hidden Internal Use Only
  74621. */
  74622. _reorderLightsInScene(): void;
  74623. /**
  74624. * Prepares the list of defines specific to the light type.
  74625. * @param defines the list of defines
  74626. * @param lightIndex defines the index of the light for the effect
  74627. */
  74628. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74629. }
  74630. }
  74631. declare module BABYLON {
  74632. /**
  74633. * Interface used to define Action
  74634. */
  74635. export interface IAction {
  74636. /**
  74637. * Trigger for the action
  74638. */
  74639. trigger: number;
  74640. /** Options of the trigger */
  74641. triggerOptions: any;
  74642. /**
  74643. * Gets the trigger parameters
  74644. * @returns the trigger parameters
  74645. */
  74646. getTriggerParameter(): any;
  74647. /**
  74648. * Internal only - executes current action event
  74649. * @hidden
  74650. */
  74651. _executeCurrent(evt?: ActionEvent): void;
  74652. /**
  74653. * Serialize placeholder for child classes
  74654. * @param parent of child
  74655. * @returns the serialized object
  74656. */
  74657. serialize(parent: any): any;
  74658. /**
  74659. * Internal only
  74660. * @hidden
  74661. */
  74662. _prepare(): void;
  74663. /**
  74664. * Internal only - manager for action
  74665. * @hidden
  74666. */
  74667. _actionManager: AbstractActionManager;
  74668. /**
  74669. * Adds action to chain of actions, may be a DoNothingAction
  74670. * @param action defines the next action to execute
  74671. * @returns The action passed in
  74672. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74673. */
  74674. then(action: IAction): IAction;
  74675. }
  74676. /**
  74677. * The action to be carried out following a trigger
  74678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74679. */
  74680. export class Action implements IAction {
  74681. /** the trigger, with or without parameters, for the action */
  74682. triggerOptions: any;
  74683. /**
  74684. * Trigger for the action
  74685. */
  74686. trigger: number;
  74687. /**
  74688. * Internal only - manager for action
  74689. * @hidden
  74690. */
  74691. _actionManager: ActionManager;
  74692. private _nextActiveAction;
  74693. private _child;
  74694. private _condition?;
  74695. private _triggerParameter;
  74696. /**
  74697. * An event triggered prior to action being executed.
  74698. */
  74699. onBeforeExecuteObservable: Observable<Action>;
  74700. /**
  74701. * Creates a new Action
  74702. * @param triggerOptions the trigger, with or without parameters, for the action
  74703. * @param condition an optional determinant of action
  74704. */
  74705. constructor(
  74706. /** the trigger, with or without parameters, for the action */
  74707. triggerOptions: any, condition?: Condition);
  74708. /**
  74709. * Internal only
  74710. * @hidden
  74711. */
  74712. _prepare(): void;
  74713. /**
  74714. * Gets the trigger parameters
  74715. * @returns the trigger parameters
  74716. */
  74717. getTriggerParameter(): any;
  74718. /**
  74719. * Internal only - executes current action event
  74720. * @hidden
  74721. */
  74722. _executeCurrent(evt?: ActionEvent): void;
  74723. /**
  74724. * Execute placeholder for child classes
  74725. * @param evt optional action event
  74726. */
  74727. execute(evt?: ActionEvent): void;
  74728. /**
  74729. * Skips to next active action
  74730. */
  74731. skipToNextActiveAction(): void;
  74732. /**
  74733. * Adds action to chain of actions, may be a DoNothingAction
  74734. * @param action defines the next action to execute
  74735. * @returns The action passed in
  74736. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74737. */
  74738. then(action: Action): Action;
  74739. /**
  74740. * Internal only
  74741. * @hidden
  74742. */
  74743. _getProperty(propertyPath: string): string;
  74744. /**
  74745. * Internal only
  74746. * @hidden
  74747. */
  74748. _getEffectiveTarget(target: any, propertyPath: string): any;
  74749. /**
  74750. * Serialize placeholder for child classes
  74751. * @param parent of child
  74752. * @returns the serialized object
  74753. */
  74754. serialize(parent: any): any;
  74755. /**
  74756. * Internal only called by serialize
  74757. * @hidden
  74758. */
  74759. protected _serialize(serializedAction: any, parent?: any): any;
  74760. /**
  74761. * Internal only
  74762. * @hidden
  74763. */
  74764. static _SerializeValueAsString: (value: any) => string;
  74765. /**
  74766. * Internal only
  74767. * @hidden
  74768. */
  74769. static _GetTargetProperty: (target: Node | Scene) => {
  74770. name: string;
  74771. targetType: string;
  74772. value: string;
  74773. };
  74774. }
  74775. }
  74776. declare module BABYLON {
  74777. /**
  74778. * A Condition applied to an Action
  74779. */
  74780. export class Condition {
  74781. /**
  74782. * Internal only - manager for action
  74783. * @hidden
  74784. */
  74785. _actionManager: ActionManager;
  74786. /**
  74787. * Internal only
  74788. * @hidden
  74789. */
  74790. _evaluationId: number;
  74791. /**
  74792. * Internal only
  74793. * @hidden
  74794. */
  74795. _currentResult: boolean;
  74796. /**
  74797. * Creates a new Condition
  74798. * @param actionManager the manager of the action the condition is applied to
  74799. */
  74800. constructor(actionManager: ActionManager);
  74801. /**
  74802. * Check if the current condition is valid
  74803. * @returns a boolean
  74804. */
  74805. isValid(): boolean;
  74806. /**
  74807. * Internal only
  74808. * @hidden
  74809. */
  74810. _getProperty(propertyPath: string): string;
  74811. /**
  74812. * Internal only
  74813. * @hidden
  74814. */
  74815. _getEffectiveTarget(target: any, propertyPath: string): any;
  74816. /**
  74817. * Serialize placeholder for child classes
  74818. * @returns the serialized object
  74819. */
  74820. serialize(): any;
  74821. /**
  74822. * Internal only
  74823. * @hidden
  74824. */
  74825. protected _serialize(serializedCondition: any): any;
  74826. }
  74827. /**
  74828. * Defines specific conditional operators as extensions of Condition
  74829. */
  74830. export class ValueCondition extends Condition {
  74831. /** path to specify the property of the target the conditional operator uses */
  74832. propertyPath: string;
  74833. /** the value compared by the conditional operator against the current value of the property */
  74834. value: any;
  74835. /** the conditional operator, default ValueCondition.IsEqual */
  74836. operator: number;
  74837. /**
  74838. * Internal only
  74839. * @hidden
  74840. */
  74841. private static _IsEqual;
  74842. /**
  74843. * Internal only
  74844. * @hidden
  74845. */
  74846. private static _IsDifferent;
  74847. /**
  74848. * Internal only
  74849. * @hidden
  74850. */
  74851. private static _IsGreater;
  74852. /**
  74853. * Internal only
  74854. * @hidden
  74855. */
  74856. private static _IsLesser;
  74857. /**
  74858. * returns the number for IsEqual
  74859. */
  74860. static readonly IsEqual: number;
  74861. /**
  74862. * Returns the number for IsDifferent
  74863. */
  74864. static readonly IsDifferent: number;
  74865. /**
  74866. * Returns the number for IsGreater
  74867. */
  74868. static readonly IsGreater: number;
  74869. /**
  74870. * Returns the number for IsLesser
  74871. */
  74872. static readonly IsLesser: number;
  74873. /**
  74874. * Internal only The action manager for the condition
  74875. * @hidden
  74876. */
  74877. _actionManager: ActionManager;
  74878. /**
  74879. * Internal only
  74880. * @hidden
  74881. */
  74882. private _target;
  74883. /**
  74884. * Internal only
  74885. * @hidden
  74886. */
  74887. private _effectiveTarget;
  74888. /**
  74889. * Internal only
  74890. * @hidden
  74891. */
  74892. private _property;
  74893. /**
  74894. * Creates a new ValueCondition
  74895. * @param actionManager manager for the action the condition applies to
  74896. * @param target for the action
  74897. * @param propertyPath path to specify the property of the target the conditional operator uses
  74898. * @param value the value compared by the conditional operator against the current value of the property
  74899. * @param operator the conditional operator, default ValueCondition.IsEqual
  74900. */
  74901. constructor(actionManager: ActionManager, target: any,
  74902. /** path to specify the property of the target the conditional operator uses */
  74903. propertyPath: string,
  74904. /** the value compared by the conditional operator against the current value of the property */
  74905. value: any,
  74906. /** the conditional operator, default ValueCondition.IsEqual */
  74907. operator?: number);
  74908. /**
  74909. * Compares the given value with the property value for the specified conditional operator
  74910. * @returns the result of the comparison
  74911. */
  74912. isValid(): boolean;
  74913. /**
  74914. * Serialize the ValueCondition into a JSON compatible object
  74915. * @returns serialization object
  74916. */
  74917. serialize(): any;
  74918. /**
  74919. * Gets the name of the conditional operator for the ValueCondition
  74920. * @param operator the conditional operator
  74921. * @returns the name
  74922. */
  74923. static GetOperatorName(operator: number): string;
  74924. }
  74925. /**
  74926. * Defines a predicate condition as an extension of Condition
  74927. */
  74928. export class PredicateCondition extends Condition {
  74929. /** defines the predicate function used to validate the condition */
  74930. predicate: () => boolean;
  74931. /**
  74932. * Internal only - manager for action
  74933. * @hidden
  74934. */
  74935. _actionManager: ActionManager;
  74936. /**
  74937. * Creates a new PredicateCondition
  74938. * @param actionManager manager for the action the condition applies to
  74939. * @param predicate defines the predicate function used to validate the condition
  74940. */
  74941. constructor(actionManager: ActionManager,
  74942. /** defines the predicate function used to validate the condition */
  74943. predicate: () => boolean);
  74944. /**
  74945. * @returns the validity of the predicate condition
  74946. */
  74947. isValid(): boolean;
  74948. }
  74949. /**
  74950. * Defines a state condition as an extension of Condition
  74951. */
  74952. export class StateCondition extends Condition {
  74953. /** Value to compare with target state */
  74954. value: string;
  74955. /**
  74956. * Internal only - manager for action
  74957. * @hidden
  74958. */
  74959. _actionManager: ActionManager;
  74960. /**
  74961. * Internal only
  74962. * @hidden
  74963. */
  74964. private _target;
  74965. /**
  74966. * Creates a new StateCondition
  74967. * @param actionManager manager for the action the condition applies to
  74968. * @param target of the condition
  74969. * @param value to compare with target state
  74970. */
  74971. constructor(actionManager: ActionManager, target: any,
  74972. /** Value to compare with target state */
  74973. value: string);
  74974. /**
  74975. * Gets a boolean indicating if the current condition is met
  74976. * @returns the validity of the state
  74977. */
  74978. isValid(): boolean;
  74979. /**
  74980. * Serialize the StateCondition into a JSON compatible object
  74981. * @returns serialization object
  74982. */
  74983. serialize(): any;
  74984. }
  74985. }
  74986. declare module BABYLON {
  74987. /**
  74988. * This defines an action responsible to toggle a boolean once triggered.
  74989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74990. */
  74991. export class SwitchBooleanAction extends Action {
  74992. /**
  74993. * The path to the boolean property in the target object
  74994. */
  74995. propertyPath: string;
  74996. private _target;
  74997. private _effectiveTarget;
  74998. private _property;
  74999. /**
  75000. * Instantiate the action
  75001. * @param triggerOptions defines the trigger options
  75002. * @param target defines the object containing the boolean
  75003. * @param propertyPath defines the path to the boolean property in the target object
  75004. * @param condition defines the trigger related conditions
  75005. */
  75006. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75007. /** @hidden */
  75008. _prepare(): void;
  75009. /**
  75010. * Execute the action toggle the boolean value.
  75011. */
  75012. execute(): void;
  75013. /**
  75014. * Serializes the actions and its related information.
  75015. * @param parent defines the object to serialize in
  75016. * @returns the serialized object
  75017. */
  75018. serialize(parent: any): any;
  75019. }
  75020. /**
  75021. * This defines an action responsible to set a the state field of the target
  75022. * to a desired value once triggered.
  75023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75024. */
  75025. export class SetStateAction extends Action {
  75026. /**
  75027. * The value to store in the state field.
  75028. */
  75029. value: string;
  75030. private _target;
  75031. /**
  75032. * Instantiate the action
  75033. * @param triggerOptions defines the trigger options
  75034. * @param target defines the object containing the state property
  75035. * @param value defines the value to store in the state field
  75036. * @param condition defines the trigger related conditions
  75037. */
  75038. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75039. /**
  75040. * Execute the action and store the value on the target state property.
  75041. */
  75042. execute(): void;
  75043. /**
  75044. * Serializes the actions and its related information.
  75045. * @param parent defines the object to serialize in
  75046. * @returns the serialized object
  75047. */
  75048. serialize(parent: any): any;
  75049. }
  75050. /**
  75051. * This defines an action responsible to set a property of the target
  75052. * to a desired value once triggered.
  75053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75054. */
  75055. export class SetValueAction extends Action {
  75056. /**
  75057. * The path of the property to set in the target.
  75058. */
  75059. propertyPath: string;
  75060. /**
  75061. * The value to set in the property
  75062. */
  75063. value: any;
  75064. private _target;
  75065. private _effectiveTarget;
  75066. private _property;
  75067. /**
  75068. * Instantiate the action
  75069. * @param triggerOptions defines the trigger options
  75070. * @param target defines the object containing the property
  75071. * @param propertyPath defines the path of the property to set in the target
  75072. * @param value defines the value to set in the property
  75073. * @param condition defines the trigger related conditions
  75074. */
  75075. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75076. /** @hidden */
  75077. _prepare(): void;
  75078. /**
  75079. * Execute the action and set the targetted property to the desired value.
  75080. */
  75081. execute(): void;
  75082. /**
  75083. * Serializes the actions and its related information.
  75084. * @param parent defines the object to serialize in
  75085. * @returns the serialized object
  75086. */
  75087. serialize(parent: any): any;
  75088. }
  75089. /**
  75090. * This defines an action responsible to increment the target value
  75091. * to a desired value once triggered.
  75092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75093. */
  75094. export class IncrementValueAction extends Action {
  75095. /**
  75096. * The path of the property to increment in the target.
  75097. */
  75098. propertyPath: string;
  75099. /**
  75100. * The value we should increment the property by.
  75101. */
  75102. value: any;
  75103. private _target;
  75104. private _effectiveTarget;
  75105. private _property;
  75106. /**
  75107. * Instantiate the action
  75108. * @param triggerOptions defines the trigger options
  75109. * @param target defines the object containing the property
  75110. * @param propertyPath defines the path of the property to increment in the target
  75111. * @param value defines the value value we should increment the property by
  75112. * @param condition defines the trigger related conditions
  75113. */
  75114. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75115. /** @hidden */
  75116. _prepare(): void;
  75117. /**
  75118. * Execute the action and increment the target of the value amount.
  75119. */
  75120. execute(): void;
  75121. /**
  75122. * Serializes the actions and its related information.
  75123. * @param parent defines the object to serialize in
  75124. * @returns the serialized object
  75125. */
  75126. serialize(parent: any): any;
  75127. }
  75128. /**
  75129. * This defines an action responsible to start an animation once triggered.
  75130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75131. */
  75132. export class PlayAnimationAction extends Action {
  75133. /**
  75134. * Where the animation should start (animation frame)
  75135. */
  75136. from: number;
  75137. /**
  75138. * Where the animation should stop (animation frame)
  75139. */
  75140. to: number;
  75141. /**
  75142. * Define if the animation should loop or stop after the first play.
  75143. */
  75144. loop?: boolean;
  75145. private _target;
  75146. /**
  75147. * Instantiate the action
  75148. * @param triggerOptions defines the trigger options
  75149. * @param target defines the target animation or animation name
  75150. * @param from defines from where the animation should start (animation frame)
  75151. * @param end defines where the animation should stop (animation frame)
  75152. * @param loop defines if the animation should loop or stop after the first play
  75153. * @param condition defines the trigger related conditions
  75154. */
  75155. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75156. /** @hidden */
  75157. _prepare(): void;
  75158. /**
  75159. * Execute the action and play the animation.
  75160. */
  75161. execute(): void;
  75162. /**
  75163. * Serializes the actions and its related information.
  75164. * @param parent defines the object to serialize in
  75165. * @returns the serialized object
  75166. */
  75167. serialize(parent: any): any;
  75168. }
  75169. /**
  75170. * This defines an action responsible to stop an animation once triggered.
  75171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75172. */
  75173. export class StopAnimationAction extends Action {
  75174. private _target;
  75175. /**
  75176. * Instantiate the action
  75177. * @param triggerOptions defines the trigger options
  75178. * @param target defines the target animation or animation name
  75179. * @param condition defines the trigger related conditions
  75180. */
  75181. constructor(triggerOptions: any, target: any, condition?: Condition);
  75182. /** @hidden */
  75183. _prepare(): void;
  75184. /**
  75185. * Execute the action and stop the animation.
  75186. */
  75187. execute(): void;
  75188. /**
  75189. * Serializes the actions and its related information.
  75190. * @param parent defines the object to serialize in
  75191. * @returns the serialized object
  75192. */
  75193. serialize(parent: any): any;
  75194. }
  75195. /**
  75196. * This defines an action responsible that does nothing once triggered.
  75197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75198. */
  75199. export class DoNothingAction extends Action {
  75200. /**
  75201. * Instantiate the action
  75202. * @param triggerOptions defines the trigger options
  75203. * @param condition defines the trigger related conditions
  75204. */
  75205. constructor(triggerOptions?: any, condition?: Condition);
  75206. /**
  75207. * Execute the action and do nothing.
  75208. */
  75209. execute(): void;
  75210. /**
  75211. * Serializes the actions and its related information.
  75212. * @param parent defines the object to serialize in
  75213. * @returns the serialized object
  75214. */
  75215. serialize(parent: any): any;
  75216. }
  75217. /**
  75218. * This defines an action responsible to trigger several actions once triggered.
  75219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75220. */
  75221. export class CombineAction extends Action {
  75222. /**
  75223. * The list of aggregated animations to run.
  75224. */
  75225. children: Action[];
  75226. /**
  75227. * Instantiate the action
  75228. * @param triggerOptions defines the trigger options
  75229. * @param children defines the list of aggregated animations to run
  75230. * @param condition defines the trigger related conditions
  75231. */
  75232. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75233. /** @hidden */
  75234. _prepare(): void;
  75235. /**
  75236. * Execute the action and executes all the aggregated actions.
  75237. */
  75238. execute(evt: ActionEvent): void;
  75239. /**
  75240. * Serializes the actions and its related information.
  75241. * @param parent defines the object to serialize in
  75242. * @returns the serialized object
  75243. */
  75244. serialize(parent: any): any;
  75245. }
  75246. /**
  75247. * This defines an action responsible to run code (external event) once triggered.
  75248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75249. */
  75250. export class ExecuteCodeAction extends Action {
  75251. /**
  75252. * The callback function to run.
  75253. */
  75254. func: (evt: ActionEvent) => void;
  75255. /**
  75256. * Instantiate the action
  75257. * @param triggerOptions defines the trigger options
  75258. * @param func defines the callback function to run
  75259. * @param condition defines the trigger related conditions
  75260. */
  75261. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75262. /**
  75263. * Execute the action and run the attached code.
  75264. */
  75265. execute(evt: ActionEvent): void;
  75266. }
  75267. /**
  75268. * This defines an action responsible to set the parent property of the target once triggered.
  75269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75270. */
  75271. export class SetParentAction extends Action {
  75272. private _parent;
  75273. private _target;
  75274. /**
  75275. * Instantiate the action
  75276. * @param triggerOptions defines the trigger options
  75277. * @param target defines the target containing the parent property
  75278. * @param parent defines from where the animation should start (animation frame)
  75279. * @param condition defines the trigger related conditions
  75280. */
  75281. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75282. /** @hidden */
  75283. _prepare(): void;
  75284. /**
  75285. * Execute the action and set the parent property.
  75286. */
  75287. execute(): void;
  75288. /**
  75289. * Serializes the actions and its related information.
  75290. * @param parent defines the object to serialize in
  75291. * @returns the serialized object
  75292. */
  75293. serialize(parent: any): any;
  75294. }
  75295. }
  75296. declare module BABYLON {
  75297. /**
  75298. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75299. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75301. */
  75302. export class ActionManager extends AbstractActionManager {
  75303. /**
  75304. * Nothing
  75305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75306. */
  75307. static readonly NothingTrigger: number;
  75308. /**
  75309. * On pick
  75310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75311. */
  75312. static readonly OnPickTrigger: number;
  75313. /**
  75314. * On left pick
  75315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75316. */
  75317. static readonly OnLeftPickTrigger: number;
  75318. /**
  75319. * On right pick
  75320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75321. */
  75322. static readonly OnRightPickTrigger: number;
  75323. /**
  75324. * On center pick
  75325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75326. */
  75327. static readonly OnCenterPickTrigger: number;
  75328. /**
  75329. * On pick down
  75330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75331. */
  75332. static readonly OnPickDownTrigger: number;
  75333. /**
  75334. * On double pick
  75335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75336. */
  75337. static readonly OnDoublePickTrigger: number;
  75338. /**
  75339. * On pick up
  75340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75341. */
  75342. static readonly OnPickUpTrigger: number;
  75343. /**
  75344. * On pick out.
  75345. * This trigger will only be raised if you also declared a OnPickDown
  75346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75347. */
  75348. static readonly OnPickOutTrigger: number;
  75349. /**
  75350. * On long press
  75351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75352. */
  75353. static readonly OnLongPressTrigger: number;
  75354. /**
  75355. * On pointer over
  75356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75357. */
  75358. static readonly OnPointerOverTrigger: number;
  75359. /**
  75360. * On pointer out
  75361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75362. */
  75363. static readonly OnPointerOutTrigger: number;
  75364. /**
  75365. * On every frame
  75366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75367. */
  75368. static readonly OnEveryFrameTrigger: number;
  75369. /**
  75370. * On intersection enter
  75371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75372. */
  75373. static readonly OnIntersectionEnterTrigger: number;
  75374. /**
  75375. * On intersection exit
  75376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75377. */
  75378. static readonly OnIntersectionExitTrigger: number;
  75379. /**
  75380. * On key down
  75381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75382. */
  75383. static readonly OnKeyDownTrigger: number;
  75384. /**
  75385. * On key up
  75386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75387. */
  75388. static readonly OnKeyUpTrigger: number;
  75389. private _scene;
  75390. /**
  75391. * Creates a new action manager
  75392. * @param scene defines the hosting scene
  75393. */
  75394. constructor(scene: Scene);
  75395. /**
  75396. * Releases all associated resources
  75397. */
  75398. dispose(): void;
  75399. /**
  75400. * Gets hosting scene
  75401. * @returns the hosting scene
  75402. */
  75403. getScene(): Scene;
  75404. /**
  75405. * Does this action manager handles actions of any of the given triggers
  75406. * @param triggers defines the triggers to be tested
  75407. * @return a boolean indicating whether one (or more) of the triggers is handled
  75408. */
  75409. hasSpecificTriggers(triggers: number[]): boolean;
  75410. /**
  75411. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75412. * speed.
  75413. * @param triggerA defines the trigger to be tested
  75414. * @param triggerB defines the trigger to be tested
  75415. * @return a boolean indicating whether one (or more) of the triggers is handled
  75416. */
  75417. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75418. /**
  75419. * Does this action manager handles actions of a given trigger
  75420. * @param trigger defines the trigger to be tested
  75421. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75422. * @return whether the trigger is handled
  75423. */
  75424. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75425. /**
  75426. * Does this action manager has pointer triggers
  75427. */
  75428. readonly hasPointerTriggers: boolean;
  75429. /**
  75430. * Does this action manager has pick triggers
  75431. */
  75432. readonly hasPickTriggers: boolean;
  75433. /**
  75434. * Registers an action to this action manager
  75435. * @param action defines the action to be registered
  75436. * @return the action amended (prepared) after registration
  75437. */
  75438. registerAction(action: IAction): Nullable<IAction>;
  75439. /**
  75440. * Unregisters an action to this action manager
  75441. * @param action defines the action to be unregistered
  75442. * @return a boolean indicating whether the action has been unregistered
  75443. */
  75444. unregisterAction(action: IAction): Boolean;
  75445. /**
  75446. * Process a specific trigger
  75447. * @param trigger defines the trigger to process
  75448. * @param evt defines the event details to be processed
  75449. */
  75450. processTrigger(trigger: number, evt?: IActionEvent): void;
  75451. /** @hidden */
  75452. _getEffectiveTarget(target: any, propertyPath: string): any;
  75453. /** @hidden */
  75454. _getProperty(propertyPath: string): string;
  75455. /**
  75456. * Serialize this manager to a JSON object
  75457. * @param name defines the property name to store this manager
  75458. * @returns a JSON representation of this manager
  75459. */
  75460. serialize(name: string): any;
  75461. /**
  75462. * Creates a new ActionManager from a JSON data
  75463. * @param parsedActions defines the JSON data to read from
  75464. * @param object defines the hosting mesh
  75465. * @param scene defines the hosting scene
  75466. */
  75467. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75468. /**
  75469. * Get a trigger name by index
  75470. * @param trigger defines the trigger index
  75471. * @returns a trigger name
  75472. */
  75473. static GetTriggerName(trigger: number): string;
  75474. }
  75475. }
  75476. declare module BABYLON {
  75477. /**
  75478. * Class representing a ray with position and direction
  75479. */
  75480. export class Ray {
  75481. /** origin point */
  75482. origin: Vector3;
  75483. /** direction */
  75484. direction: Vector3;
  75485. /** length of the ray */
  75486. length: number;
  75487. private static readonly TmpVector3;
  75488. private _tmpRay;
  75489. /**
  75490. * Creates a new ray
  75491. * @param origin origin point
  75492. * @param direction direction
  75493. * @param length length of the ray
  75494. */
  75495. constructor(
  75496. /** origin point */
  75497. origin: Vector3,
  75498. /** direction */
  75499. direction: Vector3,
  75500. /** length of the ray */
  75501. length?: number);
  75502. /**
  75503. * Checks if the ray intersects a box
  75504. * @param minimum bound of the box
  75505. * @param maximum bound of the box
  75506. * @param intersectionTreshold extra extend to be added to the box in all direction
  75507. * @returns if the box was hit
  75508. */
  75509. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75510. /**
  75511. * Checks if the ray intersects a box
  75512. * @param box the bounding box to check
  75513. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75514. * @returns if the box was hit
  75515. */
  75516. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75517. /**
  75518. * If the ray hits a sphere
  75519. * @param sphere the bounding sphere to check
  75520. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75521. * @returns true if it hits the sphere
  75522. */
  75523. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75524. /**
  75525. * If the ray hits a triange
  75526. * @param vertex0 triangle vertex
  75527. * @param vertex1 triangle vertex
  75528. * @param vertex2 triangle vertex
  75529. * @returns intersection information if hit
  75530. */
  75531. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75532. /**
  75533. * Checks if ray intersects a plane
  75534. * @param plane the plane to check
  75535. * @returns the distance away it was hit
  75536. */
  75537. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75538. /**
  75539. * Calculate the intercept of a ray on a given axis
  75540. * @param axis to check 'x' | 'y' | 'z'
  75541. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75542. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75543. */
  75544. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75545. /**
  75546. * Checks if ray intersects a mesh
  75547. * @param mesh the mesh to check
  75548. * @param fastCheck if only the bounding box should checked
  75549. * @returns picking info of the intersecton
  75550. */
  75551. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75552. /**
  75553. * Checks if ray intersects a mesh
  75554. * @param meshes the meshes to check
  75555. * @param fastCheck if only the bounding box should checked
  75556. * @param results array to store result in
  75557. * @returns Array of picking infos
  75558. */
  75559. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75560. private _comparePickingInfo;
  75561. private static smallnum;
  75562. private static rayl;
  75563. /**
  75564. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75565. * @param sega the first point of the segment to test the intersection against
  75566. * @param segb the second point of the segment to test the intersection against
  75567. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75568. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75569. */
  75570. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75571. /**
  75572. * Update the ray from viewport position
  75573. * @param x position
  75574. * @param y y position
  75575. * @param viewportWidth viewport width
  75576. * @param viewportHeight viewport height
  75577. * @param world world matrix
  75578. * @param view view matrix
  75579. * @param projection projection matrix
  75580. * @returns this ray updated
  75581. */
  75582. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75583. /**
  75584. * Creates a ray with origin and direction of 0,0,0
  75585. * @returns the new ray
  75586. */
  75587. static Zero(): Ray;
  75588. /**
  75589. * Creates a new ray from screen space and viewport
  75590. * @param x position
  75591. * @param y y position
  75592. * @param viewportWidth viewport width
  75593. * @param viewportHeight viewport height
  75594. * @param world world matrix
  75595. * @param view view matrix
  75596. * @param projection projection matrix
  75597. * @returns new ray
  75598. */
  75599. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75600. /**
  75601. * 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
  75602. * transformed to the given world matrix.
  75603. * @param origin The origin point
  75604. * @param end The end point
  75605. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75606. * @returns the new ray
  75607. */
  75608. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75609. /**
  75610. * Transforms a ray by a matrix
  75611. * @param ray ray to transform
  75612. * @param matrix matrix to apply
  75613. * @returns the resulting new ray
  75614. */
  75615. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75616. /**
  75617. * Transforms a ray by a matrix
  75618. * @param ray ray to transform
  75619. * @param matrix matrix to apply
  75620. * @param result ray to store result in
  75621. */
  75622. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75623. /**
  75624. * Unproject a ray from screen space to object space
  75625. * @param sourceX defines the screen space x coordinate to use
  75626. * @param sourceY defines the screen space y coordinate to use
  75627. * @param viewportWidth defines the current width of the viewport
  75628. * @param viewportHeight defines the current height of the viewport
  75629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75630. * @param view defines the view matrix to use
  75631. * @param projection defines the projection matrix to use
  75632. */
  75633. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75634. }
  75635. /**
  75636. * Type used to define predicate used to select faces when a mesh intersection is detected
  75637. */
  75638. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75639. interface Scene {
  75640. /** @hidden */
  75641. _tempPickingRay: Nullable<Ray>;
  75642. /** @hidden */
  75643. _cachedRayForTransform: Ray;
  75644. /** @hidden */
  75645. _pickWithRayInverseMatrix: Matrix;
  75646. /** @hidden */
  75647. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75648. /** @hidden */
  75649. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75650. }
  75651. }
  75652. declare module BABYLON {
  75653. /**
  75654. * Groups all the scene component constants in one place to ease maintenance.
  75655. * @hidden
  75656. */
  75657. export class SceneComponentConstants {
  75658. static readonly NAME_EFFECTLAYER: string;
  75659. static readonly NAME_LAYER: string;
  75660. static readonly NAME_LENSFLARESYSTEM: string;
  75661. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75662. static readonly NAME_PARTICLESYSTEM: string;
  75663. static readonly NAME_GAMEPAD: string;
  75664. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75665. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75666. static readonly NAME_DEPTHRENDERER: string;
  75667. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75668. static readonly NAME_SPRITE: string;
  75669. static readonly NAME_OUTLINERENDERER: string;
  75670. static readonly NAME_PROCEDURALTEXTURE: string;
  75671. static readonly NAME_SHADOWGENERATOR: string;
  75672. static readonly NAME_OCTREE: string;
  75673. static readonly NAME_PHYSICSENGINE: string;
  75674. static readonly NAME_AUDIO: string;
  75675. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75676. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75677. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75678. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75679. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75680. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75681. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75682. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75683. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75684. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75685. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75686. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75687. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75688. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75689. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75690. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75691. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75692. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75693. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75694. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75695. static readonly STEP_AFTERRENDER_AUDIO: number;
  75696. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75697. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75698. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75699. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75700. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75701. static readonly STEP_POINTERMOVE_SPRITE: number;
  75702. static readonly STEP_POINTERDOWN_SPRITE: number;
  75703. static readonly STEP_POINTERUP_SPRITE: number;
  75704. }
  75705. /**
  75706. * This represents a scene component.
  75707. *
  75708. * This is used to decouple the dependency the scene is having on the different workloads like
  75709. * layers, post processes...
  75710. */
  75711. export interface ISceneComponent {
  75712. /**
  75713. * The name of the component. Each component must have a unique name.
  75714. */
  75715. name: string;
  75716. /**
  75717. * The scene the component belongs to.
  75718. */
  75719. scene: Scene;
  75720. /**
  75721. * Register the component to one instance of a scene.
  75722. */
  75723. register(): void;
  75724. /**
  75725. * Rebuilds the elements related to this component in case of
  75726. * context lost for instance.
  75727. */
  75728. rebuild(): void;
  75729. /**
  75730. * Disposes the component and the associated ressources.
  75731. */
  75732. dispose(): void;
  75733. }
  75734. /**
  75735. * This represents a SERIALIZABLE scene component.
  75736. *
  75737. * This extends Scene Component to add Serialization methods on top.
  75738. */
  75739. export interface ISceneSerializableComponent extends ISceneComponent {
  75740. /**
  75741. * Adds all the elements from the container to the scene
  75742. * @param container the container holding the elements
  75743. */
  75744. addFromContainer(container: AbstractScene): void;
  75745. /**
  75746. * Removes all the elements in the container from the scene
  75747. * @param container contains the elements to remove
  75748. * @param dispose if the removed element should be disposed (default: false)
  75749. */
  75750. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75751. /**
  75752. * Serializes the component data to the specified json object
  75753. * @param serializationObject The object to serialize to
  75754. */
  75755. serialize(serializationObject: any): void;
  75756. }
  75757. /**
  75758. * Strong typing of a Mesh related stage step action
  75759. */
  75760. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75761. /**
  75762. * Strong typing of a Evaluate Sub Mesh related stage step action
  75763. */
  75764. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75765. /**
  75766. * Strong typing of a Active Mesh related stage step action
  75767. */
  75768. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75769. /**
  75770. * Strong typing of a Camera related stage step action
  75771. */
  75772. export type CameraStageAction = (camera: Camera) => void;
  75773. /**
  75774. * Strong typing of a Camera Frame buffer related stage step action
  75775. */
  75776. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75777. /**
  75778. * Strong typing of a Render Target related stage step action
  75779. */
  75780. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75781. /**
  75782. * Strong typing of a RenderingGroup related stage step action
  75783. */
  75784. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75785. /**
  75786. * Strong typing of a Mesh Render related stage step action
  75787. */
  75788. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75789. /**
  75790. * Strong typing of a simple stage step action
  75791. */
  75792. export type SimpleStageAction = () => void;
  75793. /**
  75794. * Strong typing of a render target action.
  75795. */
  75796. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75797. /**
  75798. * Strong typing of a pointer move action.
  75799. */
  75800. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75801. /**
  75802. * Strong typing of a pointer up/down action.
  75803. */
  75804. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75805. /**
  75806. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75807. * @hidden
  75808. */
  75809. export class Stage<T extends Function> extends Array<{
  75810. index: number;
  75811. component: ISceneComponent;
  75812. action: T;
  75813. }> {
  75814. /**
  75815. * Hide ctor from the rest of the world.
  75816. * @param items The items to add.
  75817. */
  75818. private constructor();
  75819. /**
  75820. * Creates a new Stage.
  75821. * @returns A new instance of a Stage
  75822. */
  75823. static Create<T extends Function>(): Stage<T>;
  75824. /**
  75825. * Registers a step in an ordered way in the targeted stage.
  75826. * @param index Defines the position to register the step in
  75827. * @param component Defines the component attached to the step
  75828. * @param action Defines the action to launch during the step
  75829. */
  75830. registerStep(index: number, component: ISceneComponent, action: T): void;
  75831. /**
  75832. * Clears all the steps from the stage.
  75833. */
  75834. clear(): void;
  75835. }
  75836. }
  75837. declare module BABYLON {
  75838. interface Scene {
  75839. /** @hidden */
  75840. _pointerOverSprite: Nullable<Sprite>;
  75841. /** @hidden */
  75842. _pickedDownSprite: Nullable<Sprite>;
  75843. /** @hidden */
  75844. _tempSpritePickingRay: Nullable<Ray>;
  75845. /**
  75846. * All of the sprite managers added to this scene
  75847. * @see http://doc.babylonjs.com/babylon101/sprites
  75848. */
  75849. spriteManagers: Array<ISpriteManager>;
  75850. /**
  75851. * An event triggered when sprites rendering is about to start
  75852. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75853. */
  75854. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75855. /**
  75856. * An event triggered when sprites rendering is done
  75857. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75858. */
  75859. onAfterSpritesRenderingObservable: Observable<Scene>;
  75860. /** @hidden */
  75861. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75862. /** Launch a ray to try to pick a sprite in the scene
  75863. * @param x position on screen
  75864. * @param y position on screen
  75865. * @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
  75866. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75867. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75868. * @returns a PickingInfo
  75869. */
  75870. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75871. /** Use the given ray to pick a sprite in the scene
  75872. * @param ray The ray (in world space) to use to pick meshes
  75873. * @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
  75874. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75875. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75876. * @returns a PickingInfo
  75877. */
  75878. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75879. /**
  75880. * Force the sprite under the pointer
  75881. * @param sprite defines the sprite to use
  75882. */
  75883. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75884. /**
  75885. * Gets the sprite under the pointer
  75886. * @returns a Sprite or null if no sprite is under the pointer
  75887. */
  75888. getPointerOverSprite(): Nullable<Sprite>;
  75889. }
  75890. /**
  75891. * Defines the sprite scene component responsible to manage sprites
  75892. * in a given scene.
  75893. */
  75894. export class SpriteSceneComponent implements ISceneComponent {
  75895. /**
  75896. * The component name helpfull to identify the component in the list of scene components.
  75897. */
  75898. readonly name: string;
  75899. /**
  75900. * The scene the component belongs to.
  75901. */
  75902. scene: Scene;
  75903. /** @hidden */
  75904. private _spritePredicate;
  75905. /**
  75906. * Creates a new instance of the component for the given scene
  75907. * @param scene Defines the scene to register the component in
  75908. */
  75909. constructor(scene: Scene);
  75910. /**
  75911. * Registers the component in a given scene
  75912. */
  75913. register(): void;
  75914. /**
  75915. * Rebuilds the elements related to this component in case of
  75916. * context lost for instance.
  75917. */
  75918. rebuild(): void;
  75919. /**
  75920. * Disposes the component and the associated ressources.
  75921. */
  75922. dispose(): void;
  75923. private _pickSpriteButKeepRay;
  75924. private _pointerMove;
  75925. private _pointerDown;
  75926. private _pointerUp;
  75927. }
  75928. }
  75929. declare module BABYLON {
  75930. /** @hidden */
  75931. export var fogFragmentDeclaration: {
  75932. name: string;
  75933. shader: string;
  75934. };
  75935. }
  75936. declare module BABYLON {
  75937. /** @hidden */
  75938. export var fogFragment: {
  75939. name: string;
  75940. shader: string;
  75941. };
  75942. }
  75943. declare module BABYLON {
  75944. /** @hidden */
  75945. export var spritesPixelShader: {
  75946. name: string;
  75947. shader: string;
  75948. };
  75949. }
  75950. declare module BABYLON {
  75951. /** @hidden */
  75952. export var fogVertexDeclaration: {
  75953. name: string;
  75954. shader: string;
  75955. };
  75956. }
  75957. declare module BABYLON {
  75958. /** @hidden */
  75959. export var spritesVertexShader: {
  75960. name: string;
  75961. shader: string;
  75962. };
  75963. }
  75964. declare module BABYLON {
  75965. /**
  75966. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75967. */
  75968. export interface ISpriteManager extends IDisposable {
  75969. /**
  75970. * Restricts the camera to viewing objects with the same layerMask.
  75971. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75972. */
  75973. layerMask: number;
  75974. /**
  75975. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75976. */
  75977. isPickable: boolean;
  75978. /**
  75979. * Specifies the rendering group id for this mesh (0 by default)
  75980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75981. */
  75982. renderingGroupId: number;
  75983. /**
  75984. * Defines the list of sprites managed by the manager.
  75985. */
  75986. sprites: Array<Sprite>;
  75987. /**
  75988. * Tests the intersection of a sprite with a specific ray.
  75989. * @param ray The ray we are sending to test the collision
  75990. * @param camera The camera space we are sending rays in
  75991. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75992. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75993. * @returns picking info or null.
  75994. */
  75995. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75996. /**
  75997. * Renders the list of sprites on screen.
  75998. */
  75999. render(): void;
  76000. }
  76001. /**
  76002. * Class used to manage multiple sprites on the same spritesheet
  76003. * @see http://doc.babylonjs.com/babylon101/sprites
  76004. */
  76005. export class SpriteManager implements ISpriteManager {
  76006. /** defines the manager's name */
  76007. name: string;
  76008. /** Gets the list of sprites */
  76009. sprites: Sprite[];
  76010. /** Gets or sets the rendering group id (0 by default) */
  76011. renderingGroupId: number;
  76012. /** Gets or sets camera layer mask */
  76013. layerMask: number;
  76014. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76015. fogEnabled: boolean;
  76016. /** Gets or sets a boolean indicating if the sprites are pickable */
  76017. isPickable: boolean;
  76018. /** Defines the default width of a cell in the spritesheet */
  76019. cellWidth: number;
  76020. /** Defines the default height of a cell in the spritesheet */
  76021. cellHeight: number;
  76022. /** Associative array from JSON sprite data file */
  76023. private _cellData;
  76024. /** Array of sprite names from JSON sprite data file */
  76025. private _spriteMap;
  76026. /** True when packed cell data from JSON file is ready*/
  76027. private _packedAndReady;
  76028. /**
  76029. * An event triggered when the manager is disposed.
  76030. */
  76031. onDisposeObservable: Observable<SpriteManager>;
  76032. private _onDisposeObserver;
  76033. /**
  76034. * Callback called when the manager is disposed
  76035. */
  76036. onDispose: () => void;
  76037. private _capacity;
  76038. private _fromPacked;
  76039. private _spriteTexture;
  76040. private _epsilon;
  76041. private _scene;
  76042. private _vertexData;
  76043. private _buffer;
  76044. private _vertexBuffers;
  76045. private _indexBuffer;
  76046. private _effectBase;
  76047. private _effectFog;
  76048. /**
  76049. * Gets or sets the spritesheet texture
  76050. */
  76051. texture: Texture;
  76052. /**
  76053. * Creates a new sprite manager
  76054. * @param name defines the manager's name
  76055. * @param imgUrl defines the sprite sheet url
  76056. * @param capacity defines the maximum allowed number of sprites
  76057. * @param cellSize defines the size of a sprite cell
  76058. * @param scene defines the hosting scene
  76059. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76060. * @param samplingMode defines the smapling mode to use with spritesheet
  76061. * @param fromPacked set to false; do not alter
  76062. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76063. */
  76064. constructor(
  76065. /** defines the manager's name */
  76066. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76067. private _makePacked;
  76068. private _appendSpriteVertex;
  76069. /**
  76070. * Intersects the sprites with a ray
  76071. * @param ray defines the ray to intersect with
  76072. * @param camera defines the current active camera
  76073. * @param predicate defines a predicate used to select candidate sprites
  76074. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76075. * @returns null if no hit or a PickingInfo
  76076. */
  76077. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76078. /**
  76079. * Render all child sprites
  76080. */
  76081. render(): void;
  76082. /**
  76083. * Release associated resources
  76084. */
  76085. dispose(): void;
  76086. }
  76087. }
  76088. declare module BABYLON {
  76089. /**
  76090. * Class used to represent a sprite
  76091. * @see http://doc.babylonjs.com/babylon101/sprites
  76092. */
  76093. export class Sprite {
  76094. /** defines the name */
  76095. name: string;
  76096. /** Gets or sets the current world position */
  76097. position: Vector3;
  76098. /** Gets or sets the main color */
  76099. color: Color4;
  76100. /** Gets or sets the width */
  76101. width: number;
  76102. /** Gets or sets the height */
  76103. height: number;
  76104. /** Gets or sets rotation angle */
  76105. angle: number;
  76106. /** Gets or sets the cell index in the sprite sheet */
  76107. cellIndex: number;
  76108. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76109. cellRef: string;
  76110. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76111. invertU: number;
  76112. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76113. invertV: number;
  76114. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76115. disposeWhenFinishedAnimating: boolean;
  76116. /** Gets the list of attached animations */
  76117. animations: Animation[];
  76118. /** Gets or sets a boolean indicating if the sprite can be picked */
  76119. isPickable: boolean;
  76120. /**
  76121. * Gets or sets the associated action manager
  76122. */
  76123. actionManager: Nullable<ActionManager>;
  76124. private _animationStarted;
  76125. private _loopAnimation;
  76126. private _fromIndex;
  76127. private _toIndex;
  76128. private _delay;
  76129. private _direction;
  76130. private _manager;
  76131. private _time;
  76132. private _onAnimationEnd;
  76133. /**
  76134. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76135. */
  76136. isVisible: boolean;
  76137. /**
  76138. * Gets or sets the sprite size
  76139. */
  76140. size: number;
  76141. /**
  76142. * Creates a new Sprite
  76143. * @param name defines the name
  76144. * @param manager defines the manager
  76145. */
  76146. constructor(
  76147. /** defines the name */
  76148. name: string, manager: ISpriteManager);
  76149. /**
  76150. * Starts an animation
  76151. * @param from defines the initial key
  76152. * @param to defines the end key
  76153. * @param loop defines if the animation must loop
  76154. * @param delay defines the start delay (in ms)
  76155. * @param onAnimationEnd defines a callback to call when animation ends
  76156. */
  76157. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76158. /** Stops current animation (if any) */
  76159. stopAnimation(): void;
  76160. /** @hidden */
  76161. _animate(deltaTime: number): void;
  76162. /** Release associated resources */
  76163. dispose(): void;
  76164. }
  76165. }
  76166. declare module BABYLON {
  76167. /**
  76168. * Information about the result of picking within a scene
  76169. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76170. */
  76171. export class PickingInfo {
  76172. /** @hidden */
  76173. _pickingUnavailable: boolean;
  76174. /**
  76175. * If the pick collided with an object
  76176. */
  76177. hit: boolean;
  76178. /**
  76179. * Distance away where the pick collided
  76180. */
  76181. distance: number;
  76182. /**
  76183. * The location of pick collision
  76184. */
  76185. pickedPoint: Nullable<Vector3>;
  76186. /**
  76187. * The mesh corresponding the the pick collision
  76188. */
  76189. pickedMesh: Nullable<AbstractMesh>;
  76190. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76191. bu: number;
  76192. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76193. bv: number;
  76194. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76195. faceId: number;
  76196. /** Id of the the submesh that was picked */
  76197. subMeshId: number;
  76198. /** If a sprite was picked, this will be the sprite the pick collided with */
  76199. pickedSprite: Nullable<Sprite>;
  76200. /**
  76201. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76202. */
  76203. originMesh: Nullable<AbstractMesh>;
  76204. /**
  76205. * The ray that was used to perform the picking.
  76206. */
  76207. ray: Nullable<Ray>;
  76208. /**
  76209. * Gets the normal correspodning to the face the pick collided with
  76210. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76211. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76212. * @returns The normal correspodning to the face the pick collided with
  76213. */
  76214. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76215. /**
  76216. * Gets the texture coordinates of where the pick occured
  76217. * @returns the vector containing the coordnates of the texture
  76218. */
  76219. getTextureCoordinates(): Nullable<Vector2>;
  76220. }
  76221. }
  76222. declare module BABYLON {
  76223. /**
  76224. * Gather the list of pointer event types as constants.
  76225. */
  76226. export class PointerEventTypes {
  76227. /**
  76228. * 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.
  76229. */
  76230. static readonly POINTERDOWN: number;
  76231. /**
  76232. * The pointerup event is fired when a pointer is no longer active.
  76233. */
  76234. static readonly POINTERUP: number;
  76235. /**
  76236. * The pointermove event is fired when a pointer changes coordinates.
  76237. */
  76238. static readonly POINTERMOVE: number;
  76239. /**
  76240. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76241. */
  76242. static readonly POINTERWHEEL: number;
  76243. /**
  76244. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76245. */
  76246. static readonly POINTERPICK: number;
  76247. /**
  76248. * The pointertap event is fired when a the object has been touched and released without drag.
  76249. */
  76250. static readonly POINTERTAP: number;
  76251. /**
  76252. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76253. */
  76254. static readonly POINTERDOUBLETAP: number;
  76255. }
  76256. /**
  76257. * Base class of pointer info types.
  76258. */
  76259. export class PointerInfoBase {
  76260. /**
  76261. * Defines the type of event (PointerEventTypes)
  76262. */
  76263. type: number;
  76264. /**
  76265. * Defines the related dom event
  76266. */
  76267. event: PointerEvent | MouseWheelEvent;
  76268. /**
  76269. * Instantiates the base class of pointers info.
  76270. * @param type Defines the type of event (PointerEventTypes)
  76271. * @param event Defines the related dom event
  76272. */
  76273. constructor(
  76274. /**
  76275. * Defines the type of event (PointerEventTypes)
  76276. */
  76277. type: number,
  76278. /**
  76279. * Defines the related dom event
  76280. */
  76281. event: PointerEvent | MouseWheelEvent);
  76282. }
  76283. /**
  76284. * This class is used to store pointer related info for the onPrePointerObservable event.
  76285. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76286. */
  76287. export class PointerInfoPre extends PointerInfoBase {
  76288. /**
  76289. * Ray from a pointer if availible (eg. 6dof controller)
  76290. */
  76291. ray: Nullable<Ray>;
  76292. /**
  76293. * Defines the local position of the pointer on the canvas.
  76294. */
  76295. localPosition: Vector2;
  76296. /**
  76297. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76298. */
  76299. skipOnPointerObservable: boolean;
  76300. /**
  76301. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76302. * @param type Defines the type of event (PointerEventTypes)
  76303. * @param event Defines the related dom event
  76304. * @param localX Defines the local x coordinates of the pointer when the event occured
  76305. * @param localY Defines the local y coordinates of the pointer when the event occured
  76306. */
  76307. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76308. }
  76309. /**
  76310. * This type contains all the data related to a pointer event in Babylon.js.
  76311. * 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.
  76312. */
  76313. export class PointerInfo extends PointerInfoBase {
  76314. /**
  76315. * Defines the picking info associated to the info (if any)\
  76316. */
  76317. pickInfo: Nullable<PickingInfo>;
  76318. /**
  76319. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76320. * @param type Defines the type of event (PointerEventTypes)
  76321. * @param event Defines the related dom event
  76322. * @param pickInfo Defines the picking info associated to the info (if any)\
  76323. */
  76324. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76325. /**
  76326. * Defines the picking info associated to the info (if any)\
  76327. */
  76328. pickInfo: Nullable<PickingInfo>);
  76329. }
  76330. /**
  76331. * Data relating to a touch event on the screen.
  76332. */
  76333. export interface PointerTouch {
  76334. /**
  76335. * X coordinate of touch.
  76336. */
  76337. x: number;
  76338. /**
  76339. * Y coordinate of touch.
  76340. */
  76341. y: number;
  76342. /**
  76343. * Id of touch. Unique for each finger.
  76344. */
  76345. pointerId: number;
  76346. /**
  76347. * Event type passed from DOM.
  76348. */
  76349. type: any;
  76350. }
  76351. }
  76352. declare module BABYLON {
  76353. /**
  76354. * Manage the mouse inputs to control the movement of a free camera.
  76355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76356. */
  76357. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76358. /**
  76359. * Define if touch is enabled in the mouse input
  76360. */
  76361. touchEnabled: boolean;
  76362. /**
  76363. * Defines the camera the input is attached to.
  76364. */
  76365. camera: FreeCamera;
  76366. /**
  76367. * Defines the buttons associated with the input to handle camera move.
  76368. */
  76369. buttons: number[];
  76370. /**
  76371. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76372. */
  76373. angularSensibility: number;
  76374. private _pointerInput;
  76375. private _onMouseMove;
  76376. private _observer;
  76377. private previousPosition;
  76378. /**
  76379. * Observable for when a pointer move event occurs containing the move offset
  76380. */
  76381. onPointerMovedObservable: Observable<{
  76382. offsetX: number;
  76383. offsetY: number;
  76384. }>;
  76385. /**
  76386. * @hidden
  76387. * If the camera should be rotated automatically based on pointer movement
  76388. */
  76389. _allowCameraRotation: boolean;
  76390. /**
  76391. * Manage the mouse inputs to control the movement of a free camera.
  76392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76393. * @param touchEnabled Defines if touch is enabled or not
  76394. */
  76395. constructor(
  76396. /**
  76397. * Define if touch is enabled in the mouse input
  76398. */
  76399. touchEnabled?: boolean);
  76400. /**
  76401. * Attach the input controls to a specific dom element to get the input from.
  76402. * @param element Defines the element the controls should be listened from
  76403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76404. */
  76405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76406. /**
  76407. * Called on JS contextmenu event.
  76408. * Override this method to provide functionality.
  76409. */
  76410. protected onContextMenu(evt: PointerEvent): void;
  76411. /**
  76412. * Detach the current controls from the specified dom element.
  76413. * @param element Defines the element to stop listening the inputs from
  76414. */
  76415. detachControl(element: Nullable<HTMLElement>): void;
  76416. /**
  76417. * Gets the class name of the current intput.
  76418. * @returns the class name
  76419. */
  76420. getClassName(): string;
  76421. /**
  76422. * Get the friendly name associated with the input class.
  76423. * @returns the input friendly name
  76424. */
  76425. getSimpleName(): string;
  76426. }
  76427. }
  76428. declare module BABYLON {
  76429. /**
  76430. * Manage the touch inputs to control the movement of a free camera.
  76431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76432. */
  76433. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76434. /**
  76435. * Defines the camera the input is attached to.
  76436. */
  76437. camera: FreeCamera;
  76438. /**
  76439. * Defines the touch sensibility for rotation.
  76440. * The higher the faster.
  76441. */
  76442. touchAngularSensibility: number;
  76443. /**
  76444. * Defines the touch sensibility for move.
  76445. * The higher the faster.
  76446. */
  76447. touchMoveSensibility: number;
  76448. private _offsetX;
  76449. private _offsetY;
  76450. private _pointerPressed;
  76451. private _pointerInput;
  76452. private _observer;
  76453. private _onLostFocus;
  76454. /**
  76455. * Attach the input controls to a specific dom element to get the input from.
  76456. * @param element Defines the element the controls should be listened from
  76457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76458. */
  76459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76460. /**
  76461. * Detach the current controls from the specified dom element.
  76462. * @param element Defines the element to stop listening the inputs from
  76463. */
  76464. detachControl(element: Nullable<HTMLElement>): void;
  76465. /**
  76466. * Update the current camera state depending on the inputs that have been used this frame.
  76467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76468. */
  76469. checkInputs(): void;
  76470. /**
  76471. * Gets the class name of the current intput.
  76472. * @returns the class name
  76473. */
  76474. getClassName(): string;
  76475. /**
  76476. * Get the friendly name associated with the input class.
  76477. * @returns the input friendly name
  76478. */
  76479. getSimpleName(): string;
  76480. }
  76481. }
  76482. declare module BABYLON {
  76483. /**
  76484. * Default Inputs manager for the FreeCamera.
  76485. * It groups all the default supported inputs for ease of use.
  76486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76487. */
  76488. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76489. /**
  76490. * @hidden
  76491. */
  76492. _mouseInput: Nullable<FreeCameraMouseInput>;
  76493. /**
  76494. * Instantiates a new FreeCameraInputsManager.
  76495. * @param camera Defines the camera the inputs belong to
  76496. */
  76497. constructor(camera: FreeCamera);
  76498. /**
  76499. * Add keyboard input support to the input manager.
  76500. * @returns the current input manager
  76501. */
  76502. addKeyboard(): FreeCameraInputsManager;
  76503. /**
  76504. * Add mouse input support to the input manager.
  76505. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76506. * @returns the current input manager
  76507. */
  76508. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76509. /**
  76510. * Removes the mouse input support from the manager
  76511. * @returns the current input manager
  76512. */
  76513. removeMouse(): FreeCameraInputsManager;
  76514. /**
  76515. * Add touch input support to the input manager.
  76516. * @returns the current input manager
  76517. */
  76518. addTouch(): FreeCameraInputsManager;
  76519. /**
  76520. * Remove all attached input methods from a camera
  76521. */
  76522. clear(): void;
  76523. }
  76524. }
  76525. declare module BABYLON {
  76526. /**
  76527. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76528. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76530. */
  76531. export class FreeCamera extends TargetCamera {
  76532. /**
  76533. * Define the collision ellipsoid of the camera.
  76534. * This is helpful to simulate a camera body like the player body around the camera
  76535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76536. */
  76537. ellipsoid: Vector3;
  76538. /**
  76539. * Define an offset for the position of the ellipsoid around the camera.
  76540. * This can be helpful to determine the center of the body near the gravity center of the body
  76541. * instead of its head.
  76542. */
  76543. ellipsoidOffset: Vector3;
  76544. /**
  76545. * Enable or disable collisions of the camera with the rest of the scene objects.
  76546. */
  76547. checkCollisions: boolean;
  76548. /**
  76549. * Enable or disable gravity on the camera.
  76550. */
  76551. applyGravity: boolean;
  76552. /**
  76553. * Define the input manager associated to the camera.
  76554. */
  76555. inputs: FreeCameraInputsManager;
  76556. /**
  76557. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76558. * Higher values reduce sensitivity.
  76559. */
  76560. /**
  76561. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76562. * Higher values reduce sensitivity.
  76563. */
  76564. angularSensibility: number;
  76565. /**
  76566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76567. */
  76568. keysUp: number[];
  76569. /**
  76570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76571. */
  76572. keysDown: number[];
  76573. /**
  76574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76575. */
  76576. keysLeft: number[];
  76577. /**
  76578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76579. */
  76580. keysRight: number[];
  76581. /**
  76582. * Event raised when the camera collide with a mesh in the scene.
  76583. */
  76584. onCollide: (collidedMesh: AbstractMesh) => void;
  76585. private _collider;
  76586. private _needMoveForGravity;
  76587. private _oldPosition;
  76588. private _diffPosition;
  76589. private _newPosition;
  76590. /** @hidden */
  76591. _localDirection: Vector3;
  76592. /** @hidden */
  76593. _transformedDirection: Vector3;
  76594. /**
  76595. * Instantiates a Free Camera.
  76596. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76597. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76599. * @param name Define the name of the camera in the scene
  76600. * @param position Define the start position of the camera in the scene
  76601. * @param scene Define the scene the camera belongs to
  76602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76603. */
  76604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76605. /**
  76606. * Attached controls to the current camera.
  76607. * @param element Defines the element the controls should be listened from
  76608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76609. */
  76610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76611. /**
  76612. * Detach the current controls from the camera.
  76613. * The camera will stop reacting to inputs.
  76614. * @param element Defines the element to stop listening the inputs from
  76615. */
  76616. detachControl(element: HTMLElement): void;
  76617. private _collisionMask;
  76618. /**
  76619. * Define a collision mask to limit the list of object the camera can collide with
  76620. */
  76621. collisionMask: number;
  76622. /** @hidden */
  76623. _collideWithWorld(displacement: Vector3): void;
  76624. private _onCollisionPositionChange;
  76625. /** @hidden */
  76626. _checkInputs(): void;
  76627. /** @hidden */
  76628. _decideIfNeedsToMove(): boolean;
  76629. /** @hidden */
  76630. _updatePosition(): void;
  76631. /**
  76632. * Destroy the camera and release the current resources hold by it.
  76633. */
  76634. dispose(): void;
  76635. /**
  76636. * Gets the current object class name.
  76637. * @return the class name
  76638. */
  76639. getClassName(): string;
  76640. }
  76641. }
  76642. declare module BABYLON {
  76643. /**
  76644. * Represents a gamepad control stick position
  76645. */
  76646. export class StickValues {
  76647. /**
  76648. * The x component of the control stick
  76649. */
  76650. x: number;
  76651. /**
  76652. * The y component of the control stick
  76653. */
  76654. y: number;
  76655. /**
  76656. * Initializes the gamepad x and y control stick values
  76657. * @param x The x component of the gamepad control stick value
  76658. * @param y The y component of the gamepad control stick value
  76659. */
  76660. constructor(
  76661. /**
  76662. * The x component of the control stick
  76663. */
  76664. x: number,
  76665. /**
  76666. * The y component of the control stick
  76667. */
  76668. y: number);
  76669. }
  76670. /**
  76671. * An interface which manages callbacks for gamepad button changes
  76672. */
  76673. export interface GamepadButtonChanges {
  76674. /**
  76675. * Called when a gamepad has been changed
  76676. */
  76677. changed: boolean;
  76678. /**
  76679. * Called when a gamepad press event has been triggered
  76680. */
  76681. pressChanged: boolean;
  76682. /**
  76683. * Called when a touch event has been triggered
  76684. */
  76685. touchChanged: boolean;
  76686. /**
  76687. * Called when a value has changed
  76688. */
  76689. valueChanged: boolean;
  76690. }
  76691. /**
  76692. * Represents a gamepad
  76693. */
  76694. export class Gamepad {
  76695. /**
  76696. * The id of the gamepad
  76697. */
  76698. id: string;
  76699. /**
  76700. * The index of the gamepad
  76701. */
  76702. index: number;
  76703. /**
  76704. * The browser gamepad
  76705. */
  76706. browserGamepad: any;
  76707. /**
  76708. * Specifies what type of gamepad this represents
  76709. */
  76710. type: number;
  76711. private _leftStick;
  76712. private _rightStick;
  76713. /** @hidden */
  76714. _isConnected: boolean;
  76715. private _leftStickAxisX;
  76716. private _leftStickAxisY;
  76717. private _rightStickAxisX;
  76718. private _rightStickAxisY;
  76719. /**
  76720. * Triggered when the left control stick has been changed
  76721. */
  76722. private _onleftstickchanged;
  76723. /**
  76724. * Triggered when the right control stick has been changed
  76725. */
  76726. private _onrightstickchanged;
  76727. /**
  76728. * Represents a gamepad controller
  76729. */
  76730. static GAMEPAD: number;
  76731. /**
  76732. * Represents a generic controller
  76733. */
  76734. static GENERIC: number;
  76735. /**
  76736. * Represents an XBox controller
  76737. */
  76738. static XBOX: number;
  76739. /**
  76740. * Represents a pose-enabled controller
  76741. */
  76742. static POSE_ENABLED: number;
  76743. /**
  76744. * Represents an Dual Shock controller
  76745. */
  76746. static DUALSHOCK: number;
  76747. /**
  76748. * Specifies whether the left control stick should be Y-inverted
  76749. */
  76750. protected _invertLeftStickY: boolean;
  76751. /**
  76752. * Specifies if the gamepad has been connected
  76753. */
  76754. readonly isConnected: boolean;
  76755. /**
  76756. * Initializes the gamepad
  76757. * @param id The id of the gamepad
  76758. * @param index The index of the gamepad
  76759. * @param browserGamepad The browser gamepad
  76760. * @param leftStickX The x component of the left joystick
  76761. * @param leftStickY The y component of the left joystick
  76762. * @param rightStickX The x component of the right joystick
  76763. * @param rightStickY The y component of the right joystick
  76764. */
  76765. constructor(
  76766. /**
  76767. * The id of the gamepad
  76768. */
  76769. id: string,
  76770. /**
  76771. * The index of the gamepad
  76772. */
  76773. index: number,
  76774. /**
  76775. * The browser gamepad
  76776. */
  76777. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76778. /**
  76779. * Callback triggered when the left joystick has changed
  76780. * @param callback
  76781. */
  76782. onleftstickchanged(callback: (values: StickValues) => void): void;
  76783. /**
  76784. * Callback triggered when the right joystick has changed
  76785. * @param callback
  76786. */
  76787. onrightstickchanged(callback: (values: StickValues) => void): void;
  76788. /**
  76789. * Gets the left joystick
  76790. */
  76791. /**
  76792. * Sets the left joystick values
  76793. */
  76794. leftStick: StickValues;
  76795. /**
  76796. * Gets the right joystick
  76797. */
  76798. /**
  76799. * Sets the right joystick value
  76800. */
  76801. rightStick: StickValues;
  76802. /**
  76803. * Updates the gamepad joystick positions
  76804. */
  76805. update(): void;
  76806. /**
  76807. * Disposes the gamepad
  76808. */
  76809. dispose(): void;
  76810. }
  76811. /**
  76812. * Represents a generic gamepad
  76813. */
  76814. export class GenericPad extends Gamepad {
  76815. private _buttons;
  76816. private _onbuttondown;
  76817. private _onbuttonup;
  76818. /**
  76819. * Observable triggered when a button has been pressed
  76820. */
  76821. onButtonDownObservable: Observable<number>;
  76822. /**
  76823. * Observable triggered when a button has been released
  76824. */
  76825. onButtonUpObservable: Observable<number>;
  76826. /**
  76827. * Callback triggered when a button has been pressed
  76828. * @param callback Called when a button has been pressed
  76829. */
  76830. onbuttondown(callback: (buttonPressed: number) => void): void;
  76831. /**
  76832. * Callback triggered when a button has been released
  76833. * @param callback Called when a button has been released
  76834. */
  76835. onbuttonup(callback: (buttonReleased: number) => void): void;
  76836. /**
  76837. * Initializes the generic gamepad
  76838. * @param id The id of the generic gamepad
  76839. * @param index The index of the generic gamepad
  76840. * @param browserGamepad The browser gamepad
  76841. */
  76842. constructor(id: string, index: number, browserGamepad: any);
  76843. private _setButtonValue;
  76844. /**
  76845. * Updates the generic gamepad
  76846. */
  76847. update(): void;
  76848. /**
  76849. * Disposes the generic gamepad
  76850. */
  76851. dispose(): void;
  76852. }
  76853. }
  76854. declare module BABYLON {
  76855. interface Engine {
  76856. /**
  76857. * Creates a raw texture
  76858. * @param data defines the data to store in the texture
  76859. * @param width defines the width of the texture
  76860. * @param height defines the height of the texture
  76861. * @param format defines the format of the data
  76862. * @param generateMipMaps defines if the engine should generate the mip levels
  76863. * @param invertY defines if data must be stored with Y axis inverted
  76864. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76865. * @param compression defines the compression used (null by default)
  76866. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76867. * @returns the raw texture inside an InternalTexture
  76868. */
  76869. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76870. /**
  76871. * Update a raw texture
  76872. * @param texture defines the texture to update
  76873. * @param data defines the data to store in the texture
  76874. * @param format defines the format of the data
  76875. * @param invertY defines if data must be stored with Y axis inverted
  76876. */
  76877. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76878. /**
  76879. * Update a raw texture
  76880. * @param texture defines the texture to update
  76881. * @param data defines the data to store in the texture
  76882. * @param format defines the format of the data
  76883. * @param invertY defines if data must be stored with Y axis inverted
  76884. * @param compression defines the compression used (null by default)
  76885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76886. */
  76887. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76888. /**
  76889. * Creates a new raw cube texture
  76890. * @param data defines the array of data to use to create each face
  76891. * @param size defines the size of the textures
  76892. * @param format defines the format of the data
  76893. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76894. * @param generateMipMaps defines if the engine should generate the mip levels
  76895. * @param invertY defines if data must be stored with Y axis inverted
  76896. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76897. * @param compression defines the compression used (null by default)
  76898. * @returns the cube texture as an InternalTexture
  76899. */
  76900. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76901. /**
  76902. * Update a raw cube texture
  76903. * @param texture defines the texture to udpdate
  76904. * @param data defines the data to store
  76905. * @param format defines the data format
  76906. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76907. * @param invertY defines if data must be stored with Y axis inverted
  76908. */
  76909. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76910. /**
  76911. * Update a raw cube texture
  76912. * @param texture defines the texture to udpdate
  76913. * @param data defines the data to store
  76914. * @param format defines the data format
  76915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76916. * @param invertY defines if data must be stored with Y axis inverted
  76917. * @param compression defines the compression used (null by default)
  76918. */
  76919. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76920. /**
  76921. * Update a raw cube texture
  76922. * @param texture defines the texture to udpdate
  76923. * @param data defines the data to store
  76924. * @param format defines the data format
  76925. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76926. * @param invertY defines if data must be stored with Y axis inverted
  76927. * @param compression defines the compression used (null by default)
  76928. * @param level defines which level of the texture to update
  76929. */
  76930. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76931. /**
  76932. * Creates a new raw cube texture from a specified url
  76933. * @param url defines the url where the data is located
  76934. * @param scene defines the current scene
  76935. * @param size defines the size of the textures
  76936. * @param format defines the format of the data
  76937. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76938. * @param noMipmap defines if the engine should avoid generating the mip levels
  76939. * @param callback defines a callback used to extract texture data from loaded data
  76940. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76941. * @param onLoad defines a callback called when texture is loaded
  76942. * @param onError defines a callback called if there is an error
  76943. * @returns the cube texture as an InternalTexture
  76944. */
  76945. 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;
  76946. /**
  76947. * Creates a new raw cube texture from a specified url
  76948. * @param url defines the url where the data is located
  76949. * @param scene defines the current scene
  76950. * @param size defines the size of the textures
  76951. * @param format defines the format of the data
  76952. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76953. * @param noMipmap defines if the engine should avoid generating the mip levels
  76954. * @param callback defines a callback used to extract texture data from loaded data
  76955. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76956. * @param onLoad defines a callback called when texture is loaded
  76957. * @param onError defines a callback called if there is an error
  76958. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76959. * @param invertY defines if data must be stored with Y axis inverted
  76960. * @returns the cube texture as an InternalTexture
  76961. */
  76962. 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;
  76963. /**
  76964. * Creates a new raw 3D texture
  76965. * @param data defines the data used to create the texture
  76966. * @param width defines the width of the texture
  76967. * @param height defines the height of the texture
  76968. * @param depth defines the depth of the texture
  76969. * @param format defines the format of the texture
  76970. * @param generateMipMaps defines if the engine must generate mip levels
  76971. * @param invertY defines if data must be stored with Y axis inverted
  76972. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76973. * @param compression defines the compressed used (can be null)
  76974. * @param textureType defines the compressed used (can be null)
  76975. * @returns a new raw 3D texture (stored in an InternalTexture)
  76976. */
  76977. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76978. /**
  76979. * Update a raw 3D texture
  76980. * @param texture defines the texture to update
  76981. * @param data defines the data to store
  76982. * @param format defines the data format
  76983. * @param invertY defines if data must be stored with Y axis inverted
  76984. */
  76985. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76986. /**
  76987. * Update a raw 3D texture
  76988. * @param texture defines the texture to update
  76989. * @param data defines the data to store
  76990. * @param format defines the data format
  76991. * @param invertY defines if data must be stored with Y axis inverted
  76992. * @param compression defines the used compression (can be null)
  76993. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76994. */
  76995. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76996. }
  76997. }
  76998. declare module BABYLON {
  76999. /**
  77000. * Raw texture can help creating a texture directly from an array of data.
  77001. * This can be super useful if you either get the data from an uncompressed source or
  77002. * if you wish to create your texture pixel by pixel.
  77003. */
  77004. export class RawTexture extends Texture {
  77005. /**
  77006. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77007. */
  77008. format: number;
  77009. private _engine;
  77010. /**
  77011. * Instantiates a new RawTexture.
  77012. * Raw texture can help creating a texture directly from an array of data.
  77013. * This can be super useful if you either get the data from an uncompressed source or
  77014. * if you wish to create your texture pixel by pixel.
  77015. * @param data define the array of data to use to create the texture
  77016. * @param width define the width of the texture
  77017. * @param height define the height of the texture
  77018. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77019. * @param scene define the scene the texture belongs to
  77020. * @param generateMipMaps define whether mip maps should be generated or not
  77021. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77022. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77023. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77024. */
  77025. constructor(data: ArrayBufferView, width: number, height: number,
  77026. /**
  77027. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77028. */
  77029. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77030. /**
  77031. * Updates the texture underlying data.
  77032. * @param data Define the new data of the texture
  77033. */
  77034. update(data: ArrayBufferView): void;
  77035. /**
  77036. * Creates a luminance texture from some data.
  77037. * @param data Define the texture data
  77038. * @param width Define the width of the texture
  77039. * @param height Define the height of the texture
  77040. * @param scene Define the scene the texture belongs to
  77041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77044. * @returns the luminance texture
  77045. */
  77046. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77047. /**
  77048. * Creates a luminance alpha texture from some data.
  77049. * @param data Define the texture data
  77050. * @param width Define the width of the texture
  77051. * @param height Define the height of the texture
  77052. * @param scene Define the scene the texture belongs to
  77053. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77054. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77055. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77056. * @returns the luminance alpha texture
  77057. */
  77058. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77059. /**
  77060. * Creates an alpha texture from some data.
  77061. * @param data Define the texture data
  77062. * @param width Define the width of the texture
  77063. * @param height Define the height of the texture
  77064. * @param scene Define the scene the texture belongs to
  77065. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77066. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77067. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77068. * @returns the alpha texture
  77069. */
  77070. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77071. /**
  77072. * Creates a RGB texture from some data.
  77073. * @param data Define the texture data
  77074. * @param width Define the width of the texture
  77075. * @param height Define the height of the texture
  77076. * @param scene Define the scene the texture belongs to
  77077. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77078. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77079. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77080. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77081. * @returns the RGB alpha texture
  77082. */
  77083. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77084. /**
  77085. * Creates a RGBA texture from some data.
  77086. * @param data Define the texture data
  77087. * @param width Define the width of the texture
  77088. * @param height Define the height of the texture
  77089. * @param scene Define the scene the texture belongs to
  77090. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77091. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77092. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77093. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77094. * @returns the RGBA texture
  77095. */
  77096. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77097. /**
  77098. * Creates a R texture from some data.
  77099. * @param data Define the texture data
  77100. * @param width Define the width of the texture
  77101. * @param height Define the height of the texture
  77102. * @param scene Define the scene the texture belongs to
  77103. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77104. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77105. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77106. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77107. * @returns the R texture
  77108. */
  77109. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77110. }
  77111. }
  77112. declare module BABYLON {
  77113. /**
  77114. * Interface for the size containing width and height
  77115. */
  77116. export interface ISize {
  77117. /**
  77118. * Width
  77119. */
  77120. width: number;
  77121. /**
  77122. * Heighht
  77123. */
  77124. height: number;
  77125. }
  77126. /**
  77127. * Size containing widht and height
  77128. */
  77129. export class Size implements ISize {
  77130. /**
  77131. * Width
  77132. */
  77133. width: number;
  77134. /**
  77135. * Height
  77136. */
  77137. height: number;
  77138. /**
  77139. * Creates a Size object from the given width and height (floats).
  77140. * @param width width of the new size
  77141. * @param height height of the new size
  77142. */
  77143. constructor(width: number, height: number);
  77144. /**
  77145. * Returns a string with the Size width and height
  77146. * @returns a string with the Size width and height
  77147. */
  77148. toString(): string;
  77149. /**
  77150. * "Size"
  77151. * @returns the string "Size"
  77152. */
  77153. getClassName(): string;
  77154. /**
  77155. * Returns the Size hash code.
  77156. * @returns a hash code for a unique width and height
  77157. */
  77158. getHashCode(): number;
  77159. /**
  77160. * Updates the current size from the given one.
  77161. * @param src the given size
  77162. */
  77163. copyFrom(src: Size): void;
  77164. /**
  77165. * Updates in place the current Size from the given floats.
  77166. * @param width width of the new size
  77167. * @param height height of the new size
  77168. * @returns the updated Size.
  77169. */
  77170. copyFromFloats(width: number, height: number): Size;
  77171. /**
  77172. * Updates in place the current Size from the given floats.
  77173. * @param width width to set
  77174. * @param height height to set
  77175. * @returns the updated Size.
  77176. */
  77177. set(width: number, height: number): Size;
  77178. /**
  77179. * Multiplies the width and height by numbers
  77180. * @param w factor to multiple the width by
  77181. * @param h factor to multiple the height by
  77182. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77183. */
  77184. multiplyByFloats(w: number, h: number): Size;
  77185. /**
  77186. * Clones the size
  77187. * @returns a new Size copied from the given one.
  77188. */
  77189. clone(): Size;
  77190. /**
  77191. * True if the current Size and the given one width and height are strictly equal.
  77192. * @param other the other size to compare against
  77193. * @returns True if the current Size and the given one width and height are strictly equal.
  77194. */
  77195. equals(other: Size): boolean;
  77196. /**
  77197. * The surface of the Size : width * height (float).
  77198. */
  77199. readonly surface: number;
  77200. /**
  77201. * Create a new size of zero
  77202. * @returns a new Size set to (0.0, 0.0)
  77203. */
  77204. static Zero(): Size;
  77205. /**
  77206. * Sums the width and height of two sizes
  77207. * @param otherSize size to add to this size
  77208. * @returns a new Size set as the addition result of the current Size and the given one.
  77209. */
  77210. add(otherSize: Size): Size;
  77211. /**
  77212. * Subtracts the width and height of two
  77213. * @param otherSize size to subtract to this size
  77214. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77215. */
  77216. subtract(otherSize: Size): Size;
  77217. /**
  77218. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77219. * @param start starting size to lerp between
  77220. * @param end end size to lerp between
  77221. * @param amount amount to lerp between the start and end values
  77222. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77223. */
  77224. static Lerp(start: Size, end: Size, amount: number): Size;
  77225. }
  77226. }
  77227. declare module BABYLON {
  77228. /**
  77229. * Defines a runtime animation
  77230. */
  77231. export class RuntimeAnimation {
  77232. private _events;
  77233. /**
  77234. * The current frame of the runtime animation
  77235. */
  77236. private _currentFrame;
  77237. /**
  77238. * The animation used by the runtime animation
  77239. */
  77240. private _animation;
  77241. /**
  77242. * The target of the runtime animation
  77243. */
  77244. private _target;
  77245. /**
  77246. * The initiating animatable
  77247. */
  77248. private _host;
  77249. /**
  77250. * The original value of the runtime animation
  77251. */
  77252. private _originalValue;
  77253. /**
  77254. * The original blend value of the runtime animation
  77255. */
  77256. private _originalBlendValue;
  77257. /**
  77258. * The offsets cache of the runtime animation
  77259. */
  77260. private _offsetsCache;
  77261. /**
  77262. * The high limits cache of the runtime animation
  77263. */
  77264. private _highLimitsCache;
  77265. /**
  77266. * Specifies if the runtime animation has been stopped
  77267. */
  77268. private _stopped;
  77269. /**
  77270. * The blending factor of the runtime animation
  77271. */
  77272. private _blendingFactor;
  77273. /**
  77274. * The BabylonJS scene
  77275. */
  77276. private _scene;
  77277. /**
  77278. * The current value of the runtime animation
  77279. */
  77280. private _currentValue;
  77281. /** @hidden */
  77282. _animationState: _IAnimationState;
  77283. /**
  77284. * The active target of the runtime animation
  77285. */
  77286. private _activeTargets;
  77287. private _currentActiveTarget;
  77288. private _directTarget;
  77289. /**
  77290. * The target path of the runtime animation
  77291. */
  77292. private _targetPath;
  77293. /**
  77294. * The weight of the runtime animation
  77295. */
  77296. private _weight;
  77297. /**
  77298. * The ratio offset of the runtime animation
  77299. */
  77300. private _ratioOffset;
  77301. /**
  77302. * The previous delay of the runtime animation
  77303. */
  77304. private _previousDelay;
  77305. /**
  77306. * The previous ratio of the runtime animation
  77307. */
  77308. private _previousRatio;
  77309. private _enableBlending;
  77310. private _keys;
  77311. private _minFrame;
  77312. private _maxFrame;
  77313. private _minValue;
  77314. private _maxValue;
  77315. private _targetIsArray;
  77316. /**
  77317. * Gets the current frame of the runtime animation
  77318. */
  77319. readonly currentFrame: number;
  77320. /**
  77321. * Gets the weight of the runtime animation
  77322. */
  77323. readonly weight: number;
  77324. /**
  77325. * Gets the current value of the runtime animation
  77326. */
  77327. readonly currentValue: any;
  77328. /**
  77329. * Gets the target path of the runtime animation
  77330. */
  77331. readonly targetPath: string;
  77332. /**
  77333. * Gets the actual target of the runtime animation
  77334. */
  77335. readonly target: any;
  77336. /** @hidden */
  77337. _onLoop: () => void;
  77338. /**
  77339. * Create a new RuntimeAnimation object
  77340. * @param target defines the target of the animation
  77341. * @param animation defines the source animation object
  77342. * @param scene defines the hosting scene
  77343. * @param host defines the initiating Animatable
  77344. */
  77345. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77346. private _preparePath;
  77347. /**
  77348. * Gets the animation from the runtime animation
  77349. */
  77350. readonly animation: Animation;
  77351. /**
  77352. * Resets the runtime animation to the beginning
  77353. * @param restoreOriginal defines whether to restore the target property to the original value
  77354. */
  77355. reset(restoreOriginal?: boolean): void;
  77356. /**
  77357. * Specifies if the runtime animation is stopped
  77358. * @returns Boolean specifying if the runtime animation is stopped
  77359. */
  77360. isStopped(): boolean;
  77361. /**
  77362. * Disposes of the runtime animation
  77363. */
  77364. dispose(): void;
  77365. /**
  77366. * Apply the interpolated value to the target
  77367. * @param currentValue defines the value computed by the animation
  77368. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77369. */
  77370. setValue(currentValue: any, weight: number): void;
  77371. private _getOriginalValues;
  77372. private _setValue;
  77373. /**
  77374. * Gets the loop pmode of the runtime animation
  77375. * @returns Loop Mode
  77376. */
  77377. private _getCorrectLoopMode;
  77378. /**
  77379. * Move the current animation to a given frame
  77380. * @param frame defines the frame to move to
  77381. */
  77382. goToFrame(frame: number): void;
  77383. /**
  77384. * @hidden Internal use only
  77385. */
  77386. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77387. /**
  77388. * Execute the current animation
  77389. * @param delay defines the delay to add to the current frame
  77390. * @param from defines the lower bound of the animation range
  77391. * @param to defines the upper bound of the animation range
  77392. * @param loop defines if the current animation must loop
  77393. * @param speedRatio defines the current speed ratio
  77394. * @param weight defines the weight of the animation (default is -1 so no weight)
  77395. * @param onLoop optional callback called when animation loops
  77396. * @returns a boolean indicating if the animation is running
  77397. */
  77398. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77399. }
  77400. }
  77401. declare module BABYLON {
  77402. /**
  77403. * Class used to store an actual running animation
  77404. */
  77405. export class Animatable {
  77406. /** defines the target object */
  77407. target: any;
  77408. /** defines the starting frame number (default is 0) */
  77409. fromFrame: number;
  77410. /** defines the ending frame number (default is 100) */
  77411. toFrame: number;
  77412. /** defines if the animation must loop (default is false) */
  77413. loopAnimation: boolean;
  77414. /** defines a callback to call when animation ends if it is not looping */
  77415. onAnimationEnd?: (() => void) | null | undefined;
  77416. /** defines a callback to call when animation loops */
  77417. onAnimationLoop?: (() => void) | null | undefined;
  77418. private _localDelayOffset;
  77419. private _pausedDelay;
  77420. private _runtimeAnimations;
  77421. private _paused;
  77422. private _scene;
  77423. private _speedRatio;
  77424. private _weight;
  77425. private _syncRoot;
  77426. /**
  77427. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77428. * This will only apply for non looping animation (default is true)
  77429. */
  77430. disposeOnEnd: boolean;
  77431. /**
  77432. * Gets a boolean indicating if the animation has started
  77433. */
  77434. animationStarted: boolean;
  77435. /**
  77436. * Observer raised when the animation ends
  77437. */
  77438. onAnimationEndObservable: Observable<Animatable>;
  77439. /**
  77440. * Observer raised when the animation loops
  77441. */
  77442. onAnimationLoopObservable: Observable<Animatable>;
  77443. /**
  77444. * Gets the root Animatable used to synchronize and normalize animations
  77445. */
  77446. readonly syncRoot: Nullable<Animatable>;
  77447. /**
  77448. * Gets the current frame of the first RuntimeAnimation
  77449. * Used to synchronize Animatables
  77450. */
  77451. readonly masterFrame: number;
  77452. /**
  77453. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77454. */
  77455. weight: number;
  77456. /**
  77457. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77458. */
  77459. speedRatio: number;
  77460. /**
  77461. * Creates a new Animatable
  77462. * @param scene defines the hosting scene
  77463. * @param target defines the target object
  77464. * @param fromFrame defines the starting frame number (default is 0)
  77465. * @param toFrame defines the ending frame number (default is 100)
  77466. * @param loopAnimation defines if the animation must loop (default is false)
  77467. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77468. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77469. * @param animations defines a group of animation to add to the new Animatable
  77470. * @param onAnimationLoop defines a callback to call when animation loops
  77471. */
  77472. constructor(scene: Scene,
  77473. /** defines the target object */
  77474. target: any,
  77475. /** defines the starting frame number (default is 0) */
  77476. fromFrame?: number,
  77477. /** defines the ending frame number (default is 100) */
  77478. toFrame?: number,
  77479. /** defines if the animation must loop (default is false) */
  77480. loopAnimation?: boolean, speedRatio?: number,
  77481. /** defines a callback to call when animation ends if it is not looping */
  77482. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77483. /** defines a callback to call when animation loops */
  77484. onAnimationLoop?: (() => void) | null | undefined);
  77485. /**
  77486. * Synchronize and normalize current Animatable with a source Animatable
  77487. * This is useful when using animation weights and when animations are not of the same length
  77488. * @param root defines the root Animatable to synchronize with
  77489. * @returns the current Animatable
  77490. */
  77491. syncWith(root: Animatable): Animatable;
  77492. /**
  77493. * Gets the list of runtime animations
  77494. * @returns an array of RuntimeAnimation
  77495. */
  77496. getAnimations(): RuntimeAnimation[];
  77497. /**
  77498. * Adds more animations to the current animatable
  77499. * @param target defines the target of the animations
  77500. * @param animations defines the new animations to add
  77501. */
  77502. appendAnimations(target: any, animations: Animation[]): void;
  77503. /**
  77504. * Gets the source animation for a specific property
  77505. * @param property defines the propertyu to look for
  77506. * @returns null or the source animation for the given property
  77507. */
  77508. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77509. /**
  77510. * Gets the runtime animation for a specific property
  77511. * @param property defines the propertyu to look for
  77512. * @returns null or the runtime animation for the given property
  77513. */
  77514. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77515. /**
  77516. * Resets the animatable to its original state
  77517. */
  77518. reset(): void;
  77519. /**
  77520. * Allows the animatable to blend with current running animations
  77521. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77522. * @param blendingSpeed defines the blending speed to use
  77523. */
  77524. enableBlending(blendingSpeed: number): void;
  77525. /**
  77526. * Disable animation blending
  77527. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77528. */
  77529. disableBlending(): void;
  77530. /**
  77531. * Jump directly to a given frame
  77532. * @param frame defines the frame to jump to
  77533. */
  77534. goToFrame(frame: number): void;
  77535. /**
  77536. * Pause the animation
  77537. */
  77538. pause(): void;
  77539. /**
  77540. * Restart the animation
  77541. */
  77542. restart(): void;
  77543. private _raiseOnAnimationEnd;
  77544. /**
  77545. * Stop and delete the current animation
  77546. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77547. * @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)
  77548. */
  77549. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77550. /**
  77551. * Wait asynchronously for the animation to end
  77552. * @returns a promise which will be fullfilled when the animation ends
  77553. */
  77554. waitAsync(): Promise<Animatable>;
  77555. /** @hidden */
  77556. _animate(delay: number): boolean;
  77557. }
  77558. interface Scene {
  77559. /** @hidden */
  77560. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77561. /** @hidden */
  77562. _processLateAnimationBindingsForMatrices(holder: {
  77563. totalWeight: number;
  77564. animations: RuntimeAnimation[];
  77565. originalValue: Matrix;
  77566. }): any;
  77567. /** @hidden */
  77568. _processLateAnimationBindingsForQuaternions(holder: {
  77569. totalWeight: number;
  77570. animations: RuntimeAnimation[];
  77571. originalValue: Quaternion;
  77572. }, refQuaternion: Quaternion): Quaternion;
  77573. /** @hidden */
  77574. _processLateAnimationBindings(): void;
  77575. /**
  77576. * Will start the animation sequence of a given target
  77577. * @param target defines the target
  77578. * @param from defines from which frame should animation start
  77579. * @param to defines until which frame should animation run.
  77580. * @param weight defines the weight to apply to the animation (1.0 by default)
  77581. * @param loop defines if the animation loops
  77582. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77583. * @param onAnimationEnd defines the function to be executed when the animation ends
  77584. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77585. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77586. * @param onAnimationLoop defines the callback to call when an animation loops
  77587. * @returns the animatable object created for this animation
  77588. */
  77589. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77590. /**
  77591. * Will start the animation sequence of a given target
  77592. * @param target defines the target
  77593. * @param from defines from which frame should animation start
  77594. * @param to defines until which frame should animation run.
  77595. * @param loop defines if the animation loops
  77596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77597. * @param onAnimationEnd defines the function to be executed when the animation ends
  77598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77599. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77600. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77601. * @param onAnimationLoop defines the callback to call when an animation loops
  77602. * @returns the animatable object created for this animation
  77603. */
  77604. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77605. /**
  77606. * Will start the animation sequence of a given target and its hierarchy
  77607. * @param target defines the target
  77608. * @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.
  77609. * @param from defines from which frame should animation start
  77610. * @param to defines until which frame should animation run.
  77611. * @param loop defines if the animation loops
  77612. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77613. * @param onAnimationEnd defines the function to be executed when the animation ends
  77614. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77615. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77616. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77617. * @param onAnimationLoop defines the callback to call when an animation loops
  77618. * @returns the list of created animatables
  77619. */
  77620. 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[];
  77621. /**
  77622. * Begin a new animation on a given node
  77623. * @param target defines the target where the animation will take place
  77624. * @param animations defines the list of animations to start
  77625. * @param from defines the initial value
  77626. * @param to defines the final value
  77627. * @param loop defines if you want animation to loop (off by default)
  77628. * @param speedRatio defines the speed ratio to apply to all animations
  77629. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77630. * @param onAnimationLoop defines the callback to call when an animation loops
  77631. * @returns the list of created animatables
  77632. */
  77633. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77634. /**
  77635. * Begin a new animation on a given node and its hierarchy
  77636. * @param target defines the root node where the animation will take place
  77637. * @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.
  77638. * @param animations defines the list of animations to start
  77639. * @param from defines the initial value
  77640. * @param to defines the final value
  77641. * @param loop defines if you want animation to loop (off by default)
  77642. * @param speedRatio defines the speed ratio to apply to all animations
  77643. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77644. * @param onAnimationLoop defines the callback to call when an animation loops
  77645. * @returns the list of animatables created for all nodes
  77646. */
  77647. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77648. /**
  77649. * Gets the animatable associated with a specific target
  77650. * @param target defines the target of the animatable
  77651. * @returns the required animatable if found
  77652. */
  77653. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77654. /**
  77655. * Gets all animatables associated with a given target
  77656. * @param target defines the target to look animatables for
  77657. * @returns an array of Animatables
  77658. */
  77659. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77660. /**
  77661. * Stops and removes all animations that have been applied to the scene
  77662. */
  77663. stopAllAnimations(): void;
  77664. }
  77665. interface Bone {
  77666. /**
  77667. * Copy an animation range from another bone
  77668. * @param source defines the source bone
  77669. * @param rangeName defines the range name to copy
  77670. * @param frameOffset defines the frame offset
  77671. * @param rescaleAsRequired defines if rescaling must be applied if required
  77672. * @param skelDimensionsRatio defines the scaling ratio
  77673. * @returns true if operation was successful
  77674. */
  77675. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77676. }
  77677. }
  77678. declare module BABYLON {
  77679. /**
  77680. * Class used to override all child animations of a given target
  77681. */
  77682. export class AnimationPropertiesOverride {
  77683. /**
  77684. * Gets or sets a value indicating if animation blending must be used
  77685. */
  77686. enableBlending: boolean;
  77687. /**
  77688. * Gets or sets the blending speed to use when enableBlending is true
  77689. */
  77690. blendingSpeed: number;
  77691. /**
  77692. * Gets or sets the default loop mode to use
  77693. */
  77694. loopMode: number;
  77695. }
  77696. }
  77697. declare module BABYLON {
  77698. /**
  77699. * Class used to handle skinning animations
  77700. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77701. */
  77702. export class Skeleton implements IAnimatable {
  77703. /** defines the skeleton name */
  77704. name: string;
  77705. /** defines the skeleton Id */
  77706. id: string;
  77707. /**
  77708. * Defines the list of child bones
  77709. */
  77710. bones: Bone[];
  77711. /**
  77712. * Defines an estimate of the dimension of the skeleton at rest
  77713. */
  77714. dimensionsAtRest: Vector3;
  77715. /**
  77716. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77717. */
  77718. needInitialSkinMatrix: boolean;
  77719. /**
  77720. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77721. */
  77722. overrideMesh: Nullable<AbstractMesh>;
  77723. /**
  77724. * Gets the list of animations attached to this skeleton
  77725. */
  77726. animations: Array<Animation>;
  77727. private _scene;
  77728. private _isDirty;
  77729. private _transformMatrices;
  77730. private _transformMatrixTexture;
  77731. private _meshesWithPoseMatrix;
  77732. private _animatables;
  77733. private _identity;
  77734. private _synchronizedWithMesh;
  77735. private _ranges;
  77736. private _lastAbsoluteTransformsUpdateId;
  77737. private _canUseTextureForBones;
  77738. private _uniqueId;
  77739. /** @hidden */
  77740. _numBonesWithLinkedTransformNode: number;
  77741. /** @hidden */
  77742. _hasWaitingData: Nullable<boolean>;
  77743. /**
  77744. * Specifies if the skeleton should be serialized
  77745. */
  77746. doNotSerialize: boolean;
  77747. private _useTextureToStoreBoneMatrices;
  77748. /**
  77749. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77750. * Please note that this option is not available if the hardware does not support it
  77751. */
  77752. useTextureToStoreBoneMatrices: boolean;
  77753. private _animationPropertiesOverride;
  77754. /**
  77755. * Gets or sets the animation properties override
  77756. */
  77757. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77758. /**
  77759. * List of inspectable custom properties (used by the Inspector)
  77760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77761. */
  77762. inspectableCustomProperties: IInspectable[];
  77763. /**
  77764. * An observable triggered before computing the skeleton's matrices
  77765. */
  77766. onBeforeComputeObservable: Observable<Skeleton>;
  77767. /**
  77768. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77769. */
  77770. readonly isUsingTextureForMatrices: boolean;
  77771. /**
  77772. * Gets the unique ID of this skeleton
  77773. */
  77774. readonly uniqueId: number;
  77775. /**
  77776. * Creates a new skeleton
  77777. * @param name defines the skeleton name
  77778. * @param id defines the skeleton Id
  77779. * @param scene defines the hosting scene
  77780. */
  77781. constructor(
  77782. /** defines the skeleton name */
  77783. name: string,
  77784. /** defines the skeleton Id */
  77785. id: string, scene: Scene);
  77786. /**
  77787. * Gets the current object class name.
  77788. * @return the class name
  77789. */
  77790. getClassName(): string;
  77791. /**
  77792. * Returns an array containing the root bones
  77793. * @returns an array containing the root bones
  77794. */
  77795. getChildren(): Array<Bone>;
  77796. /**
  77797. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77798. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77799. * @returns a Float32Array containing matrices data
  77800. */
  77801. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77802. /**
  77803. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77804. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77805. * @returns a raw texture containing the data
  77806. */
  77807. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77808. /**
  77809. * Gets the current hosting scene
  77810. * @returns a scene object
  77811. */
  77812. getScene(): Scene;
  77813. /**
  77814. * Gets a string representing the current skeleton data
  77815. * @param fullDetails defines a boolean indicating if we want a verbose version
  77816. * @returns a string representing the current skeleton data
  77817. */
  77818. toString(fullDetails?: boolean): string;
  77819. /**
  77820. * Get bone's index searching by name
  77821. * @param name defines bone's name to search for
  77822. * @return the indice of the bone. Returns -1 if not found
  77823. */
  77824. getBoneIndexByName(name: string): number;
  77825. /**
  77826. * Creater a new animation range
  77827. * @param name defines the name of the range
  77828. * @param from defines the start key
  77829. * @param to defines the end key
  77830. */
  77831. createAnimationRange(name: string, from: number, to: number): void;
  77832. /**
  77833. * Delete a specific animation range
  77834. * @param name defines the name of the range
  77835. * @param deleteFrames defines if frames must be removed as well
  77836. */
  77837. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77838. /**
  77839. * Gets a specific animation range
  77840. * @param name defines the name of the range to look for
  77841. * @returns the requested animation range or null if not found
  77842. */
  77843. getAnimationRange(name: string): Nullable<AnimationRange>;
  77844. /**
  77845. * Gets the list of all animation ranges defined on this skeleton
  77846. * @returns an array
  77847. */
  77848. getAnimationRanges(): Nullable<AnimationRange>[];
  77849. /**
  77850. * Copy animation range from a source skeleton.
  77851. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77852. * @param source defines the source skeleton
  77853. * @param name defines the name of the range to copy
  77854. * @param rescaleAsRequired defines if rescaling must be applied if required
  77855. * @returns true if operation was successful
  77856. */
  77857. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77858. /**
  77859. * Forces the skeleton to go to rest pose
  77860. */
  77861. returnToRest(): void;
  77862. private _getHighestAnimationFrame;
  77863. /**
  77864. * Begin a specific animation range
  77865. * @param name defines the name of the range to start
  77866. * @param loop defines if looping must be turned on (false by default)
  77867. * @param speedRatio defines the speed ratio to apply (1 by default)
  77868. * @param onAnimationEnd defines a callback which will be called when animation will end
  77869. * @returns a new animatable
  77870. */
  77871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77872. /** @hidden */
  77873. _markAsDirty(): void;
  77874. /** @hidden */
  77875. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77876. /** @hidden */
  77877. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77878. private _computeTransformMatrices;
  77879. /**
  77880. * Build all resources required to render a skeleton
  77881. */
  77882. prepare(): void;
  77883. /**
  77884. * Gets the list of animatables currently running for this skeleton
  77885. * @returns an array of animatables
  77886. */
  77887. getAnimatables(): IAnimatable[];
  77888. /**
  77889. * Clone the current skeleton
  77890. * @param name defines the name of the new skeleton
  77891. * @param id defines the id of the new skeleton
  77892. * @returns the new skeleton
  77893. */
  77894. clone(name: string, id: string): Skeleton;
  77895. /**
  77896. * Enable animation blending for this skeleton
  77897. * @param blendingSpeed defines the blending speed to apply
  77898. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77899. */
  77900. enableBlending(blendingSpeed?: number): void;
  77901. /**
  77902. * Releases all resources associated with the current skeleton
  77903. */
  77904. dispose(): void;
  77905. /**
  77906. * Serialize the skeleton in a JSON object
  77907. * @returns a JSON object
  77908. */
  77909. serialize(): any;
  77910. /**
  77911. * Creates a new skeleton from serialized data
  77912. * @param parsedSkeleton defines the serialized data
  77913. * @param scene defines the hosting scene
  77914. * @returns a new skeleton
  77915. */
  77916. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77917. /**
  77918. * Compute all node absolute transforms
  77919. * @param forceUpdate defines if computation must be done even if cache is up to date
  77920. */
  77921. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77922. /**
  77923. * Gets the root pose matrix
  77924. * @returns a matrix
  77925. */
  77926. getPoseMatrix(): Nullable<Matrix>;
  77927. /**
  77928. * Sorts bones per internal index
  77929. */
  77930. sortBones(): void;
  77931. private _sortBones;
  77932. }
  77933. }
  77934. declare module BABYLON {
  77935. /**
  77936. * Class used to store bone information
  77937. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77938. */
  77939. export class Bone extends Node {
  77940. /**
  77941. * defines the bone name
  77942. */
  77943. name: string;
  77944. private static _tmpVecs;
  77945. private static _tmpQuat;
  77946. private static _tmpMats;
  77947. /**
  77948. * Gets the list of child bones
  77949. */
  77950. children: Bone[];
  77951. /** Gets the animations associated with this bone */
  77952. animations: Animation[];
  77953. /**
  77954. * Gets or sets bone length
  77955. */
  77956. length: number;
  77957. /**
  77958. * @hidden Internal only
  77959. * Set this value to map this bone to a different index in the transform matrices
  77960. * Set this value to -1 to exclude the bone from the transform matrices
  77961. */
  77962. _index: Nullable<number>;
  77963. private _skeleton;
  77964. private _localMatrix;
  77965. private _restPose;
  77966. private _baseMatrix;
  77967. private _absoluteTransform;
  77968. private _invertedAbsoluteTransform;
  77969. private _parent;
  77970. private _scalingDeterminant;
  77971. private _worldTransform;
  77972. private _localScaling;
  77973. private _localRotation;
  77974. private _localPosition;
  77975. private _needToDecompose;
  77976. private _needToCompose;
  77977. /** @hidden */
  77978. _linkedTransformNode: Nullable<TransformNode>;
  77979. /** @hidden */
  77980. _waitingTransformNodeId: Nullable<string>;
  77981. /** @hidden */
  77982. /** @hidden */
  77983. _matrix: Matrix;
  77984. /**
  77985. * Create a new bone
  77986. * @param name defines the bone name
  77987. * @param skeleton defines the parent skeleton
  77988. * @param parentBone defines the parent (can be null if the bone is the root)
  77989. * @param localMatrix defines the local matrix
  77990. * @param restPose defines the rest pose matrix
  77991. * @param baseMatrix defines the base matrix
  77992. * @param index defines index of the bone in the hiearchy
  77993. */
  77994. constructor(
  77995. /**
  77996. * defines the bone name
  77997. */
  77998. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77999. /**
  78000. * Gets the current object class name.
  78001. * @return the class name
  78002. */
  78003. getClassName(): string;
  78004. /**
  78005. * Gets the parent skeleton
  78006. * @returns a skeleton
  78007. */
  78008. getSkeleton(): Skeleton;
  78009. /**
  78010. * Gets parent bone
  78011. * @returns a bone or null if the bone is the root of the bone hierarchy
  78012. */
  78013. getParent(): Nullable<Bone>;
  78014. /**
  78015. * Returns an array containing the root bones
  78016. * @returns an array containing the root bones
  78017. */
  78018. getChildren(): Array<Bone>;
  78019. /**
  78020. * Sets the parent bone
  78021. * @param parent defines the parent (can be null if the bone is the root)
  78022. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78023. */
  78024. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78025. /**
  78026. * Gets the local matrix
  78027. * @returns a matrix
  78028. */
  78029. getLocalMatrix(): Matrix;
  78030. /**
  78031. * Gets the base matrix (initial matrix which remains unchanged)
  78032. * @returns a matrix
  78033. */
  78034. getBaseMatrix(): Matrix;
  78035. /**
  78036. * Gets the rest pose matrix
  78037. * @returns a matrix
  78038. */
  78039. getRestPose(): Matrix;
  78040. /**
  78041. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78042. */
  78043. getWorldMatrix(): Matrix;
  78044. /**
  78045. * Sets the local matrix to rest pose matrix
  78046. */
  78047. returnToRest(): void;
  78048. /**
  78049. * Gets the inverse of the absolute transform matrix.
  78050. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78051. * @returns a matrix
  78052. */
  78053. getInvertedAbsoluteTransform(): Matrix;
  78054. /**
  78055. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78056. * @returns a matrix
  78057. */
  78058. getAbsoluteTransform(): Matrix;
  78059. /**
  78060. * Links with the given transform node.
  78061. * The local matrix of this bone is copied from the transform node every frame.
  78062. * @param transformNode defines the transform node to link to
  78063. */
  78064. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78065. /**
  78066. * Gets the node used to drive the bone's transformation
  78067. * @returns a transform node or null
  78068. */
  78069. getTransformNode(): Nullable<TransformNode>;
  78070. /** Gets or sets current position (in local space) */
  78071. position: Vector3;
  78072. /** Gets or sets current rotation (in local space) */
  78073. rotation: Vector3;
  78074. /** Gets or sets current rotation quaternion (in local space) */
  78075. rotationQuaternion: Quaternion;
  78076. /** Gets or sets current scaling (in local space) */
  78077. scaling: Vector3;
  78078. /**
  78079. * Gets the animation properties override
  78080. */
  78081. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78082. private _decompose;
  78083. private _compose;
  78084. /**
  78085. * Update the base and local matrices
  78086. * @param matrix defines the new base or local matrix
  78087. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78088. * @param updateLocalMatrix defines if the local matrix should be updated
  78089. */
  78090. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78091. /** @hidden */
  78092. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78093. /**
  78094. * Flag the bone as dirty (Forcing it to update everything)
  78095. */
  78096. markAsDirty(): void;
  78097. /** @hidden */
  78098. _markAsDirtyAndCompose(): void;
  78099. private _markAsDirtyAndDecompose;
  78100. /**
  78101. * Translate the bone in local or world space
  78102. * @param vec The amount to translate the bone
  78103. * @param space The space that the translation is in
  78104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78105. */
  78106. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78107. /**
  78108. * Set the postion of the bone in local or world space
  78109. * @param position The position to set the bone
  78110. * @param space The space that the position is in
  78111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78112. */
  78113. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78114. /**
  78115. * Set the absolute position of the bone (world space)
  78116. * @param position The position to set the bone
  78117. * @param mesh The mesh that this bone is attached to
  78118. */
  78119. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78120. /**
  78121. * Scale the bone on the x, y and z axes (in local space)
  78122. * @param x The amount to scale the bone on the x axis
  78123. * @param y The amount to scale the bone on the y axis
  78124. * @param z The amount to scale the bone on the z axis
  78125. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78126. */
  78127. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78128. /**
  78129. * Set the bone scaling in local space
  78130. * @param scale defines the scaling vector
  78131. */
  78132. setScale(scale: Vector3): void;
  78133. /**
  78134. * Gets the current scaling in local space
  78135. * @returns the current scaling vector
  78136. */
  78137. getScale(): Vector3;
  78138. /**
  78139. * Gets the current scaling in local space and stores it in a target vector
  78140. * @param result defines the target vector
  78141. */
  78142. getScaleToRef(result: Vector3): void;
  78143. /**
  78144. * Set the yaw, pitch, and roll of the bone in local or world space
  78145. * @param yaw The rotation of the bone on the y axis
  78146. * @param pitch The rotation of the bone on the x axis
  78147. * @param roll The rotation of the bone on the z axis
  78148. * @param space The space that the axes of rotation are in
  78149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78150. */
  78151. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78152. /**
  78153. * Add a rotation to the bone on an axis in local or world space
  78154. * @param axis The axis to rotate the bone on
  78155. * @param amount The amount to rotate the bone
  78156. * @param space The space that the axis is in
  78157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78158. */
  78159. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78160. /**
  78161. * Set the rotation of the bone to a particular axis angle in local or world space
  78162. * @param axis The axis to rotate the bone on
  78163. * @param angle The angle that the bone should be rotated to
  78164. * @param space The space that the axis is in
  78165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78166. */
  78167. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78168. /**
  78169. * Set the euler rotation of the bone in local of world space
  78170. * @param rotation The euler rotation that the bone should be set to
  78171. * @param space The space that the rotation is in
  78172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78173. */
  78174. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78175. /**
  78176. * Set the quaternion rotation of the bone in local of world space
  78177. * @param quat The quaternion rotation that the bone should be set to
  78178. * @param space The space that the rotation is in
  78179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78180. */
  78181. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78182. /**
  78183. * Set the rotation matrix of the bone in local of world space
  78184. * @param rotMat The rotation matrix that the bone should be set to
  78185. * @param space The space that the rotation is in
  78186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78187. */
  78188. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78189. private _rotateWithMatrix;
  78190. private _getNegativeRotationToRef;
  78191. /**
  78192. * Get the position of the bone in local or world space
  78193. * @param space The space that the returned position is in
  78194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78195. * @returns The position of the bone
  78196. */
  78197. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78198. /**
  78199. * Copy the position of the bone to a vector3 in local or world space
  78200. * @param space The space that the returned position is in
  78201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78202. * @param result The vector3 to copy the position to
  78203. */
  78204. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78205. /**
  78206. * Get the absolute position of the bone (world space)
  78207. * @param mesh The mesh that this bone is attached to
  78208. * @returns The absolute position of the bone
  78209. */
  78210. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78211. /**
  78212. * Copy the absolute position of the bone (world space) to the result param
  78213. * @param mesh The mesh that this bone is attached to
  78214. * @param result The vector3 to copy the absolute position to
  78215. */
  78216. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78217. /**
  78218. * Compute the absolute transforms of this bone and its children
  78219. */
  78220. computeAbsoluteTransforms(): void;
  78221. /**
  78222. * Get the world direction from an axis that is in the local space of the bone
  78223. * @param localAxis The local direction that is used to compute the world direction
  78224. * @param mesh The mesh that this bone is attached to
  78225. * @returns The world direction
  78226. */
  78227. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78228. /**
  78229. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78230. * @param localAxis The local direction that is used to compute the world direction
  78231. * @param mesh The mesh that this bone is attached to
  78232. * @param result The vector3 that the world direction will be copied to
  78233. */
  78234. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78235. /**
  78236. * Get the euler rotation of the bone in local or world space
  78237. * @param space The space that the rotation should be in
  78238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78239. * @returns The euler rotation
  78240. */
  78241. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78242. /**
  78243. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78244. * @param space The space that the rotation should be in
  78245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78246. * @param result The vector3 that the rotation should be copied to
  78247. */
  78248. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78249. /**
  78250. * Get the quaternion rotation of the bone in either local or world space
  78251. * @param space The space that the rotation should be in
  78252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78253. * @returns The quaternion rotation
  78254. */
  78255. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78256. /**
  78257. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78258. * @param space The space that the rotation should be in
  78259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78260. * @param result The quaternion that the rotation should be copied to
  78261. */
  78262. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78263. /**
  78264. * Get the rotation matrix of the bone in local or world space
  78265. * @param space The space that the rotation should be in
  78266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78267. * @returns The rotation matrix
  78268. */
  78269. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78270. /**
  78271. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78272. * @param space The space that the rotation should be in
  78273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78274. * @param result The quaternion that the rotation should be copied to
  78275. */
  78276. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78277. /**
  78278. * Get the world position of a point that is in the local space of the bone
  78279. * @param position The local position
  78280. * @param mesh The mesh that this bone is attached to
  78281. * @returns The world position
  78282. */
  78283. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78284. /**
  78285. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78286. * @param position The local position
  78287. * @param mesh The mesh that this bone is attached to
  78288. * @param result The vector3 that the world position should be copied to
  78289. */
  78290. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78291. /**
  78292. * Get the local position of a point that is in world space
  78293. * @param position The world position
  78294. * @param mesh The mesh that this bone is attached to
  78295. * @returns The local position
  78296. */
  78297. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78298. /**
  78299. * Get the local position of a point that is in world space and copy it to the result param
  78300. * @param position The world position
  78301. * @param mesh The mesh that this bone is attached to
  78302. * @param result The vector3 that the local position should be copied to
  78303. */
  78304. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /**
  78309. * 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.
  78310. * @see https://doc.babylonjs.com/how_to/transformnode
  78311. */
  78312. export class TransformNode extends Node {
  78313. /**
  78314. * Object will not rotate to face the camera
  78315. */
  78316. static BILLBOARDMODE_NONE: number;
  78317. /**
  78318. * Object will rotate to face the camera but only on the x axis
  78319. */
  78320. static BILLBOARDMODE_X: number;
  78321. /**
  78322. * Object will rotate to face the camera but only on the y axis
  78323. */
  78324. static BILLBOARDMODE_Y: number;
  78325. /**
  78326. * Object will rotate to face the camera but only on the z axis
  78327. */
  78328. static BILLBOARDMODE_Z: number;
  78329. /**
  78330. * Object will rotate to face the camera
  78331. */
  78332. static BILLBOARDMODE_ALL: number;
  78333. /**
  78334. * Object will rotate to face the camera's position instead of orientation
  78335. */
  78336. static BILLBOARDMODE_USE_POSITION: number;
  78337. private _forward;
  78338. private _forwardInverted;
  78339. private _up;
  78340. private _right;
  78341. private _rightInverted;
  78342. private _position;
  78343. private _rotation;
  78344. private _rotationQuaternion;
  78345. protected _scaling: Vector3;
  78346. protected _isDirty: boolean;
  78347. private _transformToBoneReferal;
  78348. private _isAbsoluteSynced;
  78349. private _billboardMode;
  78350. /**
  78351. * Gets or sets the billboard mode. Default is 0.
  78352. *
  78353. * | Value | Type | Description |
  78354. * | --- | --- | --- |
  78355. * | 0 | BILLBOARDMODE_NONE | |
  78356. * | 1 | BILLBOARDMODE_X | |
  78357. * | 2 | BILLBOARDMODE_Y | |
  78358. * | 4 | BILLBOARDMODE_Z | |
  78359. * | 7 | BILLBOARDMODE_ALL | |
  78360. *
  78361. */
  78362. billboardMode: number;
  78363. private _preserveParentRotationForBillboard;
  78364. /**
  78365. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78366. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78367. */
  78368. preserveParentRotationForBillboard: boolean;
  78369. /**
  78370. * 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
  78371. */
  78372. scalingDeterminant: number;
  78373. private _infiniteDistance;
  78374. /**
  78375. * Gets or sets the distance of the object to max, often used by skybox
  78376. */
  78377. infiniteDistance: boolean;
  78378. /**
  78379. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78380. * By default the system will update normals to compensate
  78381. */
  78382. ignoreNonUniformScaling: boolean;
  78383. /**
  78384. * 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
  78385. */
  78386. reIntegrateRotationIntoRotationQuaternion: boolean;
  78387. /** @hidden */
  78388. _poseMatrix: Nullable<Matrix>;
  78389. /** @hidden */
  78390. _localMatrix: Matrix;
  78391. private _usePivotMatrix;
  78392. private _absolutePosition;
  78393. private _absoluteScaling;
  78394. private _absoluteRotationQuaternion;
  78395. private _pivotMatrix;
  78396. private _pivotMatrixInverse;
  78397. protected _postMultiplyPivotMatrix: boolean;
  78398. protected _isWorldMatrixFrozen: boolean;
  78399. /** @hidden */
  78400. _indexInSceneTransformNodesArray: number;
  78401. /**
  78402. * An event triggered after the world matrix is updated
  78403. */
  78404. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78405. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78406. /**
  78407. * Gets a string identifying the name of the class
  78408. * @returns "TransformNode" string
  78409. */
  78410. getClassName(): string;
  78411. /**
  78412. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78413. */
  78414. position: Vector3;
  78415. /**
  78416. * 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)).
  78417. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78418. */
  78419. rotation: Vector3;
  78420. /**
  78421. * 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)).
  78422. */
  78423. scaling: Vector3;
  78424. /**
  78425. * 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).
  78426. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78427. */
  78428. rotationQuaternion: Nullable<Quaternion>;
  78429. /**
  78430. * The forward direction of that transform in world space.
  78431. */
  78432. readonly forward: Vector3;
  78433. /**
  78434. * The up direction of that transform in world space.
  78435. */
  78436. readonly up: Vector3;
  78437. /**
  78438. * The right direction of that transform in world space.
  78439. */
  78440. readonly right: Vector3;
  78441. /**
  78442. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78443. * @param matrix the matrix to copy the pose from
  78444. * @returns this TransformNode.
  78445. */
  78446. updatePoseMatrix(matrix: Matrix): TransformNode;
  78447. /**
  78448. * Returns the mesh Pose matrix.
  78449. * @returns the pose matrix
  78450. */
  78451. getPoseMatrix(): Matrix;
  78452. /** @hidden */
  78453. _isSynchronized(): boolean;
  78454. /** @hidden */
  78455. _initCache(): void;
  78456. /**
  78457. * Flag the transform node as dirty (Forcing it to update everything)
  78458. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78459. * @returns this transform node
  78460. */
  78461. markAsDirty(property: string): TransformNode;
  78462. /**
  78463. * Returns the current mesh absolute position.
  78464. * Returns a Vector3.
  78465. */
  78466. readonly absolutePosition: Vector3;
  78467. /**
  78468. * Returns the current mesh absolute scaling.
  78469. * Returns a Vector3.
  78470. */
  78471. readonly absoluteScaling: Vector3;
  78472. /**
  78473. * Returns the current mesh absolute rotation.
  78474. * Returns a Quaternion.
  78475. */
  78476. readonly absoluteRotationQuaternion: Quaternion;
  78477. /**
  78478. * Sets a new matrix to apply before all other transformation
  78479. * @param matrix defines the transform matrix
  78480. * @returns the current TransformNode
  78481. */
  78482. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78483. /**
  78484. * Sets a new pivot matrix to the current node
  78485. * @param matrix defines the new pivot matrix to use
  78486. * @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
  78487. * @returns the current TransformNode
  78488. */
  78489. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78490. /**
  78491. * Returns the mesh pivot matrix.
  78492. * Default : Identity.
  78493. * @returns the matrix
  78494. */
  78495. getPivotMatrix(): Matrix;
  78496. /**
  78497. * Instantiate (when possible) or clone that node with its hierarchy
  78498. * @param newParent defines the new parent to use for the instance (or clone)
  78499. * @returns an instance (or a clone) of the current node with its hiearchy
  78500. */
  78501. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  78502. /**
  78503. * Prevents the World matrix to be computed any longer
  78504. * @param newWorldMatrix defines an optional matrix to use as world matrix
  78505. * @returns the TransformNode.
  78506. */
  78507. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  78508. /**
  78509. * Allows back the World matrix computation.
  78510. * @returns the TransformNode.
  78511. */
  78512. unfreezeWorldMatrix(): this;
  78513. /**
  78514. * True if the World matrix has been frozen.
  78515. */
  78516. readonly isWorldMatrixFrozen: boolean;
  78517. /**
  78518. * Retuns the mesh absolute position in the World.
  78519. * @returns a Vector3.
  78520. */
  78521. getAbsolutePosition(): Vector3;
  78522. /**
  78523. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78524. * @param absolutePosition the absolute position to set
  78525. * @returns the TransformNode.
  78526. */
  78527. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78528. /**
  78529. * Sets the mesh position in its local space.
  78530. * @param vector3 the position to set in localspace
  78531. * @returns the TransformNode.
  78532. */
  78533. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78534. /**
  78535. * Returns the mesh position in the local space from the current World matrix values.
  78536. * @returns a new Vector3.
  78537. */
  78538. getPositionExpressedInLocalSpace(): Vector3;
  78539. /**
  78540. * Translates the mesh along the passed Vector3 in its local space.
  78541. * @param vector3 the distance to translate in localspace
  78542. * @returns the TransformNode.
  78543. */
  78544. locallyTranslate(vector3: Vector3): TransformNode;
  78545. private static _lookAtVectorCache;
  78546. /**
  78547. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78548. * @param targetPoint the position (must be in same space as current mesh) to look at
  78549. * @param yawCor optional yaw (y-axis) correction in radians
  78550. * @param pitchCor optional pitch (x-axis) correction in radians
  78551. * @param rollCor optional roll (z-axis) correction in radians
  78552. * @param space the choosen space of the target
  78553. * @returns the TransformNode.
  78554. */
  78555. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78556. /**
  78557. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78558. * This Vector3 is expressed in the World space.
  78559. * @param localAxis axis to rotate
  78560. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78561. */
  78562. getDirection(localAxis: Vector3): Vector3;
  78563. /**
  78564. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78565. * localAxis is expressed in the mesh local space.
  78566. * result is computed in the Wordl space from the mesh World matrix.
  78567. * @param localAxis axis to rotate
  78568. * @param result the resulting transformnode
  78569. * @returns this TransformNode.
  78570. */
  78571. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78572. /**
  78573. * Sets this transform node rotation to the given local axis.
  78574. * @param localAxis the axis in local space
  78575. * @param yawCor optional yaw (y-axis) correction in radians
  78576. * @param pitchCor optional pitch (x-axis) correction in radians
  78577. * @param rollCor optional roll (z-axis) correction in radians
  78578. * @returns this TransformNode
  78579. */
  78580. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78581. /**
  78582. * Sets a new pivot point to the current node
  78583. * @param point defines the new pivot point to use
  78584. * @param space defines if the point is in world or local space (local by default)
  78585. * @returns the current TransformNode
  78586. */
  78587. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78588. /**
  78589. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78590. * @returns the pivot point
  78591. */
  78592. getPivotPoint(): Vector3;
  78593. /**
  78594. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78595. * @param result the vector3 to store the result
  78596. * @returns this TransformNode.
  78597. */
  78598. getPivotPointToRef(result: Vector3): TransformNode;
  78599. /**
  78600. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78601. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78602. */
  78603. getAbsolutePivotPoint(): Vector3;
  78604. /**
  78605. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78606. * @param result vector3 to store the result
  78607. * @returns this TransformNode.
  78608. */
  78609. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78610. /**
  78611. * Defines the passed node as the parent of the current node.
  78612. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78613. * @see https://doc.babylonjs.com/how_to/parenting
  78614. * @param node the node ot set as the parent
  78615. * @returns this TransformNode.
  78616. */
  78617. setParent(node: Nullable<Node>): TransformNode;
  78618. private _nonUniformScaling;
  78619. /**
  78620. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78621. */
  78622. readonly nonUniformScaling: boolean;
  78623. /** @hidden */
  78624. _updateNonUniformScalingState(value: boolean): boolean;
  78625. /**
  78626. * Attach the current TransformNode to another TransformNode associated with a bone
  78627. * @param bone Bone affecting the TransformNode
  78628. * @param affectedTransformNode TransformNode associated with the bone
  78629. * @returns this object
  78630. */
  78631. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78632. /**
  78633. * Detach the transform node if its associated with a bone
  78634. * @returns this object
  78635. */
  78636. detachFromBone(): TransformNode;
  78637. private static _rotationAxisCache;
  78638. /**
  78639. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78640. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78641. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78642. * The passed axis is also normalized.
  78643. * @param axis the axis to rotate around
  78644. * @param amount the amount to rotate in radians
  78645. * @param space Space to rotate in (Default: local)
  78646. * @returns the TransformNode.
  78647. */
  78648. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78649. /**
  78650. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78651. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78652. * The passed axis is also normalized. .
  78653. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78654. * @param point the point to rotate around
  78655. * @param axis the axis to rotate around
  78656. * @param amount the amount to rotate in radians
  78657. * @returns the TransformNode
  78658. */
  78659. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78660. /**
  78661. * Translates the mesh along the axis vector for the passed distance in the given space.
  78662. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78663. * @param axis the axis to translate in
  78664. * @param distance the distance to translate
  78665. * @param space Space to rotate in (Default: local)
  78666. * @returns the TransformNode.
  78667. */
  78668. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78669. /**
  78670. * Adds a rotation step to the mesh current rotation.
  78671. * x, y, z are Euler angles expressed in radians.
  78672. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78673. * This means this rotation is made in the mesh local space only.
  78674. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78675. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78676. * ```javascript
  78677. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78678. * ```
  78679. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78680. * 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.
  78681. * @param x Rotation to add
  78682. * @param y Rotation to add
  78683. * @param z Rotation to add
  78684. * @returns the TransformNode.
  78685. */
  78686. addRotation(x: number, y: number, z: number): TransformNode;
  78687. /**
  78688. * @hidden
  78689. */
  78690. protected _getEffectiveParent(): Nullable<Node>;
  78691. /**
  78692. * Computes the world matrix of the node
  78693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78694. * @returns the world matrix
  78695. */
  78696. computeWorldMatrix(force?: boolean): Matrix;
  78697. protected _afterComputeWorldMatrix(): void;
  78698. /**
  78699. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78700. * @param func callback function to add
  78701. *
  78702. * @returns the TransformNode.
  78703. */
  78704. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78705. /**
  78706. * Removes a registered callback function.
  78707. * @param func callback function to remove
  78708. * @returns the TransformNode.
  78709. */
  78710. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78711. /**
  78712. * Gets the position of the current mesh in camera space
  78713. * @param camera defines the camera to use
  78714. * @returns a position
  78715. */
  78716. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78717. /**
  78718. * Returns the distance from the mesh to the active camera
  78719. * @param camera defines the camera to use
  78720. * @returns the distance
  78721. */
  78722. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78723. /**
  78724. * Clone the current transform node
  78725. * @param name Name of the new clone
  78726. * @param newParent New parent for the clone
  78727. * @param doNotCloneChildren Do not clone children hierarchy
  78728. * @returns the new transform node
  78729. */
  78730. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78731. /**
  78732. * Serializes the objects information.
  78733. * @param currentSerializationObject defines the object to serialize in
  78734. * @returns the serialized object
  78735. */
  78736. serialize(currentSerializationObject?: any): any;
  78737. /**
  78738. * Returns a new TransformNode object parsed from the source provided.
  78739. * @param parsedTransformNode is the source.
  78740. * @param scene the scne the object belongs to
  78741. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78742. * @returns a new TransformNode object parsed from the source provided.
  78743. */
  78744. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78745. /**
  78746. * Get all child-transformNodes of this node
  78747. * @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
  78748. * @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
  78749. * @returns an array of TransformNode
  78750. */
  78751. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78752. /**
  78753. * Releases resources associated with this transform node.
  78754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78756. */
  78757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78758. /**
  78759. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78760. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78761. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78762. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78763. * @returns the current mesh
  78764. */
  78765. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78766. private _syncAbsoluteScalingAndRotation;
  78767. }
  78768. }
  78769. declare module BABYLON {
  78770. /**
  78771. * Defines the types of pose enabled controllers that are supported
  78772. */
  78773. export enum PoseEnabledControllerType {
  78774. /**
  78775. * HTC Vive
  78776. */
  78777. VIVE = 0,
  78778. /**
  78779. * Oculus Rift
  78780. */
  78781. OCULUS = 1,
  78782. /**
  78783. * Windows mixed reality
  78784. */
  78785. WINDOWS = 2,
  78786. /**
  78787. * Samsung gear VR
  78788. */
  78789. GEAR_VR = 3,
  78790. /**
  78791. * Google Daydream
  78792. */
  78793. DAYDREAM = 4,
  78794. /**
  78795. * Generic
  78796. */
  78797. GENERIC = 5
  78798. }
  78799. /**
  78800. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78801. */
  78802. export interface MutableGamepadButton {
  78803. /**
  78804. * Value of the button/trigger
  78805. */
  78806. value: number;
  78807. /**
  78808. * If the button/trigger is currently touched
  78809. */
  78810. touched: boolean;
  78811. /**
  78812. * If the button/trigger is currently pressed
  78813. */
  78814. pressed: boolean;
  78815. }
  78816. /**
  78817. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78818. * @hidden
  78819. */
  78820. export interface ExtendedGamepadButton extends GamepadButton {
  78821. /**
  78822. * If the button/trigger is currently pressed
  78823. */
  78824. readonly pressed: boolean;
  78825. /**
  78826. * If the button/trigger is currently touched
  78827. */
  78828. readonly touched: boolean;
  78829. /**
  78830. * Value of the button/trigger
  78831. */
  78832. readonly value: number;
  78833. }
  78834. /** @hidden */
  78835. export interface _GamePadFactory {
  78836. /**
  78837. * Returns wether or not the current gamepad can be created for this type of controller.
  78838. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78839. * @returns true if it can be created, otherwise false
  78840. */
  78841. canCreate(gamepadInfo: any): boolean;
  78842. /**
  78843. * Creates a new instance of the Gamepad.
  78844. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78845. * @returns the new gamepad instance
  78846. */
  78847. create(gamepadInfo: any): Gamepad;
  78848. }
  78849. /**
  78850. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78851. */
  78852. export class PoseEnabledControllerHelper {
  78853. /** @hidden */
  78854. static _ControllerFactories: _GamePadFactory[];
  78855. /** @hidden */
  78856. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78857. /**
  78858. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78859. * @param vrGamepad the gamepad to initialized
  78860. * @returns a vr controller of the type the gamepad identified as
  78861. */
  78862. static InitiateController(vrGamepad: any): Gamepad;
  78863. }
  78864. /**
  78865. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78866. */
  78867. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78868. /**
  78869. * If the controller is used in a webXR session
  78870. */
  78871. isXR: boolean;
  78872. private _deviceRoomPosition;
  78873. private _deviceRoomRotationQuaternion;
  78874. /**
  78875. * The device position in babylon space
  78876. */
  78877. devicePosition: Vector3;
  78878. /**
  78879. * The device rotation in babylon space
  78880. */
  78881. deviceRotationQuaternion: Quaternion;
  78882. /**
  78883. * The scale factor of the device in babylon space
  78884. */
  78885. deviceScaleFactor: number;
  78886. /**
  78887. * (Likely devicePosition should be used instead) The device position in its room space
  78888. */
  78889. position: Vector3;
  78890. /**
  78891. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78892. */
  78893. rotationQuaternion: Quaternion;
  78894. /**
  78895. * The type of controller (Eg. Windows mixed reality)
  78896. */
  78897. controllerType: PoseEnabledControllerType;
  78898. protected _calculatedPosition: Vector3;
  78899. private _calculatedRotation;
  78900. /**
  78901. * The raw pose from the device
  78902. */
  78903. rawPose: DevicePose;
  78904. private _trackPosition;
  78905. private _maxRotationDistFromHeadset;
  78906. private _draggedRoomRotation;
  78907. /**
  78908. * @hidden
  78909. */
  78910. _disableTrackPosition(fixedPosition: Vector3): void;
  78911. /**
  78912. * Internal, the mesh attached to the controller
  78913. * @hidden
  78914. */
  78915. _mesh: Nullable<AbstractMesh>;
  78916. private _poseControlledCamera;
  78917. private _leftHandSystemQuaternion;
  78918. /**
  78919. * Internal, matrix used to convert room space to babylon space
  78920. * @hidden
  78921. */
  78922. _deviceToWorld: Matrix;
  78923. /**
  78924. * Node to be used when casting a ray from the controller
  78925. * @hidden
  78926. */
  78927. _pointingPoseNode: Nullable<TransformNode>;
  78928. /**
  78929. * Name of the child mesh that can be used to cast a ray from the controller
  78930. */
  78931. static readonly POINTING_POSE: string;
  78932. /**
  78933. * Creates a new PoseEnabledController from a gamepad
  78934. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78935. */
  78936. constructor(browserGamepad: any);
  78937. private _workingMatrix;
  78938. /**
  78939. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78940. */
  78941. update(): void;
  78942. /**
  78943. * Updates only the pose device and mesh without doing any button event checking
  78944. */
  78945. protected _updatePoseAndMesh(): void;
  78946. /**
  78947. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78948. * @param poseData raw pose fromthe device
  78949. */
  78950. updateFromDevice(poseData: DevicePose): void;
  78951. /**
  78952. * @hidden
  78953. */
  78954. _meshAttachedObservable: Observable<AbstractMesh>;
  78955. /**
  78956. * Attaches a mesh to the controller
  78957. * @param mesh the mesh to be attached
  78958. */
  78959. attachToMesh(mesh: AbstractMesh): void;
  78960. /**
  78961. * Attaches the controllers mesh to a camera
  78962. * @param camera the camera the mesh should be attached to
  78963. */
  78964. attachToPoseControlledCamera(camera: TargetCamera): void;
  78965. /**
  78966. * Disposes of the controller
  78967. */
  78968. dispose(): void;
  78969. /**
  78970. * The mesh that is attached to the controller
  78971. */
  78972. readonly mesh: Nullable<AbstractMesh>;
  78973. /**
  78974. * Gets the ray of the controller in the direction the controller is pointing
  78975. * @param length the length the resulting ray should be
  78976. * @returns a ray in the direction the controller is pointing
  78977. */
  78978. getForwardRay(length?: number): Ray;
  78979. }
  78980. }
  78981. declare module BABYLON {
  78982. /**
  78983. * Defines the WebVRController object that represents controllers tracked in 3D space
  78984. */
  78985. export abstract class WebVRController extends PoseEnabledController {
  78986. /**
  78987. * Internal, the default controller model for the controller
  78988. */
  78989. protected _defaultModel: AbstractMesh;
  78990. /**
  78991. * Fired when the trigger state has changed
  78992. */
  78993. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78994. /**
  78995. * Fired when the main button state has changed
  78996. */
  78997. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78998. /**
  78999. * Fired when the secondary button state has changed
  79000. */
  79001. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79002. /**
  79003. * Fired when the pad state has changed
  79004. */
  79005. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79006. /**
  79007. * Fired when controllers stick values have changed
  79008. */
  79009. onPadValuesChangedObservable: Observable<StickValues>;
  79010. /**
  79011. * Array of button availible on the controller
  79012. */
  79013. protected _buttons: Array<MutableGamepadButton>;
  79014. private _onButtonStateChange;
  79015. /**
  79016. * Fired when a controller button's state has changed
  79017. * @param callback the callback containing the button that was modified
  79018. */
  79019. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79020. /**
  79021. * X and Y axis corresponding to the controllers joystick
  79022. */
  79023. pad: StickValues;
  79024. /**
  79025. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79026. */
  79027. hand: string;
  79028. /**
  79029. * The default controller model for the controller
  79030. */
  79031. readonly defaultModel: AbstractMesh;
  79032. /**
  79033. * Creates a new WebVRController from a gamepad
  79034. * @param vrGamepad the gamepad that the WebVRController should be created from
  79035. */
  79036. constructor(vrGamepad: any);
  79037. /**
  79038. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79039. */
  79040. update(): void;
  79041. /**
  79042. * Function to be called when a button is modified
  79043. */
  79044. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79045. /**
  79046. * Loads a mesh and attaches it to the controller
  79047. * @param scene the scene the mesh should be added to
  79048. * @param meshLoaded callback for when the mesh has been loaded
  79049. */
  79050. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79051. private _setButtonValue;
  79052. private _changes;
  79053. private _checkChanges;
  79054. /**
  79055. * Disposes of th webVRCOntroller
  79056. */
  79057. dispose(): void;
  79058. }
  79059. }
  79060. declare module BABYLON {
  79061. /**
  79062. * The HemisphericLight simulates the ambient environment light,
  79063. * so the passed direction is the light reflection direction, not the incoming direction.
  79064. */
  79065. export class HemisphericLight extends Light {
  79066. /**
  79067. * The groundColor is the light in the opposite direction to the one specified during creation.
  79068. * 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.
  79069. */
  79070. groundColor: Color3;
  79071. /**
  79072. * The light reflection direction, not the incoming direction.
  79073. */
  79074. direction: Vector3;
  79075. /**
  79076. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79077. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79078. * The HemisphericLight can't cast shadows.
  79079. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79080. * @param name The friendly name of the light
  79081. * @param direction The direction of the light reflection
  79082. * @param scene The scene the light belongs to
  79083. */
  79084. constructor(name: string, direction: Vector3, scene: Scene);
  79085. protected _buildUniformLayout(): void;
  79086. /**
  79087. * Returns the string "HemisphericLight".
  79088. * @return The class name
  79089. */
  79090. getClassName(): string;
  79091. /**
  79092. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79093. * Returns the updated direction.
  79094. * @param target The target the direction should point to
  79095. * @return The computed direction
  79096. */
  79097. setDirectionToTarget(target: Vector3): Vector3;
  79098. /**
  79099. * Returns the shadow generator associated to the light.
  79100. * @returns Always null for hemispheric lights because it does not support shadows.
  79101. */
  79102. getShadowGenerator(): Nullable<IShadowGenerator>;
  79103. /**
  79104. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79105. * @param effect The effect to update
  79106. * @param lightIndex The index of the light in the effect to update
  79107. * @returns The hemispheric light
  79108. */
  79109. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79110. /**
  79111. * Computes the world matrix of the node
  79112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79113. * @param useWasUpdatedFlag defines a reserved property
  79114. * @returns the world matrix
  79115. */
  79116. computeWorldMatrix(): Matrix;
  79117. /**
  79118. * Returns the integer 3.
  79119. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79120. */
  79121. getTypeID(): number;
  79122. /**
  79123. * Prepares the list of defines specific to the light type.
  79124. * @param defines the list of defines
  79125. * @param lightIndex defines the index of the light for the effect
  79126. */
  79127. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79128. }
  79129. }
  79130. declare module BABYLON {
  79131. /** @hidden */
  79132. export var vrMultiviewToSingleviewPixelShader: {
  79133. name: string;
  79134. shader: string;
  79135. };
  79136. }
  79137. declare module BABYLON {
  79138. /**
  79139. * Renders to multiple views with a single draw call
  79140. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79141. */
  79142. export class MultiviewRenderTarget extends RenderTargetTexture {
  79143. /**
  79144. * Creates a multiview render target
  79145. * @param scene scene used with the render target
  79146. * @param size the size of the render target (used for each view)
  79147. */
  79148. constructor(scene: Scene, size?: number | {
  79149. width: number;
  79150. height: number;
  79151. } | {
  79152. ratio: number;
  79153. });
  79154. /**
  79155. * @hidden
  79156. * @param faceIndex the face index, if its a cube texture
  79157. */
  79158. _bindFrameBuffer(faceIndex?: number): void;
  79159. /**
  79160. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79161. * @returns the view count
  79162. */
  79163. getViewCount(): number;
  79164. }
  79165. }
  79166. declare module BABYLON {
  79167. /**
  79168. * Reprasents a camera frustum
  79169. */
  79170. export class Frustum {
  79171. /**
  79172. * Gets the planes representing the frustum
  79173. * @param transform matrix to be applied to the returned planes
  79174. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79175. */
  79176. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79177. /**
  79178. * Gets the near frustum plane transformed by the transform matrix
  79179. * @param transform transformation matrix to be applied to the resulting frustum plane
  79180. * @param frustumPlane the resuling frustum plane
  79181. */
  79182. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79183. /**
  79184. * Gets the far frustum plane transformed by the transform matrix
  79185. * @param transform transformation matrix to be applied to the resulting frustum plane
  79186. * @param frustumPlane the resuling frustum plane
  79187. */
  79188. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79189. /**
  79190. * Gets the left frustum plane transformed by the transform matrix
  79191. * @param transform transformation matrix to be applied to the resulting frustum plane
  79192. * @param frustumPlane the resuling frustum plane
  79193. */
  79194. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79195. /**
  79196. * Gets the right frustum plane transformed by the transform matrix
  79197. * @param transform transformation matrix to be applied to the resulting frustum plane
  79198. * @param frustumPlane the resuling frustum plane
  79199. */
  79200. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79201. /**
  79202. * Gets the top frustum plane transformed by the transform matrix
  79203. * @param transform transformation matrix to be applied to the resulting frustum plane
  79204. * @param frustumPlane the resuling frustum plane
  79205. */
  79206. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79207. /**
  79208. * Gets the bottom frustum plane transformed by the transform matrix
  79209. * @param transform transformation matrix to be applied to the resulting frustum plane
  79210. * @param frustumPlane the resuling frustum plane
  79211. */
  79212. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79213. /**
  79214. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79215. * @param transform transformation matrix to be applied to the resulting frustum planes
  79216. * @param frustumPlanes the resuling frustum planes
  79217. */
  79218. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79219. }
  79220. }
  79221. declare module BABYLON {
  79222. interface Engine {
  79223. /**
  79224. * Creates a new multiview render target
  79225. * @param width defines the width of the texture
  79226. * @param height defines the height of the texture
  79227. * @returns the created multiview texture
  79228. */
  79229. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79230. /**
  79231. * Binds a multiview framebuffer to be drawn to
  79232. * @param multiviewTexture texture to bind
  79233. */
  79234. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79235. }
  79236. interface Camera {
  79237. /**
  79238. * @hidden
  79239. * 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)
  79240. */
  79241. _useMultiviewToSingleView: boolean;
  79242. /**
  79243. * @hidden
  79244. * 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)
  79245. */
  79246. _multiviewTexture: Nullable<RenderTargetTexture>;
  79247. /**
  79248. * @hidden
  79249. * ensures the multiview texture of the camera exists and has the specified width/height
  79250. * @param width height to set on the multiview texture
  79251. * @param height width to set on the multiview texture
  79252. */
  79253. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79254. }
  79255. interface Scene {
  79256. /** @hidden */
  79257. _transformMatrixR: Matrix;
  79258. /** @hidden */
  79259. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79260. /** @hidden */
  79261. _createMultiviewUbo(): void;
  79262. /** @hidden */
  79263. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79264. /** @hidden */
  79265. _renderMultiviewToSingleView(camera: Camera): void;
  79266. }
  79267. }
  79268. declare module BABYLON {
  79269. /**
  79270. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79271. * This will not be used for webXR as it supports displaying texture arrays directly
  79272. */
  79273. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79274. /**
  79275. * Initializes a VRMultiviewToSingleview
  79276. * @param name name of the post process
  79277. * @param camera camera to be applied to
  79278. * @param scaleFactor scaling factor to the size of the output texture
  79279. */
  79280. constructor(name: string, camera: Camera, scaleFactor: number);
  79281. }
  79282. }
  79283. declare module BABYLON {
  79284. interface Engine {
  79285. /** @hidden */
  79286. _vrDisplay: any;
  79287. /** @hidden */
  79288. _vrSupported: boolean;
  79289. /** @hidden */
  79290. _oldSize: Size;
  79291. /** @hidden */
  79292. _oldHardwareScaleFactor: number;
  79293. /** @hidden */
  79294. _vrExclusivePointerMode: boolean;
  79295. /** @hidden */
  79296. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79297. /** @hidden */
  79298. _onVRDisplayPointerRestricted: () => void;
  79299. /** @hidden */
  79300. _onVRDisplayPointerUnrestricted: () => void;
  79301. /** @hidden */
  79302. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79303. /** @hidden */
  79304. _onVrDisplayDisconnect: Nullable<() => void>;
  79305. /** @hidden */
  79306. _onVrDisplayPresentChange: Nullable<() => void>;
  79307. /**
  79308. * Observable signaled when VR display mode changes
  79309. */
  79310. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79311. /**
  79312. * Observable signaled when VR request present is complete
  79313. */
  79314. onVRRequestPresentComplete: Observable<boolean>;
  79315. /**
  79316. * Observable signaled when VR request present starts
  79317. */
  79318. onVRRequestPresentStart: Observable<Engine>;
  79319. /**
  79320. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79321. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79322. */
  79323. isInVRExclusivePointerMode: boolean;
  79324. /**
  79325. * Gets a boolean indicating if a webVR device was detected
  79326. * @returns true if a webVR device was detected
  79327. */
  79328. isVRDevicePresent(): boolean;
  79329. /**
  79330. * Gets the current webVR device
  79331. * @returns the current webVR device (or null)
  79332. */
  79333. getVRDevice(): any;
  79334. /**
  79335. * Initializes a webVR display and starts listening to display change events
  79336. * The onVRDisplayChangedObservable will be notified upon these changes
  79337. * @returns A promise containing a VRDisplay and if vr is supported
  79338. */
  79339. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79340. /** @hidden */
  79341. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79342. /**
  79343. * Call this function to switch to webVR mode
  79344. * Will do nothing if webVR is not supported or if there is no webVR device
  79345. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79346. */
  79347. enableVR(): void;
  79348. /** @hidden */
  79349. _onVRFullScreenTriggered(): void;
  79350. }
  79351. }
  79352. declare module BABYLON {
  79353. /**
  79354. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79355. * IMPORTANT!! The data is right-hand data.
  79356. * @export
  79357. * @interface DevicePose
  79358. */
  79359. export interface DevicePose {
  79360. /**
  79361. * The position of the device, values in array are [x,y,z].
  79362. */
  79363. readonly position: Nullable<Float32Array>;
  79364. /**
  79365. * The linearVelocity of the device, values in array are [x,y,z].
  79366. */
  79367. readonly linearVelocity: Nullable<Float32Array>;
  79368. /**
  79369. * The linearAcceleration of the device, values in array are [x,y,z].
  79370. */
  79371. readonly linearAcceleration: Nullable<Float32Array>;
  79372. /**
  79373. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79374. */
  79375. readonly orientation: Nullable<Float32Array>;
  79376. /**
  79377. * The angularVelocity of the device, values in array are [x,y,z].
  79378. */
  79379. readonly angularVelocity: Nullable<Float32Array>;
  79380. /**
  79381. * The angularAcceleration of the device, values in array are [x,y,z].
  79382. */
  79383. readonly angularAcceleration: Nullable<Float32Array>;
  79384. }
  79385. /**
  79386. * Interface representing a pose controlled object in Babylon.
  79387. * A pose controlled object has both regular pose values as well as pose values
  79388. * from an external device such as a VR head mounted display
  79389. */
  79390. export interface PoseControlled {
  79391. /**
  79392. * The position of the object in babylon space.
  79393. */
  79394. position: Vector3;
  79395. /**
  79396. * The rotation quaternion of the object in babylon space.
  79397. */
  79398. rotationQuaternion: Quaternion;
  79399. /**
  79400. * The position of the device in babylon space.
  79401. */
  79402. devicePosition?: Vector3;
  79403. /**
  79404. * The rotation quaternion of the device in babylon space.
  79405. */
  79406. deviceRotationQuaternion: Quaternion;
  79407. /**
  79408. * The raw pose coming from the device.
  79409. */
  79410. rawPose: Nullable<DevicePose>;
  79411. /**
  79412. * The scale of the device to be used when translating from device space to babylon space.
  79413. */
  79414. deviceScaleFactor: number;
  79415. /**
  79416. * Updates the poseControlled values based on the input device pose.
  79417. * @param poseData the pose data to update the object with
  79418. */
  79419. updateFromDevice(poseData: DevicePose): void;
  79420. }
  79421. /**
  79422. * Set of options to customize the webVRCamera
  79423. */
  79424. export interface WebVROptions {
  79425. /**
  79426. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79427. */
  79428. trackPosition?: boolean;
  79429. /**
  79430. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79431. */
  79432. positionScale?: number;
  79433. /**
  79434. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79435. */
  79436. displayName?: string;
  79437. /**
  79438. * Should the native controller meshes be initialized. (default: true)
  79439. */
  79440. controllerMeshes?: boolean;
  79441. /**
  79442. * Creating a default HemiLight only on controllers. (default: true)
  79443. */
  79444. defaultLightingOnControllers?: boolean;
  79445. /**
  79446. * If you don't want to use the default VR button of the helper. (default: false)
  79447. */
  79448. useCustomVRButton?: boolean;
  79449. /**
  79450. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79451. */
  79452. customVRButton?: HTMLButtonElement;
  79453. /**
  79454. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79455. */
  79456. rayLength?: number;
  79457. /**
  79458. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79459. */
  79460. defaultHeight?: number;
  79461. /**
  79462. * If multiview should be used if availible (default: false)
  79463. */
  79464. useMultiview?: boolean;
  79465. }
  79466. /**
  79467. * This represents a WebVR camera.
  79468. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79469. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79470. */
  79471. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79472. private webVROptions;
  79473. /**
  79474. * @hidden
  79475. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79476. */
  79477. _vrDevice: any;
  79478. /**
  79479. * The rawPose of the vrDevice.
  79480. */
  79481. rawPose: Nullable<DevicePose>;
  79482. private _onVREnabled;
  79483. private _specsVersion;
  79484. private _attached;
  79485. private _frameData;
  79486. protected _descendants: Array<Node>;
  79487. private _deviceRoomPosition;
  79488. /** @hidden */
  79489. _deviceRoomRotationQuaternion: Quaternion;
  79490. private _standingMatrix;
  79491. /**
  79492. * Represents device position in babylon space.
  79493. */
  79494. devicePosition: Vector3;
  79495. /**
  79496. * Represents device rotation in babylon space.
  79497. */
  79498. deviceRotationQuaternion: Quaternion;
  79499. /**
  79500. * The scale of the device to be used when translating from device space to babylon space.
  79501. */
  79502. deviceScaleFactor: number;
  79503. private _deviceToWorld;
  79504. private _worldToDevice;
  79505. /**
  79506. * References to the webVR controllers for the vrDevice.
  79507. */
  79508. controllers: Array<WebVRController>;
  79509. /**
  79510. * Emits an event when a controller is attached.
  79511. */
  79512. onControllersAttachedObservable: Observable<WebVRController[]>;
  79513. /**
  79514. * Emits an event when a controller's mesh has been loaded;
  79515. */
  79516. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79517. /**
  79518. * Emits an event when the HMD's pose has been updated.
  79519. */
  79520. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79521. private _poseSet;
  79522. /**
  79523. * If the rig cameras be used as parent instead of this camera.
  79524. */
  79525. rigParenting: boolean;
  79526. private _lightOnControllers;
  79527. private _defaultHeight?;
  79528. /**
  79529. * Instantiates a WebVRFreeCamera.
  79530. * @param name The name of the WebVRFreeCamera
  79531. * @param position The starting anchor position for the camera
  79532. * @param scene The scene the camera belongs to
  79533. * @param webVROptions a set of customizable options for the webVRCamera
  79534. */
  79535. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79536. /**
  79537. * Gets the device distance from the ground in meters.
  79538. * @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.
  79539. */
  79540. deviceDistanceToRoomGround(): number;
  79541. /**
  79542. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79543. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79544. */
  79545. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79546. /**
  79547. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79548. * @returns A promise with a boolean set to if the standing matrix is supported.
  79549. */
  79550. useStandingMatrixAsync(): Promise<boolean>;
  79551. /**
  79552. * Disposes the camera
  79553. */
  79554. dispose(): void;
  79555. /**
  79556. * Gets a vrController by name.
  79557. * @param name The name of the controller to retreive
  79558. * @returns the controller matching the name specified or null if not found
  79559. */
  79560. getControllerByName(name: string): Nullable<WebVRController>;
  79561. private _leftController;
  79562. /**
  79563. * The controller corresponding to the users left hand.
  79564. */
  79565. readonly leftController: Nullable<WebVRController>;
  79566. private _rightController;
  79567. /**
  79568. * The controller corresponding to the users right hand.
  79569. */
  79570. readonly rightController: Nullable<WebVRController>;
  79571. /**
  79572. * Casts a ray forward from the vrCamera's gaze.
  79573. * @param length Length of the ray (default: 100)
  79574. * @returns the ray corresponding to the gaze
  79575. */
  79576. getForwardRay(length?: number): Ray;
  79577. /**
  79578. * @hidden
  79579. * Updates the camera based on device's frame data
  79580. */
  79581. _checkInputs(): void;
  79582. /**
  79583. * Updates the poseControlled values based on the input device pose.
  79584. * @param poseData Pose coming from the device
  79585. */
  79586. updateFromDevice(poseData: DevicePose): void;
  79587. private _htmlElementAttached;
  79588. private _detachIfAttached;
  79589. /**
  79590. * WebVR's attach control will start broadcasting frames to the device.
  79591. * Note that in certain browsers (chrome for example) this function must be called
  79592. * within a user-interaction callback. Example:
  79593. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79594. *
  79595. * @param element html element to attach the vrDevice to
  79596. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79597. */
  79598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79599. /**
  79600. * Detaches the camera from the html element and disables VR
  79601. *
  79602. * @param element html element to detach from
  79603. */
  79604. detachControl(element: HTMLElement): void;
  79605. /**
  79606. * @returns the name of this class
  79607. */
  79608. getClassName(): string;
  79609. /**
  79610. * Calls resetPose on the vrDisplay
  79611. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79612. */
  79613. resetToCurrentRotation(): void;
  79614. /**
  79615. * @hidden
  79616. * Updates the rig cameras (left and right eye)
  79617. */
  79618. _updateRigCameras(): void;
  79619. private _workingVector;
  79620. private _oneVector;
  79621. private _workingMatrix;
  79622. private updateCacheCalled;
  79623. private _correctPositionIfNotTrackPosition;
  79624. /**
  79625. * @hidden
  79626. * Updates the cached values of the camera
  79627. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79628. */
  79629. _updateCache(ignoreParentClass?: boolean): void;
  79630. /**
  79631. * @hidden
  79632. * Get current device position in babylon world
  79633. */
  79634. _computeDevicePosition(): void;
  79635. /**
  79636. * Updates the current device position and rotation in the babylon world
  79637. */
  79638. update(): void;
  79639. /**
  79640. * @hidden
  79641. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79642. * @returns an identity matrix
  79643. */
  79644. _getViewMatrix(): Matrix;
  79645. private _tmpMatrix;
  79646. /**
  79647. * This function is called by the two RIG cameras.
  79648. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79649. * @hidden
  79650. */
  79651. _getWebVRViewMatrix(): Matrix;
  79652. /** @hidden */
  79653. _getWebVRProjectionMatrix(): Matrix;
  79654. private _onGamepadConnectedObserver;
  79655. private _onGamepadDisconnectedObserver;
  79656. private _updateCacheWhenTrackingDisabledObserver;
  79657. /**
  79658. * Initializes the controllers and their meshes
  79659. */
  79660. initControllers(): void;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. /**
  79665. * Size options for a post process
  79666. */
  79667. export type PostProcessOptions = {
  79668. width: number;
  79669. height: number;
  79670. };
  79671. /**
  79672. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79673. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79674. */
  79675. export class PostProcess {
  79676. /** Name of the PostProcess. */
  79677. name: string;
  79678. /**
  79679. * Gets or sets the unique id of the post process
  79680. */
  79681. uniqueId: number;
  79682. /**
  79683. * Width of the texture to apply the post process on
  79684. */
  79685. width: number;
  79686. /**
  79687. * Height of the texture to apply the post process on
  79688. */
  79689. height: number;
  79690. /**
  79691. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79692. * @hidden
  79693. */
  79694. _outputTexture: Nullable<InternalTexture>;
  79695. /**
  79696. * Sampling mode used by the shader
  79697. * See https://doc.babylonjs.com/classes/3.1/texture
  79698. */
  79699. renderTargetSamplingMode: number;
  79700. /**
  79701. * Clear color to use when screen clearing
  79702. */
  79703. clearColor: Color4;
  79704. /**
  79705. * If the buffer needs to be cleared before applying the post process. (default: true)
  79706. * Should be set to false if shader will overwrite all previous pixels.
  79707. */
  79708. autoClear: boolean;
  79709. /**
  79710. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79711. */
  79712. alphaMode: number;
  79713. /**
  79714. * Sets the setAlphaBlendConstants of the babylon engine
  79715. */
  79716. alphaConstants: Color4;
  79717. /**
  79718. * Animations to be used for the post processing
  79719. */
  79720. animations: Animation[];
  79721. /**
  79722. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79723. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79724. */
  79725. enablePixelPerfectMode: boolean;
  79726. /**
  79727. * Force the postprocess to be applied without taking in account viewport
  79728. */
  79729. forceFullscreenViewport: boolean;
  79730. /**
  79731. * List of inspectable custom properties (used by the Inspector)
  79732. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79733. */
  79734. inspectableCustomProperties: IInspectable[];
  79735. /**
  79736. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79737. *
  79738. * | Value | Type | Description |
  79739. * | ----- | ----------------------------------- | ----------- |
  79740. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79741. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79742. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79743. *
  79744. */
  79745. scaleMode: number;
  79746. /**
  79747. * Force textures to be a power of two (default: false)
  79748. */
  79749. alwaysForcePOT: boolean;
  79750. private _samples;
  79751. /**
  79752. * Number of sample textures (default: 1)
  79753. */
  79754. samples: number;
  79755. /**
  79756. * Modify the scale of the post process to be the same as the viewport (default: false)
  79757. */
  79758. adaptScaleToCurrentViewport: boolean;
  79759. private _camera;
  79760. private _scene;
  79761. private _engine;
  79762. private _options;
  79763. private _reusable;
  79764. private _textureType;
  79765. /**
  79766. * Smart array of input and output textures for the post process.
  79767. * @hidden
  79768. */
  79769. _textures: SmartArray<InternalTexture>;
  79770. /**
  79771. * The index in _textures that corresponds to the output texture.
  79772. * @hidden
  79773. */
  79774. _currentRenderTextureInd: number;
  79775. private _effect;
  79776. private _samplers;
  79777. private _fragmentUrl;
  79778. private _vertexUrl;
  79779. private _parameters;
  79780. private _scaleRatio;
  79781. protected _indexParameters: any;
  79782. private _shareOutputWithPostProcess;
  79783. private _texelSize;
  79784. private _forcedOutputTexture;
  79785. /**
  79786. * Returns the fragment url or shader name used in the post process.
  79787. * @returns the fragment url or name in the shader store.
  79788. */
  79789. getEffectName(): string;
  79790. /**
  79791. * An event triggered when the postprocess is activated.
  79792. */
  79793. onActivateObservable: Observable<Camera>;
  79794. private _onActivateObserver;
  79795. /**
  79796. * A function that is added to the onActivateObservable
  79797. */
  79798. onActivate: Nullable<(camera: Camera) => void>;
  79799. /**
  79800. * An event triggered when the postprocess changes its size.
  79801. */
  79802. onSizeChangedObservable: Observable<PostProcess>;
  79803. private _onSizeChangedObserver;
  79804. /**
  79805. * A function that is added to the onSizeChangedObservable
  79806. */
  79807. onSizeChanged: (postProcess: PostProcess) => void;
  79808. /**
  79809. * An event triggered when the postprocess applies its effect.
  79810. */
  79811. onApplyObservable: Observable<Effect>;
  79812. private _onApplyObserver;
  79813. /**
  79814. * A function that is added to the onApplyObservable
  79815. */
  79816. onApply: (effect: Effect) => void;
  79817. /**
  79818. * An event triggered before rendering the postprocess
  79819. */
  79820. onBeforeRenderObservable: Observable<Effect>;
  79821. private _onBeforeRenderObserver;
  79822. /**
  79823. * A function that is added to the onBeforeRenderObservable
  79824. */
  79825. onBeforeRender: (effect: Effect) => void;
  79826. /**
  79827. * An event triggered after rendering the postprocess
  79828. */
  79829. onAfterRenderObservable: Observable<Effect>;
  79830. private _onAfterRenderObserver;
  79831. /**
  79832. * A function that is added to the onAfterRenderObservable
  79833. */
  79834. onAfterRender: (efect: Effect) => void;
  79835. /**
  79836. * 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
  79837. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79838. */
  79839. inputTexture: InternalTexture;
  79840. /**
  79841. * Gets the camera which post process is applied to.
  79842. * @returns The camera the post process is applied to.
  79843. */
  79844. getCamera(): Camera;
  79845. /**
  79846. * Gets the texel size of the postprocess.
  79847. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79848. */
  79849. readonly texelSize: Vector2;
  79850. /**
  79851. * Creates a new instance PostProcess
  79852. * @param name The name of the PostProcess.
  79853. * @param fragmentUrl The url of the fragment shader to be used.
  79854. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79855. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79856. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79857. * @param camera The camera to apply the render pass to.
  79858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79859. * @param engine The engine which the post process will be applied. (default: current engine)
  79860. * @param reusable If the post process can be reused on the same frame. (default: false)
  79861. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79862. * @param textureType Type of textures used when performing the post process. (default: 0)
  79863. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79864. * @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
  79865. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79866. */
  79867. constructor(
  79868. /** Name of the PostProcess. */
  79869. 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);
  79870. /**
  79871. * Gets a string idenfifying the name of the class
  79872. * @returns "PostProcess" string
  79873. */
  79874. getClassName(): string;
  79875. /**
  79876. * Gets the engine which this post process belongs to.
  79877. * @returns The engine the post process was enabled with.
  79878. */
  79879. getEngine(): Engine;
  79880. /**
  79881. * The effect that is created when initializing the post process.
  79882. * @returns The created effect corresponding the the postprocess.
  79883. */
  79884. getEffect(): Effect;
  79885. /**
  79886. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79887. * @param postProcess The post process to share the output with.
  79888. * @returns This post process.
  79889. */
  79890. shareOutputWith(postProcess: PostProcess): PostProcess;
  79891. /**
  79892. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79893. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79894. */
  79895. useOwnOutput(): void;
  79896. /**
  79897. * Updates the effect with the current post process compile time values and recompiles the shader.
  79898. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79899. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79900. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79901. * @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
  79902. * @param onCompiled Called when the shader has been compiled.
  79903. * @param onError Called if there is an error when compiling a shader.
  79904. */
  79905. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79906. /**
  79907. * The post process is reusable if it can be used multiple times within one frame.
  79908. * @returns If the post process is reusable
  79909. */
  79910. isReusable(): boolean;
  79911. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79912. markTextureDirty(): void;
  79913. /**
  79914. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79915. * 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.
  79916. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79917. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79918. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79919. * @returns The target texture that was bound to be written to.
  79920. */
  79921. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79922. /**
  79923. * If the post process is supported.
  79924. */
  79925. readonly isSupported: boolean;
  79926. /**
  79927. * The aspect ratio of the output texture.
  79928. */
  79929. readonly aspectRatio: number;
  79930. /**
  79931. * Get a value indicating if the post-process is ready to be used
  79932. * @returns true if the post-process is ready (shader is compiled)
  79933. */
  79934. isReady(): boolean;
  79935. /**
  79936. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79937. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79938. */
  79939. apply(): Nullable<Effect>;
  79940. private _disposeTextures;
  79941. /**
  79942. * Disposes the post process.
  79943. * @param camera The camera to dispose the post process on.
  79944. */
  79945. dispose(camera?: Camera): void;
  79946. }
  79947. }
  79948. declare module BABYLON {
  79949. /** @hidden */
  79950. export var kernelBlurVaryingDeclaration: {
  79951. name: string;
  79952. shader: string;
  79953. };
  79954. }
  79955. declare module BABYLON {
  79956. /** @hidden */
  79957. export var kernelBlurFragment: {
  79958. name: string;
  79959. shader: string;
  79960. };
  79961. }
  79962. declare module BABYLON {
  79963. /** @hidden */
  79964. export var kernelBlurFragment2: {
  79965. name: string;
  79966. shader: string;
  79967. };
  79968. }
  79969. declare module BABYLON {
  79970. /** @hidden */
  79971. export var kernelBlurPixelShader: {
  79972. name: string;
  79973. shader: string;
  79974. };
  79975. }
  79976. declare module BABYLON {
  79977. /** @hidden */
  79978. export var kernelBlurVertex: {
  79979. name: string;
  79980. shader: string;
  79981. };
  79982. }
  79983. declare module BABYLON {
  79984. /** @hidden */
  79985. export var kernelBlurVertexShader: {
  79986. name: string;
  79987. shader: string;
  79988. };
  79989. }
  79990. declare module BABYLON {
  79991. /**
  79992. * The Blur Post Process which blurs an image based on a kernel and direction.
  79993. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79994. */
  79995. export class BlurPostProcess extends PostProcess {
  79996. /** The direction in which to blur the image. */
  79997. direction: Vector2;
  79998. private blockCompilation;
  79999. protected _kernel: number;
  80000. protected _idealKernel: number;
  80001. protected _packedFloat: boolean;
  80002. private _staticDefines;
  80003. /**
  80004. * Sets the length in pixels of the blur sample region
  80005. */
  80006. /**
  80007. * Gets the length in pixels of the blur sample region
  80008. */
  80009. kernel: number;
  80010. /**
  80011. * Sets wether or not the blur needs to unpack/repack floats
  80012. */
  80013. /**
  80014. * Gets wether or not the blur is unpacking/repacking floats
  80015. */
  80016. packedFloat: boolean;
  80017. /**
  80018. * Creates a new instance BlurPostProcess
  80019. * @param name The name of the effect.
  80020. * @param direction The direction in which to blur the image.
  80021. * @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.
  80022. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80023. * @param camera The camera to apply the render pass to.
  80024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80025. * @param engine The engine which the post process will be applied. (default: current engine)
  80026. * @param reusable If the post process can be reused on the same frame. (default: false)
  80027. * @param textureType Type of textures used when performing the post process. (default: 0)
  80028. * @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)
  80029. */
  80030. constructor(name: string,
  80031. /** The direction in which to blur the image. */
  80032. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80033. /**
  80034. * Updates the effect with the current post process compile time values and recompiles the shader.
  80035. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80036. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80037. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80038. * @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
  80039. * @param onCompiled Called when the shader has been compiled.
  80040. * @param onError Called if there is an error when compiling a shader.
  80041. */
  80042. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80043. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80044. /**
  80045. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80046. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80047. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80048. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80049. * The gaps between physical kernels are compensated for in the weighting of the samples
  80050. * @param idealKernel Ideal blur kernel.
  80051. * @return Nearest best kernel.
  80052. */
  80053. protected _nearestBestKernel(idealKernel: number): number;
  80054. /**
  80055. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80056. * @param x The point on the Gaussian distribution to sample.
  80057. * @return the value of the Gaussian function at x.
  80058. */
  80059. protected _gaussianWeight(x: number): number;
  80060. /**
  80061. * Generates a string that can be used as a floating point number in GLSL.
  80062. * @param x Value to print.
  80063. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80064. * @return GLSL float string.
  80065. */
  80066. protected _glslFloat(x: number, decimalFigures?: number): string;
  80067. }
  80068. }
  80069. declare module BABYLON {
  80070. /**
  80071. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80072. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80073. * You can then easily use it as a reflectionTexture on a flat surface.
  80074. * In case the surface is not a plane, please consider relying on reflection probes.
  80075. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80076. */
  80077. export class MirrorTexture extends RenderTargetTexture {
  80078. private scene;
  80079. /**
  80080. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80081. * 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.
  80082. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80083. */
  80084. mirrorPlane: Plane;
  80085. /**
  80086. * Define the blur ratio used to blur the reflection if needed.
  80087. */
  80088. blurRatio: number;
  80089. /**
  80090. * Define the adaptive blur kernel used to blur the reflection if needed.
  80091. * This will autocompute the closest best match for the `blurKernel`
  80092. */
  80093. adaptiveBlurKernel: number;
  80094. /**
  80095. * Define the blur kernel used to blur the reflection if needed.
  80096. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80097. */
  80098. blurKernel: number;
  80099. /**
  80100. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80101. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80102. */
  80103. blurKernelX: number;
  80104. /**
  80105. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80106. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80107. */
  80108. blurKernelY: number;
  80109. private _autoComputeBlurKernel;
  80110. protected _onRatioRescale(): void;
  80111. private _updateGammaSpace;
  80112. private _imageProcessingConfigChangeObserver;
  80113. private _transformMatrix;
  80114. private _mirrorMatrix;
  80115. private _savedViewMatrix;
  80116. private _blurX;
  80117. private _blurY;
  80118. private _adaptiveBlurKernel;
  80119. private _blurKernelX;
  80120. private _blurKernelY;
  80121. private _blurRatio;
  80122. /**
  80123. * Instantiates a Mirror Texture.
  80124. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80125. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80126. * You can then easily use it as a reflectionTexture on a flat surface.
  80127. * In case the surface is not a plane, please consider relying on reflection probes.
  80128. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80129. * @param name
  80130. * @param size
  80131. * @param scene
  80132. * @param generateMipMaps
  80133. * @param type
  80134. * @param samplingMode
  80135. * @param generateDepthBuffer
  80136. */
  80137. constructor(name: string, size: number | {
  80138. width: number;
  80139. height: number;
  80140. } | {
  80141. ratio: number;
  80142. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80143. private _preparePostProcesses;
  80144. /**
  80145. * Clone the mirror texture.
  80146. * @returns the cloned texture
  80147. */
  80148. clone(): MirrorTexture;
  80149. /**
  80150. * Serialize the texture to a JSON representation you could use in Parse later on
  80151. * @returns the serialized JSON representation
  80152. */
  80153. serialize(): any;
  80154. /**
  80155. * Dispose the texture and release its associated resources.
  80156. */
  80157. dispose(): void;
  80158. }
  80159. }
  80160. declare module BABYLON {
  80161. /**
  80162. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80163. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80164. */
  80165. export class Texture extends BaseTexture {
  80166. /** @hidden */
  80167. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80168. /** @hidden */
  80169. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80170. /** @hidden */
  80171. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80172. /** nearest is mag = nearest and min = nearest and mip = linear */
  80173. static readonly NEAREST_SAMPLINGMODE: number;
  80174. /** nearest is mag = nearest and min = nearest and mip = linear */
  80175. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80177. static readonly BILINEAR_SAMPLINGMODE: number;
  80178. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80179. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80180. /** Trilinear is mag = linear and min = linear and mip = linear */
  80181. static readonly TRILINEAR_SAMPLINGMODE: number;
  80182. /** Trilinear is mag = linear and min = linear and mip = linear */
  80183. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80184. /** mag = nearest and min = nearest and mip = nearest */
  80185. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80186. /** mag = nearest and min = linear and mip = nearest */
  80187. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80188. /** mag = nearest and min = linear and mip = linear */
  80189. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80190. /** mag = nearest and min = linear and mip = none */
  80191. static readonly NEAREST_LINEAR: number;
  80192. /** mag = nearest and min = nearest and mip = none */
  80193. static readonly NEAREST_NEAREST: number;
  80194. /** mag = linear and min = nearest and mip = nearest */
  80195. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80196. /** mag = linear and min = nearest and mip = linear */
  80197. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80198. /** mag = linear and min = linear and mip = none */
  80199. static readonly LINEAR_LINEAR: number;
  80200. /** mag = linear and min = nearest and mip = none */
  80201. static readonly LINEAR_NEAREST: number;
  80202. /** Explicit coordinates mode */
  80203. static readonly EXPLICIT_MODE: number;
  80204. /** Spherical coordinates mode */
  80205. static readonly SPHERICAL_MODE: number;
  80206. /** Planar coordinates mode */
  80207. static readonly PLANAR_MODE: number;
  80208. /** Cubic coordinates mode */
  80209. static readonly CUBIC_MODE: number;
  80210. /** Projection coordinates mode */
  80211. static readonly PROJECTION_MODE: number;
  80212. /** Inverse Cubic coordinates mode */
  80213. static readonly SKYBOX_MODE: number;
  80214. /** Inverse Cubic coordinates mode */
  80215. static readonly INVCUBIC_MODE: number;
  80216. /** Equirectangular coordinates mode */
  80217. static readonly EQUIRECTANGULAR_MODE: number;
  80218. /** Equirectangular Fixed coordinates mode */
  80219. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80220. /** Equirectangular Fixed Mirrored coordinates mode */
  80221. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80222. /** Texture is not repeating outside of 0..1 UVs */
  80223. static readonly CLAMP_ADDRESSMODE: number;
  80224. /** Texture is repeating outside of 0..1 UVs */
  80225. static readonly WRAP_ADDRESSMODE: number;
  80226. /** Texture is repeating and mirrored */
  80227. static readonly MIRROR_ADDRESSMODE: number;
  80228. /**
  80229. * 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
  80230. */
  80231. static UseSerializedUrlIfAny: boolean;
  80232. /**
  80233. * Define the url of the texture.
  80234. */
  80235. url: Nullable<string>;
  80236. /**
  80237. * Define an offset on the texture to offset the u coordinates of the UVs
  80238. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80239. */
  80240. uOffset: number;
  80241. /**
  80242. * Define an offset on the texture to offset the v coordinates of the UVs
  80243. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80244. */
  80245. vOffset: number;
  80246. /**
  80247. * Define an offset on the texture to scale the u coordinates of the UVs
  80248. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80249. */
  80250. uScale: number;
  80251. /**
  80252. * Define an offset on the texture to scale the v coordinates of the UVs
  80253. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80254. */
  80255. vScale: number;
  80256. /**
  80257. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80258. * @see http://doc.babylonjs.com/how_to/more_materials
  80259. */
  80260. uAng: number;
  80261. /**
  80262. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80263. * @see http://doc.babylonjs.com/how_to/more_materials
  80264. */
  80265. vAng: number;
  80266. /**
  80267. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80268. * @see http://doc.babylonjs.com/how_to/more_materials
  80269. */
  80270. wAng: number;
  80271. /**
  80272. * Defines the center of rotation (U)
  80273. */
  80274. uRotationCenter: number;
  80275. /**
  80276. * Defines the center of rotation (V)
  80277. */
  80278. vRotationCenter: number;
  80279. /**
  80280. * Defines the center of rotation (W)
  80281. */
  80282. wRotationCenter: number;
  80283. /**
  80284. * Are mip maps generated for this texture or not.
  80285. */
  80286. readonly noMipmap: boolean;
  80287. /**
  80288. * List of inspectable custom properties (used by the Inspector)
  80289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80290. */
  80291. inspectableCustomProperties: Nullable<IInspectable[]>;
  80292. private _noMipmap;
  80293. /** @hidden */
  80294. _invertY: boolean;
  80295. private _rowGenerationMatrix;
  80296. private _cachedTextureMatrix;
  80297. private _projectionModeMatrix;
  80298. private _t0;
  80299. private _t1;
  80300. private _t2;
  80301. private _cachedUOffset;
  80302. private _cachedVOffset;
  80303. private _cachedUScale;
  80304. private _cachedVScale;
  80305. private _cachedUAng;
  80306. private _cachedVAng;
  80307. private _cachedWAng;
  80308. private _cachedProjectionMatrixId;
  80309. private _cachedCoordinatesMode;
  80310. /** @hidden */
  80311. protected _initialSamplingMode: number;
  80312. /** @hidden */
  80313. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80314. private _deleteBuffer;
  80315. protected _format: Nullable<number>;
  80316. private _delayedOnLoad;
  80317. private _delayedOnError;
  80318. /**
  80319. * Observable triggered once the texture has been loaded.
  80320. */
  80321. onLoadObservable: Observable<Texture>;
  80322. protected _isBlocking: boolean;
  80323. /**
  80324. * Is the texture preventing material to render while loading.
  80325. * If false, a default texture will be used instead of the loading one during the preparation step.
  80326. */
  80327. isBlocking: boolean;
  80328. /**
  80329. * Get the current sampling mode associated with the texture.
  80330. */
  80331. readonly samplingMode: number;
  80332. /**
  80333. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80334. */
  80335. readonly invertY: boolean;
  80336. /**
  80337. * Instantiates a new texture.
  80338. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80339. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80340. * @param url define the url of the picture to load as a texture
  80341. * @param scene define the scene or engine the texture will belong to
  80342. * @param noMipmap define if the texture will require mip maps or not
  80343. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80344. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80345. * @param onLoad define a callback triggered when the texture has been loaded
  80346. * @param onError define a callback triggered when an error occurred during the loading session
  80347. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80348. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80349. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80350. */
  80351. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80352. /**
  80353. * Update the url (and optional buffer) of this texture if url was null during construction.
  80354. * @param url the url of the texture
  80355. * @param buffer the buffer of the texture (defaults to null)
  80356. * @param onLoad callback called when the texture is loaded (defaults to null)
  80357. */
  80358. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80359. /**
  80360. * Finish the loading sequence of a texture flagged as delayed load.
  80361. * @hidden
  80362. */
  80363. delayLoad(): void;
  80364. private _prepareRowForTextureGeneration;
  80365. /**
  80366. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80367. * @returns the transform matrix of the texture.
  80368. */
  80369. getTextureMatrix(): Matrix;
  80370. /**
  80371. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80372. * @returns The reflection texture transform
  80373. */
  80374. getReflectionTextureMatrix(): Matrix;
  80375. /**
  80376. * Clones the texture.
  80377. * @returns the cloned texture
  80378. */
  80379. clone(): Texture;
  80380. /**
  80381. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80382. * @returns The JSON representation of the texture
  80383. */
  80384. serialize(): any;
  80385. /**
  80386. * Get the current class name of the texture useful for serialization or dynamic coding.
  80387. * @returns "Texture"
  80388. */
  80389. getClassName(): string;
  80390. /**
  80391. * Dispose the texture and release its associated resources.
  80392. */
  80393. dispose(): void;
  80394. /**
  80395. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80396. * @param parsedTexture Define the JSON representation of the texture
  80397. * @param scene Define the scene the parsed texture should be instantiated in
  80398. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80399. * @returns The parsed texture if successful
  80400. */
  80401. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80402. /**
  80403. * Creates a texture from its base 64 representation.
  80404. * @param data Define the base64 payload without the data: prefix
  80405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80406. * @param scene Define the scene the texture should belong to
  80407. * @param noMipmap Forces the texture to not create mip map information if true
  80408. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80409. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80410. * @param onLoad define a callback triggered when the texture has been loaded
  80411. * @param onError define a callback triggered when an error occurred during the loading session
  80412. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80413. * @returns the created texture
  80414. */
  80415. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80416. /**
  80417. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80418. * @param data Define the base64 payload without the data: prefix
  80419. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80420. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80421. * @param scene Define the scene the texture should belong to
  80422. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80423. * @param noMipmap Forces the texture to not create mip map information if true
  80424. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80425. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80426. * @param onLoad define a callback triggered when the texture has been loaded
  80427. * @param onError define a callback triggered when an error occurred during the loading session
  80428. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80429. * @returns the created texture
  80430. */
  80431. 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;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /**
  80436. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80437. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80438. */
  80439. export class PostProcessManager {
  80440. private _scene;
  80441. private _indexBuffer;
  80442. private _vertexBuffers;
  80443. /**
  80444. * Creates a new instance PostProcess
  80445. * @param scene The scene that the post process is associated with.
  80446. */
  80447. constructor(scene: Scene);
  80448. private _prepareBuffers;
  80449. private _buildIndexBuffer;
  80450. /**
  80451. * Rebuilds the vertex buffers of the manager.
  80452. * @hidden
  80453. */
  80454. _rebuild(): void;
  80455. /**
  80456. * Prepares a frame to be run through a post process.
  80457. * @param sourceTexture The input texture to the post procesess. (default: null)
  80458. * @param postProcesses An array of post processes to be run. (default: null)
  80459. * @returns True if the post processes were able to be run.
  80460. * @hidden
  80461. */
  80462. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80463. /**
  80464. * Manually render a set of post processes to a texture.
  80465. * @param postProcesses An array of post processes to be run.
  80466. * @param targetTexture The target texture to render to.
  80467. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80468. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80469. * @param lodLevel defines which lod of the texture to render to
  80470. */
  80471. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80472. /**
  80473. * Finalize the result of the output of the postprocesses.
  80474. * @param doNotPresent If true the result will not be displayed to the screen.
  80475. * @param targetTexture The target texture to render to.
  80476. * @param faceIndex The index of the face to bind the target texture to.
  80477. * @param postProcesses The array of post processes to render.
  80478. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80479. * @hidden
  80480. */
  80481. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80482. /**
  80483. * Disposes of the post process manager.
  80484. */
  80485. dispose(): void;
  80486. }
  80487. }
  80488. declare module BABYLON {
  80489. /** Interface used by value gradients (color, factor, ...) */
  80490. export interface IValueGradient {
  80491. /**
  80492. * Gets or sets the gradient value (between 0 and 1)
  80493. */
  80494. gradient: number;
  80495. }
  80496. /** Class used to store color4 gradient */
  80497. export class ColorGradient implements IValueGradient {
  80498. /**
  80499. * Gets or sets the gradient value (between 0 and 1)
  80500. */
  80501. gradient: number;
  80502. /**
  80503. * Gets or sets first associated color
  80504. */
  80505. color1: Color4;
  80506. /**
  80507. * Gets or sets second associated color
  80508. */
  80509. color2?: Color4;
  80510. /**
  80511. * Will get a color picked randomly between color1 and color2.
  80512. * If color2 is undefined then color1 will be used
  80513. * @param result defines the target Color4 to store the result in
  80514. */
  80515. getColorToRef(result: Color4): void;
  80516. }
  80517. /** Class used to store color 3 gradient */
  80518. export class Color3Gradient implements IValueGradient {
  80519. /**
  80520. * Gets or sets the gradient value (between 0 and 1)
  80521. */
  80522. gradient: number;
  80523. /**
  80524. * Gets or sets the associated color
  80525. */
  80526. color: Color3;
  80527. }
  80528. /** Class used to store factor gradient */
  80529. export class FactorGradient implements IValueGradient {
  80530. /**
  80531. * Gets or sets the gradient value (between 0 and 1)
  80532. */
  80533. gradient: number;
  80534. /**
  80535. * Gets or sets first associated factor
  80536. */
  80537. factor1: number;
  80538. /**
  80539. * Gets or sets second associated factor
  80540. */
  80541. factor2?: number;
  80542. /**
  80543. * Will get a number picked randomly between factor1 and factor2.
  80544. * If factor2 is undefined then factor1 will be used
  80545. * @returns the picked number
  80546. */
  80547. getFactor(): number;
  80548. }
  80549. /**
  80550. * Helper used to simplify some generic gradient tasks
  80551. */
  80552. export class GradientHelper {
  80553. /**
  80554. * Gets the current gradient from an array of IValueGradient
  80555. * @param ratio defines the current ratio to get
  80556. * @param gradients defines the array of IValueGradient
  80557. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80558. */
  80559. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80560. }
  80561. }
  80562. declare module BABYLON {
  80563. interface AbstractScene {
  80564. /**
  80565. * The list of procedural textures added to the scene
  80566. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80567. */
  80568. proceduralTextures: Array<ProceduralTexture>;
  80569. }
  80570. /**
  80571. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80572. * in a given scene.
  80573. */
  80574. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80575. /**
  80576. * The component name helpfull to identify the component in the list of scene components.
  80577. */
  80578. readonly name: string;
  80579. /**
  80580. * The scene the component belongs to.
  80581. */
  80582. scene: Scene;
  80583. /**
  80584. * Creates a new instance of the component for the given scene
  80585. * @param scene Defines the scene to register the component in
  80586. */
  80587. constructor(scene: Scene);
  80588. /**
  80589. * Registers the component in a given scene
  80590. */
  80591. register(): void;
  80592. /**
  80593. * Rebuilds the elements related to this component in case of
  80594. * context lost for instance.
  80595. */
  80596. rebuild(): void;
  80597. /**
  80598. * Disposes the component and the associated ressources.
  80599. */
  80600. dispose(): void;
  80601. private _beforeClear;
  80602. }
  80603. }
  80604. declare module BABYLON {
  80605. interface Engine {
  80606. /**
  80607. * Creates a new render target cube texture
  80608. * @param size defines the size of the texture
  80609. * @param options defines the options used to create the texture
  80610. * @returns a new render target cube texture stored in an InternalTexture
  80611. */
  80612. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80613. }
  80614. }
  80615. declare module BABYLON {
  80616. /** @hidden */
  80617. export var proceduralVertexShader: {
  80618. name: string;
  80619. shader: string;
  80620. };
  80621. }
  80622. declare module BABYLON {
  80623. /**
  80624. * 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.
  80625. * This is the base class of any Procedural texture and contains most of the shareable code.
  80626. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80627. */
  80628. export class ProceduralTexture extends Texture {
  80629. isCube: boolean;
  80630. /**
  80631. * Define if the texture is enabled or not (disabled texture will not render)
  80632. */
  80633. isEnabled: boolean;
  80634. /**
  80635. * Define if the texture must be cleared before rendering (default is true)
  80636. */
  80637. autoClear: boolean;
  80638. /**
  80639. * Callback called when the texture is generated
  80640. */
  80641. onGenerated: () => void;
  80642. /**
  80643. * Event raised when the texture is generated
  80644. */
  80645. onGeneratedObservable: Observable<ProceduralTexture>;
  80646. /** @hidden */
  80647. _generateMipMaps: boolean;
  80648. /** @hidden **/
  80649. _effect: Effect;
  80650. /** @hidden */
  80651. _textures: {
  80652. [key: string]: Texture;
  80653. };
  80654. private _size;
  80655. private _currentRefreshId;
  80656. private _refreshRate;
  80657. private _vertexBuffers;
  80658. private _indexBuffer;
  80659. private _uniforms;
  80660. private _samplers;
  80661. private _fragment;
  80662. private _floats;
  80663. private _ints;
  80664. private _floatsArrays;
  80665. private _colors3;
  80666. private _colors4;
  80667. private _vectors2;
  80668. private _vectors3;
  80669. private _matrices;
  80670. private _fallbackTexture;
  80671. private _fallbackTextureUsed;
  80672. private _engine;
  80673. private _cachedDefines;
  80674. private _contentUpdateId;
  80675. private _contentData;
  80676. /**
  80677. * Instantiates a new procedural texture.
  80678. * 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.
  80679. * This is the base class of any Procedural texture and contains most of the shareable code.
  80680. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80681. * @param name Define the name of the texture
  80682. * @param size Define the size of the texture to create
  80683. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80684. * @param scene Define the scene the texture belongs to
  80685. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80686. * @param generateMipMaps Define if the texture should creates mip maps or not
  80687. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80688. */
  80689. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80690. /**
  80691. * The effect that is created when initializing the post process.
  80692. * @returns The created effect corresponding the the postprocess.
  80693. */
  80694. getEffect(): Effect;
  80695. /**
  80696. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80697. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80698. */
  80699. getContent(): Nullable<ArrayBufferView>;
  80700. private _createIndexBuffer;
  80701. /** @hidden */
  80702. _rebuild(): void;
  80703. /**
  80704. * Resets the texture in order to recreate its associated resources.
  80705. * This can be called in case of context loss
  80706. */
  80707. reset(): void;
  80708. protected _getDefines(): string;
  80709. /**
  80710. * Is the texture ready to be used ? (rendered at least once)
  80711. * @returns true if ready, otherwise, false.
  80712. */
  80713. isReady(): boolean;
  80714. /**
  80715. * Resets the refresh counter of the texture and start bak from scratch.
  80716. * Could be useful to regenerate the texture if it is setup to render only once.
  80717. */
  80718. resetRefreshCounter(): void;
  80719. /**
  80720. * Set the fragment shader to use in order to render the texture.
  80721. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80722. */
  80723. setFragment(fragment: any): void;
  80724. /**
  80725. * Define the refresh rate of the texture or the rendering frequency.
  80726. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80727. */
  80728. refreshRate: number;
  80729. /** @hidden */
  80730. _shouldRender(): boolean;
  80731. /**
  80732. * Get the size the texture is rendering at.
  80733. * @returns the size (texture is always squared)
  80734. */
  80735. getRenderSize(): number;
  80736. /**
  80737. * Resize the texture to new value.
  80738. * @param size Define the new size the texture should have
  80739. * @param generateMipMaps Define whether the new texture should create mip maps
  80740. */
  80741. resize(size: number, generateMipMaps: boolean): void;
  80742. private _checkUniform;
  80743. /**
  80744. * Set a texture in the shader program used to render.
  80745. * @param name Define the name of the uniform samplers as defined in the shader
  80746. * @param texture Define the texture to bind to this sampler
  80747. * @return the texture itself allowing "fluent" like uniform updates
  80748. */
  80749. setTexture(name: string, texture: Texture): ProceduralTexture;
  80750. /**
  80751. * Set a float in the shader.
  80752. * @param name Define the name of the uniform as defined in the shader
  80753. * @param value Define the value to give to the uniform
  80754. * @return the texture itself allowing "fluent" like uniform updates
  80755. */
  80756. setFloat(name: string, value: number): ProceduralTexture;
  80757. /**
  80758. * Set a int in the shader.
  80759. * @param name Define the name of the uniform as defined in the shader
  80760. * @param value Define the value to give to the uniform
  80761. * @return the texture itself allowing "fluent" like uniform updates
  80762. */
  80763. setInt(name: string, value: number): ProceduralTexture;
  80764. /**
  80765. * Set an array of floats in the shader.
  80766. * @param name Define the name of the uniform as defined in the shader
  80767. * @param value Define the value to give to the uniform
  80768. * @return the texture itself allowing "fluent" like uniform updates
  80769. */
  80770. setFloats(name: string, value: number[]): ProceduralTexture;
  80771. /**
  80772. * Set a vec3 in the shader from a Color3.
  80773. * @param name Define the name of the uniform as defined in the shader
  80774. * @param value Define the value to give to the uniform
  80775. * @return the texture itself allowing "fluent" like uniform updates
  80776. */
  80777. setColor3(name: string, value: Color3): ProceduralTexture;
  80778. /**
  80779. * Set a vec4 in the shader from a Color4.
  80780. * @param name Define the name of the uniform as defined in the shader
  80781. * @param value Define the value to give to the uniform
  80782. * @return the texture itself allowing "fluent" like uniform updates
  80783. */
  80784. setColor4(name: string, value: Color4): ProceduralTexture;
  80785. /**
  80786. * Set a vec2 in the shader from a Vector2.
  80787. * @param name Define the name of the uniform as defined in the shader
  80788. * @param value Define the value to give to the uniform
  80789. * @return the texture itself allowing "fluent" like uniform updates
  80790. */
  80791. setVector2(name: string, value: Vector2): ProceduralTexture;
  80792. /**
  80793. * Set a vec3 in the shader from a Vector3.
  80794. * @param name Define the name of the uniform as defined in the shader
  80795. * @param value Define the value to give to the uniform
  80796. * @return the texture itself allowing "fluent" like uniform updates
  80797. */
  80798. setVector3(name: string, value: Vector3): ProceduralTexture;
  80799. /**
  80800. * Set a mat4 in the shader from a MAtrix.
  80801. * @param name Define the name of the uniform as defined in the shader
  80802. * @param value Define the value to give to the uniform
  80803. * @return the texture itself allowing "fluent" like uniform updates
  80804. */
  80805. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80806. /**
  80807. * Render the texture to its associated render target.
  80808. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80809. */
  80810. render(useCameraPostProcess?: boolean): void;
  80811. /**
  80812. * Clone the texture.
  80813. * @returns the cloned texture
  80814. */
  80815. clone(): ProceduralTexture;
  80816. /**
  80817. * Dispose the texture and release its asoociated resources.
  80818. */
  80819. dispose(): void;
  80820. }
  80821. }
  80822. declare module BABYLON {
  80823. /**
  80824. * This represents the base class for particle system in Babylon.
  80825. * 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.
  80826. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80827. * @example https://doc.babylonjs.com/babylon101/particles
  80828. */
  80829. export class BaseParticleSystem {
  80830. /**
  80831. * Source color is added to the destination color without alpha affecting the result
  80832. */
  80833. static BLENDMODE_ONEONE: number;
  80834. /**
  80835. * Blend current color and particle color using particle’s alpha
  80836. */
  80837. static BLENDMODE_STANDARD: number;
  80838. /**
  80839. * Add current color and particle color multiplied by particle’s alpha
  80840. */
  80841. static BLENDMODE_ADD: number;
  80842. /**
  80843. * Multiply current color with particle color
  80844. */
  80845. static BLENDMODE_MULTIPLY: number;
  80846. /**
  80847. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80848. */
  80849. static BLENDMODE_MULTIPLYADD: number;
  80850. /**
  80851. * List of animations used by the particle system.
  80852. */
  80853. animations: Animation[];
  80854. /**
  80855. * The id of the Particle system.
  80856. */
  80857. id: string;
  80858. /**
  80859. * The friendly name of the Particle system.
  80860. */
  80861. name: string;
  80862. /**
  80863. * The rendering group used by the Particle system to chose when to render.
  80864. */
  80865. renderingGroupId: number;
  80866. /**
  80867. * The emitter represents the Mesh or position we are attaching the particle system to.
  80868. */
  80869. emitter: Nullable<AbstractMesh | Vector3>;
  80870. /**
  80871. * The maximum number of particles to emit per frame
  80872. */
  80873. emitRate: number;
  80874. /**
  80875. * If you want to launch only a few particles at once, that can be done, as well.
  80876. */
  80877. manualEmitCount: number;
  80878. /**
  80879. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80880. */
  80881. updateSpeed: number;
  80882. /**
  80883. * The amount of time the particle system is running (depends of the overall update speed).
  80884. */
  80885. targetStopDuration: number;
  80886. /**
  80887. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80888. */
  80889. disposeOnStop: boolean;
  80890. /**
  80891. * Minimum power of emitting particles.
  80892. */
  80893. minEmitPower: number;
  80894. /**
  80895. * Maximum power of emitting particles.
  80896. */
  80897. maxEmitPower: number;
  80898. /**
  80899. * Minimum life time of emitting particles.
  80900. */
  80901. minLifeTime: number;
  80902. /**
  80903. * Maximum life time of emitting particles.
  80904. */
  80905. maxLifeTime: number;
  80906. /**
  80907. * Minimum Size of emitting particles.
  80908. */
  80909. minSize: number;
  80910. /**
  80911. * Maximum Size of emitting particles.
  80912. */
  80913. maxSize: number;
  80914. /**
  80915. * Minimum scale of emitting particles on X axis.
  80916. */
  80917. minScaleX: number;
  80918. /**
  80919. * Maximum scale of emitting particles on X axis.
  80920. */
  80921. maxScaleX: number;
  80922. /**
  80923. * Minimum scale of emitting particles on Y axis.
  80924. */
  80925. minScaleY: number;
  80926. /**
  80927. * Maximum scale of emitting particles on Y axis.
  80928. */
  80929. maxScaleY: number;
  80930. /**
  80931. * Gets or sets the minimal initial rotation in radians.
  80932. */
  80933. minInitialRotation: number;
  80934. /**
  80935. * Gets or sets the maximal initial rotation in radians.
  80936. */
  80937. maxInitialRotation: number;
  80938. /**
  80939. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80940. */
  80941. minAngularSpeed: number;
  80942. /**
  80943. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80944. */
  80945. maxAngularSpeed: number;
  80946. /**
  80947. * The texture used to render each particle. (this can be a spritesheet)
  80948. */
  80949. particleTexture: Nullable<Texture>;
  80950. /**
  80951. * The layer mask we are rendering the particles through.
  80952. */
  80953. layerMask: number;
  80954. /**
  80955. * This can help using your own shader to render the particle system.
  80956. * The according effect will be created
  80957. */
  80958. customShader: any;
  80959. /**
  80960. * By default particle system starts as soon as they are created. This prevents the
  80961. * automatic start to happen and let you decide when to start emitting particles.
  80962. */
  80963. preventAutoStart: boolean;
  80964. private _noiseTexture;
  80965. /**
  80966. * Gets or sets a texture used to add random noise to particle positions
  80967. */
  80968. noiseTexture: Nullable<ProceduralTexture>;
  80969. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80970. noiseStrength: Vector3;
  80971. /**
  80972. * Callback triggered when the particle animation is ending.
  80973. */
  80974. onAnimationEnd: Nullable<() => void>;
  80975. /**
  80976. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80977. */
  80978. blendMode: number;
  80979. /**
  80980. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80981. * to override the particles.
  80982. */
  80983. forceDepthWrite: boolean;
  80984. /** 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 */
  80985. preWarmCycles: number;
  80986. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80987. preWarmStepOffset: number;
  80988. /**
  80989. * 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)
  80990. */
  80991. spriteCellChangeSpeed: number;
  80992. /**
  80993. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80994. */
  80995. startSpriteCellID: number;
  80996. /**
  80997. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80998. */
  80999. endSpriteCellID: number;
  81000. /**
  81001. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81002. */
  81003. spriteCellWidth: number;
  81004. /**
  81005. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81006. */
  81007. spriteCellHeight: number;
  81008. /**
  81009. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81010. */
  81011. spriteRandomStartCell: boolean;
  81012. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81013. translationPivot: Vector2;
  81014. /** @hidden */
  81015. protected _isAnimationSheetEnabled: boolean;
  81016. /**
  81017. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81018. */
  81019. beginAnimationOnStart: boolean;
  81020. /**
  81021. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81022. */
  81023. beginAnimationFrom: number;
  81024. /**
  81025. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81026. */
  81027. beginAnimationTo: number;
  81028. /**
  81029. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81030. */
  81031. beginAnimationLoop: boolean;
  81032. /**
  81033. * Gets or sets a world offset applied to all particles
  81034. */
  81035. worldOffset: Vector3;
  81036. /**
  81037. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81038. */
  81039. isAnimationSheetEnabled: boolean;
  81040. /**
  81041. * Get hosting scene
  81042. * @returns the scene
  81043. */
  81044. getScene(): Scene;
  81045. /**
  81046. * You can use gravity if you want to give an orientation to your particles.
  81047. */
  81048. gravity: Vector3;
  81049. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81050. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81051. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81052. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81053. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81054. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81055. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81056. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81057. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81058. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81059. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81060. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81061. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81062. /**
  81063. * Defines the delay in milliseconds before starting the system (0 by default)
  81064. */
  81065. startDelay: number;
  81066. /**
  81067. * Gets the current list of drag gradients.
  81068. * You must use addDragGradient and removeDragGradient to udpate this list
  81069. * @returns the list of drag gradients
  81070. */
  81071. getDragGradients(): Nullable<Array<FactorGradient>>;
  81072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81073. limitVelocityDamping: number;
  81074. /**
  81075. * Gets the current list of limit velocity gradients.
  81076. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81077. * @returns the list of limit velocity gradients
  81078. */
  81079. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81080. /**
  81081. * Gets the current list of color gradients.
  81082. * You must use addColorGradient and removeColorGradient to udpate this list
  81083. * @returns the list of color gradients
  81084. */
  81085. getColorGradients(): Nullable<Array<ColorGradient>>;
  81086. /**
  81087. * Gets the current list of size gradients.
  81088. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81089. * @returns the list of size gradients
  81090. */
  81091. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81092. /**
  81093. * Gets the current list of color remap gradients.
  81094. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81095. * @returns the list of color remap gradients
  81096. */
  81097. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81098. /**
  81099. * Gets the current list of alpha remap gradients.
  81100. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81101. * @returns the list of alpha remap gradients
  81102. */
  81103. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81104. /**
  81105. * Gets the current list of life time gradients.
  81106. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81107. * @returns the list of life time gradients
  81108. */
  81109. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81110. /**
  81111. * Gets the current list of angular speed gradients.
  81112. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81113. * @returns the list of angular speed gradients
  81114. */
  81115. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81116. /**
  81117. * Gets the current list of velocity gradients.
  81118. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81119. * @returns the list of velocity gradients
  81120. */
  81121. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81122. /**
  81123. * Gets the current list of start size gradients.
  81124. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81125. * @returns the list of start size gradients
  81126. */
  81127. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81128. /**
  81129. * Gets the current list of emit rate gradients.
  81130. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81131. * @returns the list of emit rate gradients
  81132. */
  81133. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81134. /**
  81135. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81136. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81137. */
  81138. direction1: Vector3;
  81139. /**
  81140. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81141. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81142. */
  81143. direction2: Vector3;
  81144. /**
  81145. * 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.
  81146. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81147. */
  81148. minEmitBox: Vector3;
  81149. /**
  81150. * 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.
  81151. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81152. */
  81153. maxEmitBox: Vector3;
  81154. /**
  81155. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81156. */
  81157. color1: Color4;
  81158. /**
  81159. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81160. */
  81161. color2: Color4;
  81162. /**
  81163. * Color the particle will have at the end of its lifetime
  81164. */
  81165. colorDead: Color4;
  81166. /**
  81167. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81168. */
  81169. textureMask: Color4;
  81170. /**
  81171. * The particle emitter type defines the emitter used by the particle system.
  81172. * It can be for example box, sphere, or cone...
  81173. */
  81174. particleEmitterType: IParticleEmitterType;
  81175. /** @hidden */
  81176. _isSubEmitter: boolean;
  81177. /**
  81178. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81179. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81180. */
  81181. billboardMode: number;
  81182. protected _isBillboardBased: boolean;
  81183. /**
  81184. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81185. */
  81186. isBillboardBased: boolean;
  81187. /**
  81188. * The scene the particle system belongs to.
  81189. */
  81190. protected _scene: Scene;
  81191. /**
  81192. * Local cache of defines for image processing.
  81193. */
  81194. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81195. /**
  81196. * Default configuration related to image processing available in the standard Material.
  81197. */
  81198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81199. /**
  81200. * Gets the image processing configuration used either in this material.
  81201. */
  81202. /**
  81203. * Sets the Default image processing configuration used either in the this material.
  81204. *
  81205. * If sets to null, the scene one is in use.
  81206. */
  81207. imageProcessingConfiguration: ImageProcessingConfiguration;
  81208. /**
  81209. * Attaches a new image processing configuration to the Standard Material.
  81210. * @param configuration
  81211. */
  81212. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81213. /** @hidden */
  81214. protected _reset(): void;
  81215. /** @hidden */
  81216. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81217. /**
  81218. * Instantiates a particle system.
  81219. * 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.
  81220. * @param name The name of the particle system
  81221. */
  81222. constructor(name: string);
  81223. /**
  81224. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81225. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81226. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81227. * @returns the emitter
  81228. */
  81229. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81230. /**
  81231. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81232. * @param radius The radius of the hemisphere to emit from
  81233. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81234. * @returns the emitter
  81235. */
  81236. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81237. /**
  81238. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81239. * @param radius The radius of the sphere to emit from
  81240. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81241. * @returns the emitter
  81242. */
  81243. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81244. /**
  81245. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81246. * @param radius The radius of the sphere to emit from
  81247. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81248. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81249. * @returns the emitter
  81250. */
  81251. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81252. /**
  81253. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81254. * @param radius The radius of the emission cylinder
  81255. * @param height The height of the emission cylinder
  81256. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81257. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81258. * @returns the emitter
  81259. */
  81260. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81261. /**
  81262. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81263. * @param radius The radius of the cylinder to emit from
  81264. * @param height The height of the emission cylinder
  81265. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81266. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81267. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81268. * @returns the emitter
  81269. */
  81270. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81271. /**
  81272. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81273. * @param radius The radius of the cone to emit from
  81274. * @param angle The base angle of the cone
  81275. * @returns the emitter
  81276. */
  81277. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81278. /**
  81279. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81280. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81281. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81282. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81283. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81284. * @returns the emitter
  81285. */
  81286. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81287. }
  81288. }
  81289. declare module BABYLON {
  81290. /**
  81291. * Type of sub emitter
  81292. */
  81293. export enum SubEmitterType {
  81294. /**
  81295. * Attached to the particle over it's lifetime
  81296. */
  81297. ATTACHED = 0,
  81298. /**
  81299. * Created when the particle dies
  81300. */
  81301. END = 1
  81302. }
  81303. /**
  81304. * Sub emitter class used to emit particles from an existing particle
  81305. */
  81306. export class SubEmitter {
  81307. /**
  81308. * the particle system to be used by the sub emitter
  81309. */
  81310. particleSystem: ParticleSystem;
  81311. /**
  81312. * Type of the submitter (Default: END)
  81313. */
  81314. type: SubEmitterType;
  81315. /**
  81316. * 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)
  81317. * Note: This only is supported when using an emitter of type Mesh
  81318. */
  81319. inheritDirection: boolean;
  81320. /**
  81321. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81322. */
  81323. inheritedVelocityAmount: number;
  81324. /**
  81325. * Creates a sub emitter
  81326. * @param particleSystem the particle system to be used by the sub emitter
  81327. */
  81328. constructor(
  81329. /**
  81330. * the particle system to be used by the sub emitter
  81331. */
  81332. particleSystem: ParticleSystem);
  81333. /**
  81334. * Clones the sub emitter
  81335. * @returns the cloned sub emitter
  81336. */
  81337. clone(): SubEmitter;
  81338. /**
  81339. * Serialize current object to a JSON object
  81340. * @returns the serialized object
  81341. */
  81342. serialize(): any;
  81343. /** @hidden */
  81344. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81345. /**
  81346. * Creates a new SubEmitter from a serialized JSON version
  81347. * @param serializationObject defines the JSON object to read from
  81348. * @param scene defines the hosting scene
  81349. * @param rootUrl defines the rootUrl for data loading
  81350. * @returns a new SubEmitter
  81351. */
  81352. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81353. /** Release associated resources */
  81354. dispose(): void;
  81355. }
  81356. }
  81357. declare module BABYLON {
  81358. /** @hidden */
  81359. export var clipPlaneFragmentDeclaration: {
  81360. name: string;
  81361. shader: string;
  81362. };
  81363. }
  81364. declare module BABYLON {
  81365. /** @hidden */
  81366. export var imageProcessingDeclaration: {
  81367. name: string;
  81368. shader: string;
  81369. };
  81370. }
  81371. declare module BABYLON {
  81372. /** @hidden */
  81373. export var imageProcessingFunctions: {
  81374. name: string;
  81375. shader: string;
  81376. };
  81377. }
  81378. declare module BABYLON {
  81379. /** @hidden */
  81380. export var clipPlaneFragment: {
  81381. name: string;
  81382. shader: string;
  81383. };
  81384. }
  81385. declare module BABYLON {
  81386. /** @hidden */
  81387. export var particlesPixelShader: {
  81388. name: string;
  81389. shader: string;
  81390. };
  81391. }
  81392. declare module BABYLON {
  81393. /** @hidden */
  81394. export var clipPlaneVertexDeclaration: {
  81395. name: string;
  81396. shader: string;
  81397. };
  81398. }
  81399. declare module BABYLON {
  81400. /** @hidden */
  81401. export var clipPlaneVertex: {
  81402. name: string;
  81403. shader: string;
  81404. };
  81405. }
  81406. declare module BABYLON {
  81407. /** @hidden */
  81408. export var particlesVertexShader: {
  81409. name: string;
  81410. shader: string;
  81411. };
  81412. }
  81413. declare module BABYLON {
  81414. /**
  81415. * This represents a particle system in Babylon.
  81416. * 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.
  81417. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81418. * @example https://doc.babylonjs.com/babylon101/particles
  81419. */
  81420. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81421. /**
  81422. * Billboard mode will only apply to Y axis
  81423. */
  81424. static readonly BILLBOARDMODE_Y: number;
  81425. /**
  81426. * Billboard mode will apply to all axes
  81427. */
  81428. static readonly BILLBOARDMODE_ALL: number;
  81429. /**
  81430. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81431. */
  81432. static readonly BILLBOARDMODE_STRETCHED: number;
  81433. /**
  81434. * This function can be defined to provide custom update for active particles.
  81435. * This function will be called instead of regular update (age, position, color, etc.).
  81436. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81437. */
  81438. updateFunction: (particles: Particle[]) => void;
  81439. private _emitterWorldMatrix;
  81440. /**
  81441. * This function can be defined to specify initial direction for every new particle.
  81442. * It by default use the emitterType defined function
  81443. */
  81444. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81445. /**
  81446. * This function can be defined to specify initial position for every new particle.
  81447. * It by default use the emitterType defined function
  81448. */
  81449. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81450. /**
  81451. * @hidden
  81452. */
  81453. _inheritedVelocityOffset: Vector3;
  81454. /**
  81455. * An event triggered when the system is disposed
  81456. */
  81457. onDisposeObservable: Observable<ParticleSystem>;
  81458. private _onDisposeObserver;
  81459. /**
  81460. * Sets a callback that will be triggered when the system is disposed
  81461. */
  81462. onDispose: () => void;
  81463. private _particles;
  81464. private _epsilon;
  81465. private _capacity;
  81466. private _stockParticles;
  81467. private _newPartsExcess;
  81468. private _vertexData;
  81469. private _vertexBuffer;
  81470. private _vertexBuffers;
  81471. private _spriteBuffer;
  81472. private _indexBuffer;
  81473. private _effect;
  81474. private _customEffect;
  81475. private _cachedDefines;
  81476. private _scaledColorStep;
  81477. private _colorDiff;
  81478. private _scaledDirection;
  81479. private _scaledGravity;
  81480. private _currentRenderId;
  81481. private _alive;
  81482. private _useInstancing;
  81483. private _started;
  81484. private _stopped;
  81485. private _actualFrame;
  81486. private _scaledUpdateSpeed;
  81487. private _vertexBufferSize;
  81488. /** @hidden */
  81489. _currentEmitRateGradient: Nullable<FactorGradient>;
  81490. /** @hidden */
  81491. _currentEmitRate1: number;
  81492. /** @hidden */
  81493. _currentEmitRate2: number;
  81494. /** @hidden */
  81495. _currentStartSizeGradient: Nullable<FactorGradient>;
  81496. /** @hidden */
  81497. _currentStartSize1: number;
  81498. /** @hidden */
  81499. _currentStartSize2: number;
  81500. private readonly _rawTextureWidth;
  81501. private _rampGradientsTexture;
  81502. private _useRampGradients;
  81503. /** Gets or sets a boolean indicating that ramp gradients must be used
  81504. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81505. */
  81506. useRampGradients: boolean;
  81507. /**
  81508. * 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.
  81509. * 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: [])
  81510. */
  81511. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81512. private _subEmitters;
  81513. /**
  81514. * @hidden
  81515. * If the particle systems emitter should be disposed when the particle system is disposed
  81516. */
  81517. _disposeEmitterOnDispose: boolean;
  81518. /**
  81519. * The current active Sub-systems, this property is used by the root particle system only.
  81520. */
  81521. activeSubSystems: Array<ParticleSystem>;
  81522. private _rootParticleSystem;
  81523. /**
  81524. * Gets the current list of active particles
  81525. */
  81526. readonly particles: Particle[];
  81527. /**
  81528. * Returns the string "ParticleSystem"
  81529. * @returns a string containing the class name
  81530. */
  81531. getClassName(): string;
  81532. /**
  81533. * Instantiates a particle system.
  81534. * 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.
  81535. * @param name The name of the particle system
  81536. * @param capacity The max number of particles alive at the same time
  81537. * @param scene The scene the particle system belongs to
  81538. * @param customEffect a custom effect used to change the way particles are rendered by default
  81539. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81540. * @param epsilon Offset used to render the particles
  81541. */
  81542. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81543. private _addFactorGradient;
  81544. private _removeFactorGradient;
  81545. /**
  81546. * Adds a new life time gradient
  81547. * @param gradient defines the gradient to use (between 0 and 1)
  81548. * @param factor defines the life time factor to affect to the specified gradient
  81549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81550. * @returns the current particle system
  81551. */
  81552. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81553. /**
  81554. * Remove a specific life time gradient
  81555. * @param gradient defines the gradient to remove
  81556. * @returns the current particle system
  81557. */
  81558. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81559. /**
  81560. * Adds a new size gradient
  81561. * @param gradient defines the gradient to use (between 0 and 1)
  81562. * @param factor defines the size factor to affect to the specified gradient
  81563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81564. * @returns the current particle system
  81565. */
  81566. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81567. /**
  81568. * Remove a specific size gradient
  81569. * @param gradient defines the gradient to remove
  81570. * @returns the current particle system
  81571. */
  81572. removeSizeGradient(gradient: number): IParticleSystem;
  81573. /**
  81574. * Adds a new color remap gradient
  81575. * @param gradient defines the gradient to use (between 0 and 1)
  81576. * @param min defines the color remap minimal range
  81577. * @param max defines the color remap maximal range
  81578. * @returns the current particle system
  81579. */
  81580. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81581. /**
  81582. * Remove a specific color remap gradient
  81583. * @param gradient defines the gradient to remove
  81584. * @returns the current particle system
  81585. */
  81586. removeColorRemapGradient(gradient: number): IParticleSystem;
  81587. /**
  81588. * Adds a new alpha remap gradient
  81589. * @param gradient defines the gradient to use (between 0 and 1)
  81590. * @param min defines the alpha remap minimal range
  81591. * @param max defines the alpha remap maximal range
  81592. * @returns the current particle system
  81593. */
  81594. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81595. /**
  81596. * Remove a specific alpha remap gradient
  81597. * @param gradient defines the gradient to remove
  81598. * @returns the current particle system
  81599. */
  81600. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81601. /**
  81602. * Adds a new angular speed gradient
  81603. * @param gradient defines the gradient to use (between 0 and 1)
  81604. * @param factor defines the angular speed to affect to the specified gradient
  81605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81606. * @returns the current particle system
  81607. */
  81608. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81609. /**
  81610. * Remove a specific angular speed gradient
  81611. * @param gradient defines the gradient to remove
  81612. * @returns the current particle system
  81613. */
  81614. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81615. /**
  81616. * Adds a new velocity gradient
  81617. * @param gradient defines the gradient to use (between 0 and 1)
  81618. * @param factor defines the velocity to affect to the specified gradient
  81619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81620. * @returns the current particle system
  81621. */
  81622. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81623. /**
  81624. * Remove a specific velocity gradient
  81625. * @param gradient defines the gradient to remove
  81626. * @returns the current particle system
  81627. */
  81628. removeVelocityGradient(gradient: number): IParticleSystem;
  81629. /**
  81630. * Adds a new limit velocity gradient
  81631. * @param gradient defines the gradient to use (between 0 and 1)
  81632. * @param factor defines the limit velocity value to affect to the specified gradient
  81633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81634. * @returns the current particle system
  81635. */
  81636. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81637. /**
  81638. * Remove a specific limit velocity gradient
  81639. * @param gradient defines the gradient to remove
  81640. * @returns the current particle system
  81641. */
  81642. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81643. /**
  81644. * Adds a new drag gradient
  81645. * @param gradient defines the gradient to use (between 0 and 1)
  81646. * @param factor defines the drag value to affect to the specified gradient
  81647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81648. * @returns the current particle system
  81649. */
  81650. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81651. /**
  81652. * Remove a specific drag gradient
  81653. * @param gradient defines the gradient to remove
  81654. * @returns the current particle system
  81655. */
  81656. removeDragGradient(gradient: number): IParticleSystem;
  81657. /**
  81658. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81659. * @param gradient defines the gradient to use (between 0 and 1)
  81660. * @param factor defines the emit rate value to affect to the specified gradient
  81661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81662. * @returns the current particle system
  81663. */
  81664. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81665. /**
  81666. * Remove a specific emit rate gradient
  81667. * @param gradient defines the gradient to remove
  81668. * @returns the current particle system
  81669. */
  81670. removeEmitRateGradient(gradient: number): IParticleSystem;
  81671. /**
  81672. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81673. * @param gradient defines the gradient to use (between 0 and 1)
  81674. * @param factor defines the start size value to affect to the specified gradient
  81675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81676. * @returns the current particle system
  81677. */
  81678. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81679. /**
  81680. * Remove a specific start size gradient
  81681. * @param gradient defines the gradient to remove
  81682. * @returns the current particle system
  81683. */
  81684. removeStartSizeGradient(gradient: number): IParticleSystem;
  81685. private _createRampGradientTexture;
  81686. /**
  81687. * Gets the current list of ramp gradients.
  81688. * You must use addRampGradient and removeRampGradient to udpate this list
  81689. * @returns the list of ramp gradients
  81690. */
  81691. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81692. /**
  81693. * Adds a new ramp gradient used to remap particle colors
  81694. * @param gradient defines the gradient to use (between 0 and 1)
  81695. * @param color defines the color to affect to the specified gradient
  81696. * @returns the current particle system
  81697. */
  81698. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81699. /**
  81700. * Remove a specific ramp gradient
  81701. * @param gradient defines the gradient to remove
  81702. * @returns the current particle system
  81703. */
  81704. removeRampGradient(gradient: number): ParticleSystem;
  81705. /**
  81706. * Adds a new color gradient
  81707. * @param gradient defines the gradient to use (between 0 and 1)
  81708. * @param color1 defines the color to affect to the specified gradient
  81709. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81710. * @returns this particle system
  81711. */
  81712. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81713. /**
  81714. * Remove a specific color gradient
  81715. * @param gradient defines the gradient to remove
  81716. * @returns this particle system
  81717. */
  81718. removeColorGradient(gradient: number): IParticleSystem;
  81719. private _fetchR;
  81720. protected _reset(): void;
  81721. private _resetEffect;
  81722. private _createVertexBuffers;
  81723. private _createIndexBuffer;
  81724. /**
  81725. * Gets the maximum number of particles active at the same time.
  81726. * @returns The max number of active particles.
  81727. */
  81728. getCapacity(): number;
  81729. /**
  81730. * Gets whether there are still active particles in the system.
  81731. * @returns True if it is alive, otherwise false.
  81732. */
  81733. isAlive(): boolean;
  81734. /**
  81735. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81736. * @returns True if it has been started, otherwise false.
  81737. */
  81738. isStarted(): boolean;
  81739. private _prepareSubEmitterInternalArray;
  81740. /**
  81741. * Starts the particle system and begins to emit
  81742. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81743. */
  81744. start(delay?: number): void;
  81745. /**
  81746. * Stops the particle system.
  81747. * @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.
  81748. */
  81749. stop(stopSubEmitters?: boolean): void;
  81750. /**
  81751. * Remove all active particles
  81752. */
  81753. reset(): void;
  81754. /**
  81755. * @hidden (for internal use only)
  81756. */
  81757. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81758. /**
  81759. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81760. * Its lifetime will start back at 0.
  81761. */
  81762. recycleParticle: (particle: Particle) => void;
  81763. private _stopSubEmitters;
  81764. private _createParticle;
  81765. private _removeFromRoot;
  81766. private _emitFromParticle;
  81767. private _update;
  81768. /** @hidden */
  81769. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81770. /** @hidden */
  81771. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81772. /** @hidden */
  81773. private _getEffect;
  81774. /**
  81775. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81776. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81777. */
  81778. animate(preWarmOnly?: boolean): void;
  81779. private _appendParticleVertices;
  81780. /**
  81781. * Rebuilds the particle system.
  81782. */
  81783. rebuild(): void;
  81784. /**
  81785. * Is this system ready to be used/rendered
  81786. * @return true if the system is ready
  81787. */
  81788. isReady(): boolean;
  81789. private _render;
  81790. /**
  81791. * Renders the particle system in its current state.
  81792. * @returns the current number of particles
  81793. */
  81794. render(): number;
  81795. /**
  81796. * Disposes the particle system and free the associated resources
  81797. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81798. */
  81799. dispose(disposeTexture?: boolean): void;
  81800. /**
  81801. * Clones the particle system.
  81802. * @param name The name of the cloned object
  81803. * @param newEmitter The new emitter to use
  81804. * @returns the cloned particle system
  81805. */
  81806. clone(name: string, newEmitter: any): ParticleSystem;
  81807. /**
  81808. * Serializes the particle system to a JSON object.
  81809. * @returns the JSON object
  81810. */
  81811. serialize(): any;
  81812. /** @hidden */
  81813. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81814. /** @hidden */
  81815. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81816. /**
  81817. * Parses a JSON object to create a particle system.
  81818. * @param parsedParticleSystem The JSON object to parse
  81819. * @param scene The scene to create the particle system in
  81820. * @param rootUrl The root url to use to load external dependencies like texture
  81821. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81822. * @returns the Parsed particle system
  81823. */
  81824. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /**
  81829. * A particle represents one of the element emitted by a particle system.
  81830. * This is mainly define by its coordinates, direction, velocity and age.
  81831. */
  81832. export class Particle {
  81833. /**
  81834. * The particle system the particle belongs to.
  81835. */
  81836. particleSystem: ParticleSystem;
  81837. private static _Count;
  81838. /**
  81839. * Unique ID of the particle
  81840. */
  81841. id: number;
  81842. /**
  81843. * The world position of the particle in the scene.
  81844. */
  81845. position: Vector3;
  81846. /**
  81847. * The world direction of the particle in the scene.
  81848. */
  81849. direction: Vector3;
  81850. /**
  81851. * The color of the particle.
  81852. */
  81853. color: Color4;
  81854. /**
  81855. * The color change of the particle per step.
  81856. */
  81857. colorStep: Color4;
  81858. /**
  81859. * Defines how long will the life of the particle be.
  81860. */
  81861. lifeTime: number;
  81862. /**
  81863. * The current age of the particle.
  81864. */
  81865. age: number;
  81866. /**
  81867. * The current size of the particle.
  81868. */
  81869. size: number;
  81870. /**
  81871. * The current scale of the particle.
  81872. */
  81873. scale: Vector2;
  81874. /**
  81875. * The current angle of the particle.
  81876. */
  81877. angle: number;
  81878. /**
  81879. * Defines how fast is the angle changing.
  81880. */
  81881. angularSpeed: number;
  81882. /**
  81883. * Defines the cell index used by the particle to be rendered from a sprite.
  81884. */
  81885. cellIndex: number;
  81886. /**
  81887. * The information required to support color remapping
  81888. */
  81889. remapData: Vector4;
  81890. /** @hidden */
  81891. _randomCellOffset?: number;
  81892. /** @hidden */
  81893. _initialDirection: Nullable<Vector3>;
  81894. /** @hidden */
  81895. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81896. /** @hidden */
  81897. _initialStartSpriteCellID: number;
  81898. /** @hidden */
  81899. _initialEndSpriteCellID: number;
  81900. /** @hidden */
  81901. _currentColorGradient: Nullable<ColorGradient>;
  81902. /** @hidden */
  81903. _currentColor1: Color4;
  81904. /** @hidden */
  81905. _currentColor2: Color4;
  81906. /** @hidden */
  81907. _currentSizeGradient: Nullable<FactorGradient>;
  81908. /** @hidden */
  81909. _currentSize1: number;
  81910. /** @hidden */
  81911. _currentSize2: number;
  81912. /** @hidden */
  81913. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81914. /** @hidden */
  81915. _currentAngularSpeed1: number;
  81916. /** @hidden */
  81917. _currentAngularSpeed2: number;
  81918. /** @hidden */
  81919. _currentVelocityGradient: Nullable<FactorGradient>;
  81920. /** @hidden */
  81921. _currentVelocity1: number;
  81922. /** @hidden */
  81923. _currentVelocity2: number;
  81924. /** @hidden */
  81925. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81926. /** @hidden */
  81927. _currentLimitVelocity1: number;
  81928. /** @hidden */
  81929. _currentLimitVelocity2: number;
  81930. /** @hidden */
  81931. _currentDragGradient: Nullable<FactorGradient>;
  81932. /** @hidden */
  81933. _currentDrag1: number;
  81934. /** @hidden */
  81935. _currentDrag2: number;
  81936. /** @hidden */
  81937. _randomNoiseCoordinates1: Vector3;
  81938. /** @hidden */
  81939. _randomNoiseCoordinates2: Vector3;
  81940. /**
  81941. * Creates a new instance Particle
  81942. * @param particleSystem the particle system the particle belongs to
  81943. */
  81944. constructor(
  81945. /**
  81946. * The particle system the particle belongs to.
  81947. */
  81948. particleSystem: ParticleSystem);
  81949. private updateCellInfoFromSystem;
  81950. /**
  81951. * Defines how the sprite cell index is updated for the particle
  81952. */
  81953. updateCellIndex(): void;
  81954. /** @hidden */
  81955. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81956. /** @hidden */
  81957. _inheritParticleInfoToSubEmitters(): void;
  81958. /** @hidden */
  81959. _reset(): void;
  81960. /**
  81961. * Copy the properties of particle to another one.
  81962. * @param other the particle to copy the information to.
  81963. */
  81964. copyTo(other: Particle): void;
  81965. }
  81966. }
  81967. declare module BABYLON {
  81968. /**
  81969. * Particle emitter represents a volume emitting particles.
  81970. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81971. */
  81972. export interface IParticleEmitterType {
  81973. /**
  81974. * Called by the particle System when the direction is computed for the created particle.
  81975. * @param worldMatrix is the world matrix of the particle system
  81976. * @param directionToUpdate is the direction vector to update with the result
  81977. * @param particle is the particle we are computed the direction for
  81978. */
  81979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81980. /**
  81981. * Called by the particle System when the position is computed for the created particle.
  81982. * @param worldMatrix is the world matrix of the particle system
  81983. * @param positionToUpdate is the position vector to update with the result
  81984. * @param particle is the particle we are computed the position for
  81985. */
  81986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81987. /**
  81988. * Clones the current emitter and returns a copy of it
  81989. * @returns the new emitter
  81990. */
  81991. clone(): IParticleEmitterType;
  81992. /**
  81993. * Called by the GPUParticleSystem to setup the update shader
  81994. * @param effect defines the update shader
  81995. */
  81996. applyToShader(effect: Effect): void;
  81997. /**
  81998. * Returns a string to use to update the GPU particles update shader
  81999. * @returns the effect defines string
  82000. */
  82001. getEffectDefines(): string;
  82002. /**
  82003. * Returns a string representing the class name
  82004. * @returns a string containing the class name
  82005. */
  82006. getClassName(): string;
  82007. /**
  82008. * Serializes the particle system to a JSON object.
  82009. * @returns the JSON object
  82010. */
  82011. serialize(): any;
  82012. /**
  82013. * Parse properties from a JSON object
  82014. * @param serializationObject defines the JSON object
  82015. */
  82016. parse(serializationObject: any): void;
  82017. }
  82018. }
  82019. declare module BABYLON {
  82020. /**
  82021. * Particle emitter emitting particles from the inside of a box.
  82022. * It emits the particles randomly between 2 given directions.
  82023. */
  82024. export class BoxParticleEmitter implements IParticleEmitterType {
  82025. /**
  82026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82027. */
  82028. direction1: Vector3;
  82029. /**
  82030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82031. */
  82032. direction2: Vector3;
  82033. /**
  82034. * 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.
  82035. */
  82036. minEmitBox: Vector3;
  82037. /**
  82038. * 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.
  82039. */
  82040. maxEmitBox: Vector3;
  82041. /**
  82042. * Creates a new instance BoxParticleEmitter
  82043. */
  82044. constructor();
  82045. /**
  82046. * Called by the particle System when the direction is computed for the created particle.
  82047. * @param worldMatrix is the world matrix of the particle system
  82048. * @param directionToUpdate is the direction vector to update with the result
  82049. * @param particle is the particle we are computed the direction for
  82050. */
  82051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82052. /**
  82053. * Called by the particle System when the position is computed for the created particle.
  82054. * @param worldMatrix is the world matrix of the particle system
  82055. * @param positionToUpdate is the position vector to update with the result
  82056. * @param particle is the particle we are computed the position for
  82057. */
  82058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82059. /**
  82060. * Clones the current emitter and returns a copy of it
  82061. * @returns the new emitter
  82062. */
  82063. clone(): BoxParticleEmitter;
  82064. /**
  82065. * Called by the GPUParticleSystem to setup the update shader
  82066. * @param effect defines the update shader
  82067. */
  82068. applyToShader(effect: Effect): void;
  82069. /**
  82070. * Returns a string to use to update the GPU particles update shader
  82071. * @returns a string containng the defines string
  82072. */
  82073. getEffectDefines(): string;
  82074. /**
  82075. * Returns the string "BoxParticleEmitter"
  82076. * @returns a string containing the class name
  82077. */
  82078. getClassName(): string;
  82079. /**
  82080. * Serializes the particle system to a JSON object.
  82081. * @returns the JSON object
  82082. */
  82083. serialize(): any;
  82084. /**
  82085. * Parse properties from a JSON object
  82086. * @param serializationObject defines the JSON object
  82087. */
  82088. parse(serializationObject: any): void;
  82089. }
  82090. }
  82091. declare module BABYLON {
  82092. /**
  82093. * Particle emitter emitting particles from the inside of a cone.
  82094. * It emits the particles alongside the cone volume from the base to the particle.
  82095. * The emission direction might be randomized.
  82096. */
  82097. export class ConeParticleEmitter implements IParticleEmitterType {
  82098. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82099. directionRandomizer: number;
  82100. private _radius;
  82101. private _angle;
  82102. private _height;
  82103. /**
  82104. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82105. */
  82106. radiusRange: number;
  82107. /**
  82108. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82109. */
  82110. heightRange: number;
  82111. /**
  82112. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82113. */
  82114. emitFromSpawnPointOnly: boolean;
  82115. /**
  82116. * Gets or sets the radius of the emission cone
  82117. */
  82118. radius: number;
  82119. /**
  82120. * Gets or sets the angle of the emission cone
  82121. */
  82122. angle: number;
  82123. private _buildHeight;
  82124. /**
  82125. * Creates a new instance ConeParticleEmitter
  82126. * @param radius the radius of the emission cone (1 by default)
  82127. * @param angle the cone base angle (PI by default)
  82128. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82129. */
  82130. constructor(radius?: number, angle?: number,
  82131. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82132. directionRandomizer?: number);
  82133. /**
  82134. * Called by the particle System when the direction is computed for the created particle.
  82135. * @param worldMatrix is the world matrix of the particle system
  82136. * @param directionToUpdate is the direction vector to update with the result
  82137. * @param particle is the particle we are computed the direction for
  82138. */
  82139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82140. /**
  82141. * Called by the particle System when the position is computed for the created particle.
  82142. * @param worldMatrix is the world matrix of the particle system
  82143. * @param positionToUpdate is the position vector to update with the result
  82144. * @param particle is the particle we are computed the position for
  82145. */
  82146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82147. /**
  82148. * Clones the current emitter and returns a copy of it
  82149. * @returns the new emitter
  82150. */
  82151. clone(): ConeParticleEmitter;
  82152. /**
  82153. * Called by the GPUParticleSystem to setup the update shader
  82154. * @param effect defines the update shader
  82155. */
  82156. applyToShader(effect: Effect): void;
  82157. /**
  82158. * Returns a string to use to update the GPU particles update shader
  82159. * @returns a string containng the defines string
  82160. */
  82161. getEffectDefines(): string;
  82162. /**
  82163. * Returns the string "ConeParticleEmitter"
  82164. * @returns a string containing the class name
  82165. */
  82166. getClassName(): string;
  82167. /**
  82168. * Serializes the particle system to a JSON object.
  82169. * @returns the JSON object
  82170. */
  82171. serialize(): any;
  82172. /**
  82173. * Parse properties from a JSON object
  82174. * @param serializationObject defines the JSON object
  82175. */
  82176. parse(serializationObject: any): void;
  82177. }
  82178. }
  82179. declare module BABYLON {
  82180. /**
  82181. * Particle emitter emitting particles from the inside of a cylinder.
  82182. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82183. */
  82184. export class CylinderParticleEmitter implements IParticleEmitterType {
  82185. /**
  82186. * The radius of the emission cylinder.
  82187. */
  82188. radius: number;
  82189. /**
  82190. * The height of the emission cylinder.
  82191. */
  82192. height: number;
  82193. /**
  82194. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82195. */
  82196. radiusRange: number;
  82197. /**
  82198. * How much to randomize the particle direction [0-1].
  82199. */
  82200. directionRandomizer: number;
  82201. /**
  82202. * Creates a new instance CylinderParticleEmitter
  82203. * @param radius the radius of the emission cylinder (1 by default)
  82204. * @param height the height of the emission cylinder (1 by default)
  82205. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82206. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82207. */
  82208. constructor(
  82209. /**
  82210. * The radius of the emission cylinder.
  82211. */
  82212. radius?: number,
  82213. /**
  82214. * The height of the emission cylinder.
  82215. */
  82216. height?: number,
  82217. /**
  82218. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82219. */
  82220. radiusRange?: number,
  82221. /**
  82222. * How much to randomize the particle direction [0-1].
  82223. */
  82224. directionRandomizer?: number);
  82225. /**
  82226. * Called by the particle System when the direction is computed for the created particle.
  82227. * @param worldMatrix is the world matrix of the particle system
  82228. * @param directionToUpdate is the direction vector to update with the result
  82229. * @param particle is the particle we are computed the direction for
  82230. */
  82231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82232. /**
  82233. * Called by the particle System when the position is computed for the created particle.
  82234. * @param worldMatrix is the world matrix of the particle system
  82235. * @param positionToUpdate is the position vector to update with the result
  82236. * @param particle is the particle we are computed the position for
  82237. */
  82238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82239. /**
  82240. * Clones the current emitter and returns a copy of it
  82241. * @returns the new emitter
  82242. */
  82243. clone(): CylinderParticleEmitter;
  82244. /**
  82245. * Called by the GPUParticleSystem to setup the update shader
  82246. * @param effect defines the update shader
  82247. */
  82248. applyToShader(effect: Effect): void;
  82249. /**
  82250. * Returns a string to use to update the GPU particles update shader
  82251. * @returns a string containng the defines string
  82252. */
  82253. getEffectDefines(): string;
  82254. /**
  82255. * Returns the string "CylinderParticleEmitter"
  82256. * @returns a string containing the class name
  82257. */
  82258. getClassName(): string;
  82259. /**
  82260. * Serializes the particle system to a JSON object.
  82261. * @returns the JSON object
  82262. */
  82263. serialize(): any;
  82264. /**
  82265. * Parse properties from a JSON object
  82266. * @param serializationObject defines the JSON object
  82267. */
  82268. parse(serializationObject: any): void;
  82269. }
  82270. /**
  82271. * Particle emitter emitting particles from the inside of a cylinder.
  82272. * It emits the particles randomly between two vectors.
  82273. */
  82274. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82275. /**
  82276. * The min limit of the emission direction.
  82277. */
  82278. direction1: Vector3;
  82279. /**
  82280. * The max limit of the emission direction.
  82281. */
  82282. direction2: Vector3;
  82283. /**
  82284. * Creates a new instance CylinderDirectedParticleEmitter
  82285. * @param radius the radius of the emission cylinder (1 by default)
  82286. * @param height the height of the emission cylinder (1 by default)
  82287. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82288. * @param direction1 the min limit of the emission direction (up vector by default)
  82289. * @param direction2 the max limit of the emission direction (up vector by default)
  82290. */
  82291. constructor(radius?: number, height?: number, radiusRange?: number,
  82292. /**
  82293. * The min limit of the emission direction.
  82294. */
  82295. direction1?: Vector3,
  82296. /**
  82297. * The max limit of the emission direction.
  82298. */
  82299. direction2?: Vector3);
  82300. /**
  82301. * Called by the particle System when the direction is computed for the created particle.
  82302. * @param worldMatrix is the world matrix of the particle system
  82303. * @param directionToUpdate is the direction vector to update with the result
  82304. * @param particle is the particle we are computed the direction for
  82305. */
  82306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82307. /**
  82308. * Clones the current emitter and returns a copy of it
  82309. * @returns the new emitter
  82310. */
  82311. clone(): CylinderDirectedParticleEmitter;
  82312. /**
  82313. * Called by the GPUParticleSystem to setup the update shader
  82314. * @param effect defines the update shader
  82315. */
  82316. applyToShader(effect: Effect): void;
  82317. /**
  82318. * Returns a string to use to update the GPU particles update shader
  82319. * @returns a string containng the defines string
  82320. */
  82321. getEffectDefines(): string;
  82322. /**
  82323. * Returns the string "CylinderDirectedParticleEmitter"
  82324. * @returns a string containing the class name
  82325. */
  82326. getClassName(): string;
  82327. /**
  82328. * Serializes the particle system to a JSON object.
  82329. * @returns the JSON object
  82330. */
  82331. serialize(): any;
  82332. /**
  82333. * Parse properties from a JSON object
  82334. * @param serializationObject defines the JSON object
  82335. */
  82336. parse(serializationObject: any): void;
  82337. }
  82338. }
  82339. declare module BABYLON {
  82340. /**
  82341. * Particle emitter emitting particles from the inside of a hemisphere.
  82342. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82343. */
  82344. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82345. /**
  82346. * The radius of the emission hemisphere.
  82347. */
  82348. radius: number;
  82349. /**
  82350. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82351. */
  82352. radiusRange: number;
  82353. /**
  82354. * How much to randomize the particle direction [0-1].
  82355. */
  82356. directionRandomizer: number;
  82357. /**
  82358. * Creates a new instance HemisphericParticleEmitter
  82359. * @param radius the radius of the emission hemisphere (1 by default)
  82360. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82361. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82362. */
  82363. constructor(
  82364. /**
  82365. * The radius of the emission hemisphere.
  82366. */
  82367. radius?: number,
  82368. /**
  82369. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82370. */
  82371. radiusRange?: number,
  82372. /**
  82373. * How much to randomize the particle direction [0-1].
  82374. */
  82375. directionRandomizer?: number);
  82376. /**
  82377. * Called by the particle System when the direction is computed for the created particle.
  82378. * @param worldMatrix is the world matrix of the particle system
  82379. * @param directionToUpdate is the direction vector to update with the result
  82380. * @param particle is the particle we are computed the direction for
  82381. */
  82382. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82383. /**
  82384. * Called by the particle System when the position is computed for the created particle.
  82385. * @param worldMatrix is the world matrix of the particle system
  82386. * @param positionToUpdate is the position vector to update with the result
  82387. * @param particle is the particle we are computed the position for
  82388. */
  82389. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82390. /**
  82391. * Clones the current emitter and returns a copy of it
  82392. * @returns the new emitter
  82393. */
  82394. clone(): HemisphericParticleEmitter;
  82395. /**
  82396. * Called by the GPUParticleSystem to setup the update shader
  82397. * @param effect defines the update shader
  82398. */
  82399. applyToShader(effect: Effect): void;
  82400. /**
  82401. * Returns a string to use to update the GPU particles update shader
  82402. * @returns a string containng the defines string
  82403. */
  82404. getEffectDefines(): string;
  82405. /**
  82406. * Returns the string "HemisphericParticleEmitter"
  82407. * @returns a string containing the class name
  82408. */
  82409. getClassName(): string;
  82410. /**
  82411. * Serializes the particle system to a JSON object.
  82412. * @returns the JSON object
  82413. */
  82414. serialize(): any;
  82415. /**
  82416. * Parse properties from a JSON object
  82417. * @param serializationObject defines the JSON object
  82418. */
  82419. parse(serializationObject: any): void;
  82420. }
  82421. }
  82422. declare module BABYLON {
  82423. /**
  82424. * Particle emitter emitting particles from a point.
  82425. * It emits the particles randomly between 2 given directions.
  82426. */
  82427. export class PointParticleEmitter implements IParticleEmitterType {
  82428. /**
  82429. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82430. */
  82431. direction1: Vector3;
  82432. /**
  82433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82434. */
  82435. direction2: Vector3;
  82436. /**
  82437. * Creates a new instance PointParticleEmitter
  82438. */
  82439. constructor();
  82440. /**
  82441. * Called by the particle System when the direction is computed for the created particle.
  82442. * @param worldMatrix is the world matrix of the particle system
  82443. * @param directionToUpdate is the direction vector to update with the result
  82444. * @param particle is the particle we are computed the direction for
  82445. */
  82446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82447. /**
  82448. * Called by the particle System when the position is computed for the created particle.
  82449. * @param worldMatrix is the world matrix of the particle system
  82450. * @param positionToUpdate is the position vector to update with the result
  82451. * @param particle is the particle we are computed the position for
  82452. */
  82453. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82454. /**
  82455. * Clones the current emitter and returns a copy of it
  82456. * @returns the new emitter
  82457. */
  82458. clone(): PointParticleEmitter;
  82459. /**
  82460. * Called by the GPUParticleSystem to setup the update shader
  82461. * @param effect defines the update shader
  82462. */
  82463. applyToShader(effect: Effect): void;
  82464. /**
  82465. * Returns a string to use to update the GPU particles update shader
  82466. * @returns a string containng the defines string
  82467. */
  82468. getEffectDefines(): string;
  82469. /**
  82470. * Returns the string "PointParticleEmitter"
  82471. * @returns a string containing the class name
  82472. */
  82473. getClassName(): string;
  82474. /**
  82475. * Serializes the particle system to a JSON object.
  82476. * @returns the JSON object
  82477. */
  82478. serialize(): any;
  82479. /**
  82480. * Parse properties from a JSON object
  82481. * @param serializationObject defines the JSON object
  82482. */
  82483. parse(serializationObject: any): void;
  82484. }
  82485. }
  82486. declare module BABYLON {
  82487. /**
  82488. * Particle emitter emitting particles from the inside of a sphere.
  82489. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82490. */
  82491. export class SphereParticleEmitter implements IParticleEmitterType {
  82492. /**
  82493. * The radius of the emission sphere.
  82494. */
  82495. radius: number;
  82496. /**
  82497. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82498. */
  82499. radiusRange: number;
  82500. /**
  82501. * How much to randomize the particle direction [0-1].
  82502. */
  82503. directionRandomizer: number;
  82504. /**
  82505. * Creates a new instance SphereParticleEmitter
  82506. * @param radius the radius of the emission sphere (1 by default)
  82507. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82508. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82509. */
  82510. constructor(
  82511. /**
  82512. * The radius of the emission sphere.
  82513. */
  82514. radius?: number,
  82515. /**
  82516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82517. */
  82518. radiusRange?: number,
  82519. /**
  82520. * How much to randomize the particle direction [0-1].
  82521. */
  82522. directionRandomizer?: number);
  82523. /**
  82524. * Called by the particle System when the direction is computed for the created particle.
  82525. * @param worldMatrix is the world matrix of the particle system
  82526. * @param directionToUpdate is the direction vector to update with the result
  82527. * @param particle is the particle we are computed the direction for
  82528. */
  82529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82530. /**
  82531. * Called by the particle System when the position is computed for the created particle.
  82532. * @param worldMatrix is the world matrix of the particle system
  82533. * @param positionToUpdate is the position vector to update with the result
  82534. * @param particle is the particle we are computed the position for
  82535. */
  82536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82537. /**
  82538. * Clones the current emitter and returns a copy of it
  82539. * @returns the new emitter
  82540. */
  82541. clone(): SphereParticleEmitter;
  82542. /**
  82543. * Called by the GPUParticleSystem to setup the update shader
  82544. * @param effect defines the update shader
  82545. */
  82546. applyToShader(effect: Effect): void;
  82547. /**
  82548. * Returns a string to use to update the GPU particles update shader
  82549. * @returns a string containng the defines string
  82550. */
  82551. getEffectDefines(): string;
  82552. /**
  82553. * Returns the string "SphereParticleEmitter"
  82554. * @returns a string containing the class name
  82555. */
  82556. getClassName(): string;
  82557. /**
  82558. * Serializes the particle system to a JSON object.
  82559. * @returns the JSON object
  82560. */
  82561. serialize(): any;
  82562. /**
  82563. * Parse properties from a JSON object
  82564. * @param serializationObject defines the JSON object
  82565. */
  82566. parse(serializationObject: any): void;
  82567. }
  82568. /**
  82569. * Particle emitter emitting particles from the inside of a sphere.
  82570. * It emits the particles randomly between two vectors.
  82571. */
  82572. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82573. /**
  82574. * The min limit of the emission direction.
  82575. */
  82576. direction1: Vector3;
  82577. /**
  82578. * The max limit of the emission direction.
  82579. */
  82580. direction2: Vector3;
  82581. /**
  82582. * Creates a new instance SphereDirectedParticleEmitter
  82583. * @param radius the radius of the emission sphere (1 by default)
  82584. * @param direction1 the min limit of the emission direction (up vector by default)
  82585. * @param direction2 the max limit of the emission direction (up vector by default)
  82586. */
  82587. constructor(radius?: number,
  82588. /**
  82589. * The min limit of the emission direction.
  82590. */
  82591. direction1?: Vector3,
  82592. /**
  82593. * The max limit of the emission direction.
  82594. */
  82595. direction2?: Vector3);
  82596. /**
  82597. * Called by the particle System when the direction is computed for the created particle.
  82598. * @param worldMatrix is the world matrix of the particle system
  82599. * @param directionToUpdate is the direction vector to update with the result
  82600. * @param particle is the particle we are computed the direction for
  82601. */
  82602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82603. /**
  82604. * Clones the current emitter and returns a copy of it
  82605. * @returns the new emitter
  82606. */
  82607. clone(): SphereDirectedParticleEmitter;
  82608. /**
  82609. * Called by the GPUParticleSystem to setup the update shader
  82610. * @param effect defines the update shader
  82611. */
  82612. applyToShader(effect: Effect): void;
  82613. /**
  82614. * Returns a string to use to update the GPU particles update shader
  82615. * @returns a string containng the defines string
  82616. */
  82617. getEffectDefines(): string;
  82618. /**
  82619. * Returns the string "SphereDirectedParticleEmitter"
  82620. * @returns a string containing the class name
  82621. */
  82622. getClassName(): string;
  82623. /**
  82624. * Serializes the particle system to a JSON object.
  82625. * @returns the JSON object
  82626. */
  82627. serialize(): any;
  82628. /**
  82629. * Parse properties from a JSON object
  82630. * @param serializationObject defines the JSON object
  82631. */
  82632. parse(serializationObject: any): void;
  82633. }
  82634. }
  82635. declare module BABYLON {
  82636. /**
  82637. * Interface representing a particle system in Babylon.js.
  82638. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82639. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82640. */
  82641. export interface IParticleSystem {
  82642. /**
  82643. * List of animations used by the particle system.
  82644. */
  82645. animations: Animation[];
  82646. /**
  82647. * The id of the Particle system.
  82648. */
  82649. id: string;
  82650. /**
  82651. * The name of the Particle system.
  82652. */
  82653. name: string;
  82654. /**
  82655. * The emitter represents the Mesh or position we are attaching the particle system to.
  82656. */
  82657. emitter: Nullable<AbstractMesh | Vector3>;
  82658. /**
  82659. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82660. */
  82661. isBillboardBased: boolean;
  82662. /**
  82663. * The rendering group used by the Particle system to chose when to render.
  82664. */
  82665. renderingGroupId: number;
  82666. /**
  82667. * The layer mask we are rendering the particles through.
  82668. */
  82669. layerMask: number;
  82670. /**
  82671. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82672. */
  82673. updateSpeed: number;
  82674. /**
  82675. * The amount of time the particle system is running (depends of the overall update speed).
  82676. */
  82677. targetStopDuration: number;
  82678. /**
  82679. * The texture used to render each particle. (this can be a spritesheet)
  82680. */
  82681. particleTexture: Nullable<Texture>;
  82682. /**
  82683. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82684. */
  82685. blendMode: number;
  82686. /**
  82687. * Minimum life time of emitting particles.
  82688. */
  82689. minLifeTime: number;
  82690. /**
  82691. * Maximum life time of emitting particles.
  82692. */
  82693. maxLifeTime: number;
  82694. /**
  82695. * Minimum Size of emitting particles.
  82696. */
  82697. minSize: number;
  82698. /**
  82699. * Maximum Size of emitting particles.
  82700. */
  82701. maxSize: number;
  82702. /**
  82703. * Minimum scale of emitting particles on X axis.
  82704. */
  82705. minScaleX: number;
  82706. /**
  82707. * Maximum scale of emitting particles on X axis.
  82708. */
  82709. maxScaleX: number;
  82710. /**
  82711. * Minimum scale of emitting particles on Y axis.
  82712. */
  82713. minScaleY: number;
  82714. /**
  82715. * Maximum scale of emitting particles on Y axis.
  82716. */
  82717. maxScaleY: number;
  82718. /**
  82719. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82720. */
  82721. color1: Color4;
  82722. /**
  82723. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82724. */
  82725. color2: Color4;
  82726. /**
  82727. * Color the particle will have at the end of its lifetime.
  82728. */
  82729. colorDead: Color4;
  82730. /**
  82731. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82732. */
  82733. emitRate: number;
  82734. /**
  82735. * You can use gravity if you want to give an orientation to your particles.
  82736. */
  82737. gravity: Vector3;
  82738. /**
  82739. * Minimum power of emitting particles.
  82740. */
  82741. minEmitPower: number;
  82742. /**
  82743. * Maximum power of emitting particles.
  82744. */
  82745. maxEmitPower: number;
  82746. /**
  82747. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82748. */
  82749. minAngularSpeed: number;
  82750. /**
  82751. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82752. */
  82753. maxAngularSpeed: number;
  82754. /**
  82755. * Gets or sets the minimal initial rotation in radians.
  82756. */
  82757. minInitialRotation: number;
  82758. /**
  82759. * Gets or sets the maximal initial rotation in radians.
  82760. */
  82761. maxInitialRotation: number;
  82762. /**
  82763. * The particle emitter type defines the emitter used by the particle system.
  82764. * It can be for example box, sphere, or cone...
  82765. */
  82766. particleEmitterType: Nullable<IParticleEmitterType>;
  82767. /**
  82768. * Defines the delay in milliseconds before starting the system (0 by default)
  82769. */
  82770. startDelay: number;
  82771. /**
  82772. * 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
  82773. */
  82774. preWarmCycles: number;
  82775. /**
  82776. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82777. */
  82778. preWarmStepOffset: number;
  82779. /**
  82780. * 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)
  82781. */
  82782. spriteCellChangeSpeed: number;
  82783. /**
  82784. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82785. */
  82786. startSpriteCellID: number;
  82787. /**
  82788. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82789. */
  82790. endSpriteCellID: number;
  82791. /**
  82792. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82793. */
  82794. spriteCellWidth: number;
  82795. /**
  82796. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82797. */
  82798. spriteCellHeight: number;
  82799. /**
  82800. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82801. */
  82802. spriteRandomStartCell: boolean;
  82803. /**
  82804. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82805. */
  82806. isAnimationSheetEnabled: boolean;
  82807. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82808. translationPivot: Vector2;
  82809. /**
  82810. * Gets or sets a texture used to add random noise to particle positions
  82811. */
  82812. noiseTexture: Nullable<BaseTexture>;
  82813. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82814. noiseStrength: Vector3;
  82815. /**
  82816. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82817. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82818. */
  82819. billboardMode: number;
  82820. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82821. limitVelocityDamping: number;
  82822. /**
  82823. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82824. */
  82825. beginAnimationOnStart: boolean;
  82826. /**
  82827. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82828. */
  82829. beginAnimationFrom: number;
  82830. /**
  82831. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82832. */
  82833. beginAnimationTo: number;
  82834. /**
  82835. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82836. */
  82837. beginAnimationLoop: boolean;
  82838. /**
  82839. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82840. */
  82841. disposeOnStop: boolean;
  82842. /**
  82843. * Gets the maximum number of particles active at the same time.
  82844. * @returns The max number of active particles.
  82845. */
  82846. getCapacity(): number;
  82847. /**
  82848. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82849. * @returns True if it has been started, otherwise false.
  82850. */
  82851. isStarted(): boolean;
  82852. /**
  82853. * Animates the particle system for this frame.
  82854. */
  82855. animate(): void;
  82856. /**
  82857. * Renders the particle system in its current state.
  82858. * @returns the current number of particles
  82859. */
  82860. render(): number;
  82861. /**
  82862. * Dispose the particle system and frees its associated resources.
  82863. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82864. */
  82865. dispose(disposeTexture?: boolean): void;
  82866. /**
  82867. * Clones the particle system.
  82868. * @param name The name of the cloned object
  82869. * @param newEmitter The new emitter to use
  82870. * @returns the cloned particle system
  82871. */
  82872. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82873. /**
  82874. * Serializes the particle system to a JSON object.
  82875. * @returns the JSON object
  82876. */
  82877. serialize(): any;
  82878. /**
  82879. * Rebuild the particle system
  82880. */
  82881. rebuild(): void;
  82882. /**
  82883. * Starts the particle system and begins to emit
  82884. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82885. */
  82886. start(delay?: number): void;
  82887. /**
  82888. * Stops the particle system.
  82889. */
  82890. stop(): void;
  82891. /**
  82892. * Remove all active particles
  82893. */
  82894. reset(): void;
  82895. /**
  82896. * Is this system ready to be used/rendered
  82897. * @return true if the system is ready
  82898. */
  82899. isReady(): boolean;
  82900. /**
  82901. * Adds a new color gradient
  82902. * @param gradient defines the gradient to use (between 0 and 1)
  82903. * @param color1 defines the color to affect to the specified gradient
  82904. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82905. * @returns the current particle system
  82906. */
  82907. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82908. /**
  82909. * Remove a specific color gradient
  82910. * @param gradient defines the gradient to remove
  82911. * @returns the current particle system
  82912. */
  82913. removeColorGradient(gradient: number): IParticleSystem;
  82914. /**
  82915. * Adds a new size gradient
  82916. * @param gradient defines the gradient to use (between 0 and 1)
  82917. * @param factor defines the size factor to affect to the specified gradient
  82918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82919. * @returns the current particle system
  82920. */
  82921. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82922. /**
  82923. * Remove a specific size gradient
  82924. * @param gradient defines the gradient to remove
  82925. * @returns the current particle system
  82926. */
  82927. removeSizeGradient(gradient: number): IParticleSystem;
  82928. /**
  82929. * Gets the current list of color gradients.
  82930. * You must use addColorGradient and removeColorGradient to udpate this list
  82931. * @returns the list of color gradients
  82932. */
  82933. getColorGradients(): Nullable<Array<ColorGradient>>;
  82934. /**
  82935. * Gets the current list of size gradients.
  82936. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82937. * @returns the list of size gradients
  82938. */
  82939. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82940. /**
  82941. * Gets the current list of angular speed gradients.
  82942. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82943. * @returns the list of angular speed gradients
  82944. */
  82945. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82946. /**
  82947. * Adds a new angular speed gradient
  82948. * @param gradient defines the gradient to use (between 0 and 1)
  82949. * @param factor defines the angular speed to affect to the specified gradient
  82950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82951. * @returns the current particle system
  82952. */
  82953. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82954. /**
  82955. * Remove a specific angular speed gradient
  82956. * @param gradient defines the gradient to remove
  82957. * @returns the current particle system
  82958. */
  82959. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82960. /**
  82961. * Gets the current list of velocity gradients.
  82962. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82963. * @returns the list of velocity gradients
  82964. */
  82965. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82966. /**
  82967. * Adds a new velocity gradient
  82968. * @param gradient defines the gradient to use (between 0 and 1)
  82969. * @param factor defines the velocity to affect to the specified gradient
  82970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82971. * @returns the current particle system
  82972. */
  82973. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82974. /**
  82975. * Remove a specific velocity gradient
  82976. * @param gradient defines the gradient to remove
  82977. * @returns the current particle system
  82978. */
  82979. removeVelocityGradient(gradient: number): IParticleSystem;
  82980. /**
  82981. * Gets the current list of limit velocity gradients.
  82982. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82983. * @returns the list of limit velocity gradients
  82984. */
  82985. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82986. /**
  82987. * Adds a new limit velocity gradient
  82988. * @param gradient defines the gradient to use (between 0 and 1)
  82989. * @param factor defines the limit velocity to affect to the specified gradient
  82990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82991. * @returns the current particle system
  82992. */
  82993. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82994. /**
  82995. * Remove a specific limit velocity gradient
  82996. * @param gradient defines the gradient to remove
  82997. * @returns the current particle system
  82998. */
  82999. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83000. /**
  83001. * Adds a new drag gradient
  83002. * @param gradient defines the gradient to use (between 0 and 1)
  83003. * @param factor defines the drag to affect to the specified gradient
  83004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83005. * @returns the current particle system
  83006. */
  83007. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83008. /**
  83009. * Remove a specific drag gradient
  83010. * @param gradient defines the gradient to remove
  83011. * @returns the current particle system
  83012. */
  83013. removeDragGradient(gradient: number): IParticleSystem;
  83014. /**
  83015. * Gets the current list of drag gradients.
  83016. * You must use addDragGradient and removeDragGradient to udpate this list
  83017. * @returns the list of drag gradients
  83018. */
  83019. getDragGradients(): Nullable<Array<FactorGradient>>;
  83020. /**
  83021. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83022. * @param gradient defines the gradient to use (between 0 and 1)
  83023. * @param factor defines the emit rate to affect to the specified gradient
  83024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83025. * @returns the current particle system
  83026. */
  83027. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83028. /**
  83029. * Remove a specific emit rate gradient
  83030. * @param gradient defines the gradient to remove
  83031. * @returns the current particle system
  83032. */
  83033. removeEmitRateGradient(gradient: number): IParticleSystem;
  83034. /**
  83035. * Gets the current list of emit rate gradients.
  83036. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83037. * @returns the list of emit rate gradients
  83038. */
  83039. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83040. /**
  83041. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83042. * @param gradient defines the gradient to use (between 0 and 1)
  83043. * @param factor defines the start size to affect to the specified gradient
  83044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83045. * @returns the current particle system
  83046. */
  83047. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83048. /**
  83049. * Remove a specific start size gradient
  83050. * @param gradient defines the gradient to remove
  83051. * @returns the current particle system
  83052. */
  83053. removeStartSizeGradient(gradient: number): IParticleSystem;
  83054. /**
  83055. * Gets the current list of start size gradients.
  83056. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83057. * @returns the list of start size gradients
  83058. */
  83059. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83060. /**
  83061. * Adds a new life time gradient
  83062. * @param gradient defines the gradient to use (between 0 and 1)
  83063. * @param factor defines the life time factor to affect to the specified gradient
  83064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83065. * @returns the current particle system
  83066. */
  83067. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83068. /**
  83069. * Remove a specific life time gradient
  83070. * @param gradient defines the gradient to remove
  83071. * @returns the current particle system
  83072. */
  83073. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83074. /**
  83075. * Gets the current list of life time gradients.
  83076. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83077. * @returns the list of life time gradients
  83078. */
  83079. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83080. /**
  83081. * Gets the current list of color gradients.
  83082. * You must use addColorGradient and removeColorGradient to udpate this list
  83083. * @returns the list of color gradients
  83084. */
  83085. getColorGradients(): Nullable<Array<ColorGradient>>;
  83086. /**
  83087. * Adds a new ramp gradient used to remap particle colors
  83088. * @param gradient defines the gradient to use (between 0 and 1)
  83089. * @param color defines the color to affect to the specified gradient
  83090. * @returns the current particle system
  83091. */
  83092. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83093. /**
  83094. * Gets the current list of ramp gradients.
  83095. * You must use addRampGradient and removeRampGradient to udpate this list
  83096. * @returns the list of ramp gradients
  83097. */
  83098. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83099. /** Gets or sets a boolean indicating that ramp gradients must be used
  83100. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83101. */
  83102. useRampGradients: boolean;
  83103. /**
  83104. * Adds a new color remap gradient
  83105. * @param gradient defines the gradient to use (between 0 and 1)
  83106. * @param min defines the color remap minimal range
  83107. * @param max defines the color remap maximal range
  83108. * @returns the current particle system
  83109. */
  83110. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83111. /**
  83112. * Gets the current list of color remap gradients.
  83113. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83114. * @returns the list of color remap gradients
  83115. */
  83116. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83117. /**
  83118. * Adds a new alpha remap gradient
  83119. * @param gradient defines the gradient to use (between 0 and 1)
  83120. * @param min defines the alpha remap minimal range
  83121. * @param max defines the alpha remap maximal range
  83122. * @returns the current particle system
  83123. */
  83124. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83125. /**
  83126. * Gets the current list of alpha remap gradients.
  83127. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83128. * @returns the list of alpha remap gradients
  83129. */
  83130. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83131. /**
  83132. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83133. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83134. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83135. * @returns the emitter
  83136. */
  83137. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83138. /**
  83139. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83140. * @param radius The radius of the hemisphere to emit from
  83141. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83142. * @returns the emitter
  83143. */
  83144. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83145. /**
  83146. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83147. * @param radius The radius of the sphere to emit from
  83148. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83149. * @returns the emitter
  83150. */
  83151. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83152. /**
  83153. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83154. * @param radius The radius of the sphere to emit from
  83155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83157. * @returns the emitter
  83158. */
  83159. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83160. /**
  83161. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83162. * @param radius The radius of the emission cylinder
  83163. * @param height The height of the emission cylinder
  83164. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83165. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83166. * @returns the emitter
  83167. */
  83168. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83169. /**
  83170. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83171. * @param radius The radius of the cylinder to emit from
  83172. * @param height The height of the emission cylinder
  83173. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83176. * @returns the emitter
  83177. */
  83178. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83179. /**
  83180. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83181. * @param radius The radius of the cone to emit from
  83182. * @param angle The base angle of the cone
  83183. * @returns the emitter
  83184. */
  83185. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83186. /**
  83187. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83188. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83189. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83190. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83191. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83192. * @returns the emitter
  83193. */
  83194. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83195. /**
  83196. * Get hosting scene
  83197. * @returns the scene
  83198. */
  83199. getScene(): Scene;
  83200. }
  83201. }
  83202. declare module BABYLON {
  83203. /**
  83204. * Creates an instance based on a source mesh.
  83205. */
  83206. export class InstancedMesh extends AbstractMesh {
  83207. private _sourceMesh;
  83208. private _currentLOD;
  83209. /** @hidden */
  83210. _indexInSourceMeshInstanceArray: number;
  83211. constructor(name: string, source: Mesh);
  83212. /**
  83213. * Returns the string "InstancedMesh".
  83214. */
  83215. getClassName(): string;
  83216. /** Gets the list of lights affecting that mesh */
  83217. readonly lightSources: Light[];
  83218. _resyncLightSources(): void;
  83219. _resyncLighSource(light: Light): void;
  83220. _removeLightSource(light: Light): void;
  83221. /**
  83222. * If the source mesh receives shadows
  83223. */
  83224. readonly receiveShadows: boolean;
  83225. /**
  83226. * The material of the source mesh
  83227. */
  83228. readonly material: Nullable<Material>;
  83229. /**
  83230. * Visibility of the source mesh
  83231. */
  83232. readonly visibility: number;
  83233. /**
  83234. * Skeleton of the source mesh
  83235. */
  83236. readonly skeleton: Nullable<Skeleton>;
  83237. /**
  83238. * Rendering ground id of the source mesh
  83239. */
  83240. renderingGroupId: number;
  83241. /**
  83242. * Returns the total number of vertices (integer).
  83243. */
  83244. getTotalVertices(): number;
  83245. /**
  83246. * Returns a positive integer : the total number of indices in this mesh geometry.
  83247. * @returns the numner of indices or zero if the mesh has no geometry.
  83248. */
  83249. getTotalIndices(): number;
  83250. /**
  83251. * The source mesh of the instance
  83252. */
  83253. readonly sourceMesh: Mesh;
  83254. /**
  83255. * Is this node ready to be used/rendered
  83256. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83257. * @return {boolean} is it ready
  83258. */
  83259. isReady(completeCheck?: boolean): boolean;
  83260. /**
  83261. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83262. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83263. * @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.
  83264. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83265. */
  83266. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83267. /**
  83268. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83269. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83270. * The `data` are either a numeric array either a Float32Array.
  83271. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83272. * 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).
  83273. * Note that a new underlying VertexBuffer object is created each call.
  83274. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83275. *
  83276. * Possible `kind` values :
  83277. * - VertexBuffer.PositionKind
  83278. * - VertexBuffer.UVKind
  83279. * - VertexBuffer.UV2Kind
  83280. * - VertexBuffer.UV3Kind
  83281. * - VertexBuffer.UV4Kind
  83282. * - VertexBuffer.UV5Kind
  83283. * - VertexBuffer.UV6Kind
  83284. * - VertexBuffer.ColorKind
  83285. * - VertexBuffer.MatricesIndicesKind
  83286. * - VertexBuffer.MatricesIndicesExtraKind
  83287. * - VertexBuffer.MatricesWeightsKind
  83288. * - VertexBuffer.MatricesWeightsExtraKind
  83289. *
  83290. * Returns the Mesh.
  83291. */
  83292. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83293. /**
  83294. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83295. * If the mesh has no geometry, it is simply returned as it is.
  83296. * The `data` are either a numeric array either a Float32Array.
  83297. * No new underlying VertexBuffer object is created.
  83298. * 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.
  83299. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83300. *
  83301. * Possible `kind` values :
  83302. * - VertexBuffer.PositionKind
  83303. * - VertexBuffer.UVKind
  83304. * - VertexBuffer.UV2Kind
  83305. * - VertexBuffer.UV3Kind
  83306. * - VertexBuffer.UV4Kind
  83307. * - VertexBuffer.UV5Kind
  83308. * - VertexBuffer.UV6Kind
  83309. * - VertexBuffer.ColorKind
  83310. * - VertexBuffer.MatricesIndicesKind
  83311. * - VertexBuffer.MatricesIndicesExtraKind
  83312. * - VertexBuffer.MatricesWeightsKind
  83313. * - VertexBuffer.MatricesWeightsExtraKind
  83314. *
  83315. * Returns the Mesh.
  83316. */
  83317. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83318. /**
  83319. * Sets the mesh indices.
  83320. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83321. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83322. * This method creates a new index buffer each call.
  83323. * Returns the Mesh.
  83324. */
  83325. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83326. /**
  83327. * Boolean : True if the mesh owns the requested kind of data.
  83328. */
  83329. isVerticesDataPresent(kind: string): boolean;
  83330. /**
  83331. * Returns an array of indices (IndicesArray).
  83332. */
  83333. getIndices(): Nullable<IndicesArray>;
  83334. readonly _positions: Nullable<Vector3[]>;
  83335. /**
  83336. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83337. * This means the mesh underlying bounding box and sphere are recomputed.
  83338. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83339. * @returns the current mesh
  83340. */
  83341. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83342. /** @hidden */
  83343. _preActivate(): InstancedMesh;
  83344. /** @hidden */
  83345. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83346. /** @hidden */
  83347. _postActivate(): void;
  83348. getWorldMatrix(): Matrix;
  83349. readonly isAnInstance: boolean;
  83350. /**
  83351. * Returns the current associated LOD AbstractMesh.
  83352. */
  83353. getLOD(camera: Camera): AbstractMesh;
  83354. /** @hidden */
  83355. _syncSubMeshes(): InstancedMesh;
  83356. /** @hidden */
  83357. _generatePointsArray(): boolean;
  83358. /**
  83359. * Creates a new InstancedMesh from the current mesh.
  83360. * - name (string) : the cloned mesh name
  83361. * - newParent (optional Node) : the optional Node to parent the clone to.
  83362. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83363. *
  83364. * Returns the clone.
  83365. */
  83366. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83367. /**
  83368. * Disposes the InstancedMesh.
  83369. * Returns nothing.
  83370. */
  83371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83372. }
  83373. }
  83374. declare module BABYLON {
  83375. /**
  83376. * Defines the options associated with the creation of a shader material.
  83377. */
  83378. export interface IShaderMaterialOptions {
  83379. /**
  83380. * Does the material work in alpha blend mode
  83381. */
  83382. needAlphaBlending: boolean;
  83383. /**
  83384. * Does the material work in alpha test mode
  83385. */
  83386. needAlphaTesting: boolean;
  83387. /**
  83388. * The list of attribute names used in the shader
  83389. */
  83390. attributes: string[];
  83391. /**
  83392. * The list of unifrom names used in the shader
  83393. */
  83394. uniforms: string[];
  83395. /**
  83396. * The list of UBO names used in the shader
  83397. */
  83398. uniformBuffers: string[];
  83399. /**
  83400. * The list of sampler names used in the shader
  83401. */
  83402. samplers: string[];
  83403. /**
  83404. * The list of defines used in the shader
  83405. */
  83406. defines: string[];
  83407. }
  83408. /**
  83409. * 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.
  83410. *
  83411. * This returned material effects how the mesh will look based on the code in the shaders.
  83412. *
  83413. * @see http://doc.babylonjs.com/how_to/shader_material
  83414. */
  83415. export class ShaderMaterial extends Material {
  83416. private _shaderPath;
  83417. private _options;
  83418. private _textures;
  83419. private _textureArrays;
  83420. private _floats;
  83421. private _ints;
  83422. private _floatsArrays;
  83423. private _colors3;
  83424. private _colors3Arrays;
  83425. private _colors4;
  83426. private _colors4Arrays;
  83427. private _vectors2;
  83428. private _vectors3;
  83429. private _vectors4;
  83430. private _matrices;
  83431. private _matrices3x3;
  83432. private _matrices2x2;
  83433. private _vectors2Arrays;
  83434. private _vectors3Arrays;
  83435. private _vectors4Arrays;
  83436. private _cachedWorldViewMatrix;
  83437. private _cachedWorldViewProjectionMatrix;
  83438. private _renderId;
  83439. /**
  83440. * Instantiate a new shader material.
  83441. * 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.
  83442. * This returned material effects how the mesh will look based on the code in the shaders.
  83443. * @see http://doc.babylonjs.com/how_to/shader_material
  83444. * @param name Define the name of the material in the scene
  83445. * @param scene Define the scene the material belongs to
  83446. * @param shaderPath Defines the route to the shader code in one of three ways:
  83447. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83448. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83449. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83450. * @param options Define the options used to create the shader
  83451. */
  83452. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83453. /**
  83454. * Gets the options used to compile the shader.
  83455. * They can be modified to trigger a new compilation
  83456. */
  83457. readonly options: IShaderMaterialOptions;
  83458. /**
  83459. * Gets the current class name of the material e.g. "ShaderMaterial"
  83460. * Mainly use in serialization.
  83461. * @returns the class name
  83462. */
  83463. getClassName(): string;
  83464. /**
  83465. * Specifies if the material will require alpha blending
  83466. * @returns a boolean specifying if alpha blending is needed
  83467. */
  83468. needAlphaBlending(): boolean;
  83469. /**
  83470. * Specifies if this material should be rendered in alpha test mode
  83471. * @returns a boolean specifying if an alpha test is needed.
  83472. */
  83473. needAlphaTesting(): boolean;
  83474. private _checkUniform;
  83475. /**
  83476. * Set a texture in the shader.
  83477. * @param name Define the name of the uniform samplers as defined in the shader
  83478. * @param texture Define the texture to bind to this sampler
  83479. * @return the material itself allowing "fluent" like uniform updates
  83480. */
  83481. setTexture(name: string, texture: Texture): ShaderMaterial;
  83482. /**
  83483. * Set a texture array in the shader.
  83484. * @param name Define the name of the uniform sampler array as defined in the shader
  83485. * @param textures Define the list of textures to bind to this sampler
  83486. * @return the material itself allowing "fluent" like uniform updates
  83487. */
  83488. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83489. /**
  83490. * Set a float in the shader.
  83491. * @param name Define the name of the uniform as defined in the shader
  83492. * @param value Define the value to give to the uniform
  83493. * @return the material itself allowing "fluent" like uniform updates
  83494. */
  83495. setFloat(name: string, value: number): ShaderMaterial;
  83496. /**
  83497. * Set a int in the shader.
  83498. * @param name Define the name of the uniform as defined in the shader
  83499. * @param value Define the value to give to the uniform
  83500. * @return the material itself allowing "fluent" like uniform updates
  83501. */
  83502. setInt(name: string, value: number): ShaderMaterial;
  83503. /**
  83504. * Set an array of floats in the shader.
  83505. * @param name Define the name of the uniform as defined in the shader
  83506. * @param value Define the value to give to the uniform
  83507. * @return the material itself allowing "fluent" like uniform updates
  83508. */
  83509. setFloats(name: string, value: number[]): ShaderMaterial;
  83510. /**
  83511. * Set a vec3 in the shader from a Color3.
  83512. * @param name Define the name of the uniform as defined in the shader
  83513. * @param value Define the value to give to the uniform
  83514. * @return the material itself allowing "fluent" like uniform updates
  83515. */
  83516. setColor3(name: string, value: Color3): ShaderMaterial;
  83517. /**
  83518. * Set a vec3 array in the shader from a Color3 array.
  83519. * @param name Define the name of the uniform as defined in the shader
  83520. * @param value Define the value to give to the uniform
  83521. * @return the material itself allowing "fluent" like uniform updates
  83522. */
  83523. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83524. /**
  83525. * Set a vec4 in the shader from a Color4.
  83526. * @param name Define the name of the uniform as defined in the shader
  83527. * @param value Define the value to give to the uniform
  83528. * @return the material itself allowing "fluent" like uniform updates
  83529. */
  83530. setColor4(name: string, value: Color4): ShaderMaterial;
  83531. /**
  83532. * Set a vec4 array in the shader from a Color4 array.
  83533. * @param name Define the name of the uniform as defined in the shader
  83534. * @param value Define the value to give to the uniform
  83535. * @return the material itself allowing "fluent" like uniform updates
  83536. */
  83537. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83538. /**
  83539. * Set a vec2 in the shader from a Vector2.
  83540. * @param name Define the name of the uniform as defined in the shader
  83541. * @param value Define the value to give to the uniform
  83542. * @return the material itself allowing "fluent" like uniform updates
  83543. */
  83544. setVector2(name: string, value: Vector2): ShaderMaterial;
  83545. /**
  83546. * Set a vec3 in the shader from a Vector3.
  83547. * @param name Define the name of the uniform as defined in the shader
  83548. * @param value Define the value to give to the uniform
  83549. * @return the material itself allowing "fluent" like uniform updates
  83550. */
  83551. setVector3(name: string, value: Vector3): ShaderMaterial;
  83552. /**
  83553. * Set a vec4 in the shader from a Vector4.
  83554. * @param name Define the name of the uniform as defined in the shader
  83555. * @param value Define the value to give to the uniform
  83556. * @return the material itself allowing "fluent" like uniform updates
  83557. */
  83558. setVector4(name: string, value: Vector4): ShaderMaterial;
  83559. /**
  83560. * Set a mat4 in the shader from a Matrix.
  83561. * @param name Define the name of the uniform as defined in the shader
  83562. * @param value Define the value to give to the uniform
  83563. * @return the material itself allowing "fluent" like uniform updates
  83564. */
  83565. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83566. /**
  83567. * Set a mat3 in the shader from a Float32Array.
  83568. * @param name Define the name of the uniform as defined in the shader
  83569. * @param value Define the value to give to the uniform
  83570. * @return the material itself allowing "fluent" like uniform updates
  83571. */
  83572. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83573. /**
  83574. * Set a mat2 in the shader from a Float32Array.
  83575. * @param name Define the name of the uniform as defined in the shader
  83576. * @param value Define the value to give to the uniform
  83577. * @return the material itself allowing "fluent" like uniform updates
  83578. */
  83579. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83580. /**
  83581. * Set a vec2 array in the shader from a number array.
  83582. * @param name Define the name of the uniform as defined in the shader
  83583. * @param value Define the value to give to the uniform
  83584. * @return the material itself allowing "fluent" like uniform updates
  83585. */
  83586. setArray2(name: string, value: number[]): ShaderMaterial;
  83587. /**
  83588. * Set a vec3 array in the shader from a number array.
  83589. * @param name Define the name of the uniform as defined in the shader
  83590. * @param value Define the value to give to the uniform
  83591. * @return the material itself allowing "fluent" like uniform updates
  83592. */
  83593. setArray3(name: string, value: number[]): ShaderMaterial;
  83594. /**
  83595. * Set a vec4 array in the shader from a number array.
  83596. * @param name Define the name of the uniform as defined in the shader
  83597. * @param value Define the value to give to the uniform
  83598. * @return the material itself allowing "fluent" like uniform updates
  83599. */
  83600. setArray4(name: string, value: number[]): ShaderMaterial;
  83601. private _checkCache;
  83602. /**
  83603. * Specifies that the submesh is ready to be used
  83604. * @param mesh defines the mesh to check
  83605. * @param subMesh defines which submesh to check
  83606. * @param useInstances specifies that instances should be used
  83607. * @returns a boolean indicating that the submesh is ready or not
  83608. */
  83609. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83610. /**
  83611. * Checks if the material is ready to render the requested mesh
  83612. * @param mesh Define the mesh to render
  83613. * @param useInstances Define whether or not the material is used with instances
  83614. * @returns true if ready, otherwise false
  83615. */
  83616. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83617. /**
  83618. * Binds the world matrix to the material
  83619. * @param world defines the world transformation matrix
  83620. */
  83621. bindOnlyWorldMatrix(world: Matrix): void;
  83622. /**
  83623. * Binds the material to the mesh
  83624. * @param world defines the world transformation matrix
  83625. * @param mesh defines the mesh to bind the material to
  83626. */
  83627. bind(world: Matrix, mesh?: Mesh): void;
  83628. /**
  83629. * Gets the active textures from the material
  83630. * @returns an array of textures
  83631. */
  83632. getActiveTextures(): BaseTexture[];
  83633. /**
  83634. * Specifies if the material uses a texture
  83635. * @param texture defines the texture to check against the material
  83636. * @returns a boolean specifying if the material uses the texture
  83637. */
  83638. hasTexture(texture: BaseTexture): boolean;
  83639. /**
  83640. * Makes a duplicate of the material, and gives it a new name
  83641. * @param name defines the new name for the duplicated material
  83642. * @returns the cloned material
  83643. */
  83644. clone(name: string): ShaderMaterial;
  83645. /**
  83646. * Disposes the material
  83647. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83648. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83649. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83650. */
  83651. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83652. /**
  83653. * Serializes this material in a JSON representation
  83654. * @returns the serialized material object
  83655. */
  83656. serialize(): any;
  83657. /**
  83658. * Creates a shader material from parsed shader material data
  83659. * @param source defines the JSON represnetation of the material
  83660. * @param scene defines the hosting scene
  83661. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83662. * @returns a new material
  83663. */
  83664. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83665. }
  83666. }
  83667. declare module BABYLON {
  83668. /** @hidden */
  83669. export var colorPixelShader: {
  83670. name: string;
  83671. shader: string;
  83672. };
  83673. }
  83674. declare module BABYLON {
  83675. /** @hidden */
  83676. export var colorVertexShader: {
  83677. name: string;
  83678. shader: string;
  83679. };
  83680. }
  83681. declare module BABYLON {
  83682. /**
  83683. * Line mesh
  83684. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83685. */
  83686. export class LinesMesh extends Mesh {
  83687. /**
  83688. * If vertex color should be applied to the mesh
  83689. */
  83690. readonly useVertexColor?: boolean | undefined;
  83691. /**
  83692. * If vertex alpha should be applied to the mesh
  83693. */
  83694. readonly useVertexAlpha?: boolean | undefined;
  83695. /**
  83696. * Color of the line (Default: White)
  83697. */
  83698. color: Color3;
  83699. /**
  83700. * Alpha of the line (Default: 1)
  83701. */
  83702. alpha: number;
  83703. /**
  83704. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83705. * This margin is expressed in world space coordinates, so its value may vary.
  83706. * Default value is 0.1
  83707. */
  83708. intersectionThreshold: number;
  83709. private _colorShader;
  83710. private color4;
  83711. /**
  83712. * Creates a new LinesMesh
  83713. * @param name defines the name
  83714. * @param scene defines the hosting scene
  83715. * @param parent defines the parent mesh if any
  83716. * @param source defines the optional source LinesMesh used to clone data from
  83717. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83718. * When false, achieved by calling a clone(), also passing False.
  83719. * This will make creation of children, recursive.
  83720. * @param useVertexColor defines if this LinesMesh supports vertex color
  83721. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83722. */
  83723. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  83724. /**
  83725. * If vertex color should be applied to the mesh
  83726. */
  83727. useVertexColor?: boolean | undefined,
  83728. /**
  83729. * If vertex alpha should be applied to the mesh
  83730. */
  83731. useVertexAlpha?: boolean | undefined);
  83732. private _addClipPlaneDefine;
  83733. private _removeClipPlaneDefine;
  83734. isReady(): boolean;
  83735. /**
  83736. * Returns the string "LineMesh"
  83737. */
  83738. getClassName(): string;
  83739. /**
  83740. * @hidden
  83741. */
  83742. /**
  83743. * @hidden
  83744. */
  83745. material: Material;
  83746. /**
  83747. * @hidden
  83748. */
  83749. readonly checkCollisions: boolean;
  83750. /** @hidden */
  83751. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83752. /** @hidden */
  83753. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83754. /**
  83755. * Disposes of the line mesh
  83756. * @param doNotRecurse If children should be disposed
  83757. */
  83758. dispose(doNotRecurse?: boolean): void;
  83759. /**
  83760. * Returns a new LineMesh object cloned from the current one.
  83761. */
  83762. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83763. /**
  83764. * Creates a new InstancedLinesMesh object from the mesh model.
  83765. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83766. * @param name defines the name of the new instance
  83767. * @returns a new InstancedLinesMesh
  83768. */
  83769. createInstance(name: string): InstancedLinesMesh;
  83770. }
  83771. /**
  83772. * Creates an instance based on a source LinesMesh
  83773. */
  83774. export class InstancedLinesMesh extends InstancedMesh {
  83775. /**
  83776. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83777. * This margin is expressed in world space coordinates, so its value may vary.
  83778. * Initilized with the intersectionThreshold value of the source LinesMesh
  83779. */
  83780. intersectionThreshold: number;
  83781. constructor(name: string, source: LinesMesh);
  83782. /**
  83783. * Returns the string "InstancedLinesMesh".
  83784. */
  83785. getClassName(): string;
  83786. }
  83787. }
  83788. declare module BABYLON {
  83789. /** @hidden */
  83790. export var linePixelShader: {
  83791. name: string;
  83792. shader: string;
  83793. };
  83794. }
  83795. declare module BABYLON {
  83796. /** @hidden */
  83797. export var lineVertexShader: {
  83798. name: string;
  83799. shader: string;
  83800. };
  83801. }
  83802. declare module BABYLON {
  83803. interface AbstractMesh {
  83804. /**
  83805. * Gets the edgesRenderer associated with the mesh
  83806. */
  83807. edgesRenderer: Nullable<EdgesRenderer>;
  83808. }
  83809. interface LinesMesh {
  83810. /**
  83811. * Enables the edge rendering mode on the mesh.
  83812. * This mode makes the mesh edges visible
  83813. * @param epsilon defines the maximal distance between two angles to detect a face
  83814. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83815. * @returns the currentAbstractMesh
  83816. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83817. */
  83818. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83819. }
  83820. interface InstancedLinesMesh {
  83821. /**
  83822. * Enables the edge rendering mode on the mesh.
  83823. * This mode makes the mesh edges visible
  83824. * @param epsilon defines the maximal distance between two angles to detect a face
  83825. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83826. * @returns the current InstancedLinesMesh
  83827. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83828. */
  83829. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83830. }
  83831. /**
  83832. * Defines the minimum contract an Edges renderer should follow.
  83833. */
  83834. export interface IEdgesRenderer extends IDisposable {
  83835. /**
  83836. * Gets or sets a boolean indicating if the edgesRenderer is active
  83837. */
  83838. isEnabled: boolean;
  83839. /**
  83840. * Renders the edges of the attached mesh,
  83841. */
  83842. render(): void;
  83843. /**
  83844. * Checks wether or not the edges renderer is ready to render.
  83845. * @return true if ready, otherwise false.
  83846. */
  83847. isReady(): boolean;
  83848. }
  83849. /**
  83850. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83851. */
  83852. export class EdgesRenderer implements IEdgesRenderer {
  83853. /**
  83854. * Define the size of the edges with an orthographic camera
  83855. */
  83856. edgesWidthScalerForOrthographic: number;
  83857. /**
  83858. * Define the size of the edges with a perspective camera
  83859. */
  83860. edgesWidthScalerForPerspective: number;
  83861. protected _source: AbstractMesh;
  83862. protected _linesPositions: number[];
  83863. protected _linesNormals: number[];
  83864. protected _linesIndices: number[];
  83865. protected _epsilon: number;
  83866. protected _indicesCount: number;
  83867. protected _lineShader: ShaderMaterial;
  83868. protected _ib: DataBuffer;
  83869. protected _buffers: {
  83870. [key: string]: Nullable<VertexBuffer>;
  83871. };
  83872. protected _checkVerticesInsteadOfIndices: boolean;
  83873. private _meshRebuildObserver;
  83874. private _meshDisposeObserver;
  83875. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83876. isEnabled: boolean;
  83877. /**
  83878. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83879. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83880. * @param source Mesh used to create edges
  83881. * @param epsilon sum of angles in adjacency to check for edge
  83882. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83883. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83884. */
  83885. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83886. protected _prepareRessources(): void;
  83887. /** @hidden */
  83888. _rebuild(): void;
  83889. /**
  83890. * Releases the required resources for the edges renderer
  83891. */
  83892. dispose(): void;
  83893. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83894. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83895. /**
  83896. * Checks if the pair of p0 and p1 is en edge
  83897. * @param faceIndex
  83898. * @param edge
  83899. * @param faceNormals
  83900. * @param p0
  83901. * @param p1
  83902. * @private
  83903. */
  83904. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83905. /**
  83906. * push line into the position, normal and index buffer
  83907. * @protected
  83908. */
  83909. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83910. /**
  83911. * Generates lines edges from adjacencjes
  83912. * @private
  83913. */
  83914. _generateEdgesLines(): void;
  83915. /**
  83916. * Checks wether or not the edges renderer is ready to render.
  83917. * @return true if ready, otherwise false.
  83918. */
  83919. isReady(): boolean;
  83920. /**
  83921. * Renders the edges of the attached mesh,
  83922. */
  83923. render(): void;
  83924. }
  83925. /**
  83926. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83927. */
  83928. export class LineEdgesRenderer extends EdgesRenderer {
  83929. /**
  83930. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83931. * @param source LineMesh used to generate edges
  83932. * @param epsilon not important (specified angle for edge detection)
  83933. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83934. */
  83935. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83936. /**
  83937. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83938. */
  83939. _generateEdgesLines(): void;
  83940. }
  83941. }
  83942. declare module BABYLON {
  83943. /**
  83944. * This represents the object necessary to create a rendering group.
  83945. * This is exclusively used and created by the rendering manager.
  83946. * To modify the behavior, you use the available helpers in your scene or meshes.
  83947. * @hidden
  83948. */
  83949. export class RenderingGroup {
  83950. index: number;
  83951. private static _zeroVector;
  83952. private _scene;
  83953. private _opaqueSubMeshes;
  83954. private _transparentSubMeshes;
  83955. private _alphaTestSubMeshes;
  83956. private _depthOnlySubMeshes;
  83957. private _particleSystems;
  83958. private _spriteManagers;
  83959. private _opaqueSortCompareFn;
  83960. private _alphaTestSortCompareFn;
  83961. private _transparentSortCompareFn;
  83962. private _renderOpaque;
  83963. private _renderAlphaTest;
  83964. private _renderTransparent;
  83965. /** @hidden */
  83966. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83967. onBeforeTransparentRendering: () => void;
  83968. /**
  83969. * Set the opaque sort comparison function.
  83970. * If null the sub meshes will be render in the order they were created
  83971. */
  83972. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83973. /**
  83974. * Set the alpha test sort comparison function.
  83975. * If null the sub meshes will be render in the order they were created
  83976. */
  83977. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83978. /**
  83979. * Set the transparent sort comparison function.
  83980. * If null the sub meshes will be render in the order they were created
  83981. */
  83982. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83983. /**
  83984. * Creates a new rendering group.
  83985. * @param index The rendering group index
  83986. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83987. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83988. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83989. */
  83990. 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>);
  83991. /**
  83992. * Render all the sub meshes contained in the group.
  83993. * @param customRenderFunction Used to override the default render behaviour of the group.
  83994. * @returns true if rendered some submeshes.
  83995. */
  83996. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83997. /**
  83998. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83999. * @param subMeshes The submeshes to render
  84000. */
  84001. private renderOpaqueSorted;
  84002. /**
  84003. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84004. * @param subMeshes The submeshes to render
  84005. */
  84006. private renderAlphaTestSorted;
  84007. /**
  84008. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84009. * @param subMeshes The submeshes to render
  84010. */
  84011. private renderTransparentSorted;
  84012. /**
  84013. * Renders the submeshes in a specified order.
  84014. * @param subMeshes The submeshes to sort before render
  84015. * @param sortCompareFn The comparison function use to sort
  84016. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84017. * @param transparent Specifies to activate blending if true
  84018. */
  84019. private static renderSorted;
  84020. /**
  84021. * Renders the submeshes in the order they were dispatched (no sort applied).
  84022. * @param subMeshes The submeshes to render
  84023. */
  84024. private static renderUnsorted;
  84025. /**
  84026. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84027. * are rendered back to front if in the same alpha index.
  84028. *
  84029. * @param a The first submesh
  84030. * @param b The second submesh
  84031. * @returns The result of the comparison
  84032. */
  84033. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84034. /**
  84035. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84036. * are rendered back to front.
  84037. *
  84038. * @param a The first submesh
  84039. * @param b The second submesh
  84040. * @returns The result of the comparison
  84041. */
  84042. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84043. /**
  84044. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84045. * are rendered front to back (prevent overdraw).
  84046. *
  84047. * @param a The first submesh
  84048. * @param b The second submesh
  84049. * @returns The result of the comparison
  84050. */
  84051. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84052. /**
  84053. * Resets the different lists of submeshes to prepare a new frame.
  84054. */
  84055. prepare(): void;
  84056. dispose(): void;
  84057. /**
  84058. * Inserts the submesh in its correct queue depending on its material.
  84059. * @param subMesh The submesh to dispatch
  84060. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84061. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84062. */
  84063. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84064. dispatchSprites(spriteManager: ISpriteManager): void;
  84065. dispatchParticles(particleSystem: IParticleSystem): void;
  84066. private _renderParticles;
  84067. private _renderSprites;
  84068. }
  84069. }
  84070. declare module BABYLON {
  84071. /**
  84072. * Interface describing the different options available in the rendering manager
  84073. * regarding Auto Clear between groups.
  84074. */
  84075. export interface IRenderingManagerAutoClearSetup {
  84076. /**
  84077. * Defines whether or not autoclear is enable.
  84078. */
  84079. autoClear: boolean;
  84080. /**
  84081. * Defines whether or not to autoclear the depth buffer.
  84082. */
  84083. depth: boolean;
  84084. /**
  84085. * Defines whether or not to autoclear the stencil buffer.
  84086. */
  84087. stencil: boolean;
  84088. }
  84089. /**
  84090. * This class is used by the onRenderingGroupObservable
  84091. */
  84092. export class RenderingGroupInfo {
  84093. /**
  84094. * The Scene that being rendered
  84095. */
  84096. scene: Scene;
  84097. /**
  84098. * The camera currently used for the rendering pass
  84099. */
  84100. camera: Nullable<Camera>;
  84101. /**
  84102. * The ID of the renderingGroup being processed
  84103. */
  84104. renderingGroupId: number;
  84105. }
  84106. /**
  84107. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84108. * It is enable to manage the different groups as well as the different necessary sort functions.
  84109. * This should not be used directly aside of the few static configurations
  84110. */
  84111. export class RenderingManager {
  84112. /**
  84113. * The max id used for rendering groups (not included)
  84114. */
  84115. static MAX_RENDERINGGROUPS: number;
  84116. /**
  84117. * The min id used for rendering groups (included)
  84118. */
  84119. static MIN_RENDERINGGROUPS: number;
  84120. /**
  84121. * Used to globally prevent autoclearing scenes.
  84122. */
  84123. static AUTOCLEAR: boolean;
  84124. /**
  84125. * @hidden
  84126. */
  84127. _useSceneAutoClearSetup: boolean;
  84128. private _scene;
  84129. private _renderingGroups;
  84130. private _depthStencilBufferAlreadyCleaned;
  84131. private _autoClearDepthStencil;
  84132. private _customOpaqueSortCompareFn;
  84133. private _customAlphaTestSortCompareFn;
  84134. private _customTransparentSortCompareFn;
  84135. private _renderingGroupInfo;
  84136. /**
  84137. * Instantiates a new rendering group for a particular scene
  84138. * @param scene Defines the scene the groups belongs to
  84139. */
  84140. constructor(scene: Scene);
  84141. private _clearDepthStencilBuffer;
  84142. /**
  84143. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84144. * @hidden
  84145. */
  84146. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84147. /**
  84148. * Resets the different information of the group to prepare a new frame
  84149. * @hidden
  84150. */
  84151. reset(): void;
  84152. /**
  84153. * Dispose and release the group and its associated resources.
  84154. * @hidden
  84155. */
  84156. dispose(): void;
  84157. /**
  84158. * Clear the info related to rendering groups preventing retention points during dispose.
  84159. */
  84160. freeRenderingGroups(): void;
  84161. private _prepareRenderingGroup;
  84162. /**
  84163. * Add a sprite manager to the rendering manager in order to render it this frame.
  84164. * @param spriteManager Define the sprite manager to render
  84165. */
  84166. dispatchSprites(spriteManager: ISpriteManager): void;
  84167. /**
  84168. * Add a particle system to the rendering manager in order to render it this frame.
  84169. * @param particleSystem Define the particle system to render
  84170. */
  84171. dispatchParticles(particleSystem: IParticleSystem): void;
  84172. /**
  84173. * Add a submesh to the manager in order to render it this frame
  84174. * @param subMesh The submesh to dispatch
  84175. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84176. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84177. */
  84178. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84179. /**
  84180. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84181. * This allowed control for front to back rendering or reversly depending of the special needs.
  84182. *
  84183. * @param renderingGroupId The rendering group id corresponding to its index
  84184. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84185. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84186. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84187. */
  84188. 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;
  84189. /**
  84190. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84191. *
  84192. * @param renderingGroupId The rendering group id corresponding to its index
  84193. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84194. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84195. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84196. */
  84197. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84198. /**
  84199. * Gets the current auto clear configuration for one rendering group of the rendering
  84200. * manager.
  84201. * @param index the rendering group index to get the information for
  84202. * @returns The auto clear setup for the requested rendering group
  84203. */
  84204. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84205. }
  84206. }
  84207. declare module BABYLON {
  84208. /**
  84209. * This Helps creating a texture that will be created from a camera in your scene.
  84210. * It is basically a dynamic texture that could be used to create special effects for instance.
  84211. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84212. */
  84213. export class RenderTargetTexture extends Texture {
  84214. isCube: boolean;
  84215. /**
  84216. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84217. */
  84218. static readonly REFRESHRATE_RENDER_ONCE: number;
  84219. /**
  84220. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84221. */
  84222. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84223. /**
  84224. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84225. * the central point of your effect and can save a lot of performances.
  84226. */
  84227. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84228. /**
  84229. * Use this predicate to dynamically define the list of mesh you want to render.
  84230. * If set, the renderList property will be overwritten.
  84231. */
  84232. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84233. private _renderList;
  84234. /**
  84235. * Use this list to define the list of mesh you want to render.
  84236. */
  84237. renderList: Nullable<Array<AbstractMesh>>;
  84238. private _hookArray;
  84239. /**
  84240. * Define if particles should be rendered in your texture.
  84241. */
  84242. renderParticles: boolean;
  84243. /**
  84244. * Define if sprites should be rendered in your texture.
  84245. */
  84246. renderSprites: boolean;
  84247. /**
  84248. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84249. */
  84250. coordinatesMode: number;
  84251. /**
  84252. * Define the camera used to render the texture.
  84253. */
  84254. activeCamera: Nullable<Camera>;
  84255. /**
  84256. * Override the render function of the texture with your own one.
  84257. */
  84258. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84259. /**
  84260. * Define if camera post processes should be use while rendering the texture.
  84261. */
  84262. useCameraPostProcesses: boolean;
  84263. /**
  84264. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84265. */
  84266. ignoreCameraViewport: boolean;
  84267. private _postProcessManager;
  84268. private _postProcesses;
  84269. private _resizeObserver;
  84270. /**
  84271. * An event triggered when the texture is unbind.
  84272. */
  84273. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84274. /**
  84275. * An event triggered when the texture is unbind.
  84276. */
  84277. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84278. private _onAfterUnbindObserver;
  84279. /**
  84280. * Set a after unbind callback in the texture.
  84281. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84282. */
  84283. onAfterUnbind: () => void;
  84284. /**
  84285. * An event triggered before rendering the texture
  84286. */
  84287. onBeforeRenderObservable: Observable<number>;
  84288. private _onBeforeRenderObserver;
  84289. /**
  84290. * Set a before render callback in the texture.
  84291. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84292. */
  84293. onBeforeRender: (faceIndex: number) => void;
  84294. /**
  84295. * An event triggered after rendering the texture
  84296. */
  84297. onAfterRenderObservable: Observable<number>;
  84298. private _onAfterRenderObserver;
  84299. /**
  84300. * Set a after render callback in the texture.
  84301. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84302. */
  84303. onAfterRender: (faceIndex: number) => void;
  84304. /**
  84305. * An event triggered after the texture clear
  84306. */
  84307. onClearObservable: Observable<Engine>;
  84308. private _onClearObserver;
  84309. /**
  84310. * Set a clear callback in the texture.
  84311. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84312. */
  84313. onClear: (Engine: Engine) => void;
  84314. /**
  84315. * An event triggered when the texture is resized.
  84316. */
  84317. onResizeObservable: Observable<RenderTargetTexture>;
  84318. /**
  84319. * Define the clear color of the Render Target if it should be different from the scene.
  84320. */
  84321. clearColor: Color4;
  84322. protected _size: number | {
  84323. width: number;
  84324. height: number;
  84325. };
  84326. protected _initialSizeParameter: number | {
  84327. width: number;
  84328. height: number;
  84329. } | {
  84330. ratio: number;
  84331. };
  84332. protected _sizeRatio: Nullable<number>;
  84333. /** @hidden */
  84334. _generateMipMaps: boolean;
  84335. protected _renderingManager: RenderingManager;
  84336. /** @hidden */
  84337. _waitingRenderList: string[];
  84338. protected _doNotChangeAspectRatio: boolean;
  84339. protected _currentRefreshId: number;
  84340. protected _refreshRate: number;
  84341. protected _textureMatrix: Matrix;
  84342. protected _samples: number;
  84343. protected _renderTargetOptions: RenderTargetCreationOptions;
  84344. /**
  84345. * Gets render target creation options that were used.
  84346. */
  84347. readonly renderTargetOptions: RenderTargetCreationOptions;
  84348. protected _engine: Engine;
  84349. protected _onRatioRescale(): void;
  84350. /**
  84351. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84352. * It must define where the camera used to render the texture is set
  84353. */
  84354. boundingBoxPosition: Vector3;
  84355. private _boundingBoxSize;
  84356. /**
  84357. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84358. * When defined, the cubemap will switch to local mode
  84359. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84360. * @example https://www.babylonjs-playground.com/#RNASML
  84361. */
  84362. boundingBoxSize: Vector3;
  84363. /**
  84364. * In case the RTT has been created with a depth texture, get the associated
  84365. * depth texture.
  84366. * Otherwise, return null.
  84367. */
  84368. depthStencilTexture: Nullable<InternalTexture>;
  84369. /**
  84370. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84371. * or used a shadow, depth texture...
  84372. * @param name The friendly name of the texture
  84373. * @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)
  84374. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84375. * @param generateMipMaps True if mip maps need to be generated after render.
  84376. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84377. * @param type The type of the buffer in the RTT (int, half float, float...)
  84378. * @param isCube True if a cube texture needs to be created
  84379. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84380. * @param generateDepthBuffer True to generate a depth buffer
  84381. * @param generateStencilBuffer True to generate a stencil buffer
  84382. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84383. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84384. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84385. */
  84386. constructor(name: string, size: number | {
  84387. width: number;
  84388. height: number;
  84389. } | {
  84390. ratio: number;
  84391. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84392. /**
  84393. * Creates a depth stencil texture.
  84394. * This is only available in WebGL 2 or with the depth texture extension available.
  84395. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84396. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84397. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84398. */
  84399. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84400. private _processSizeParameter;
  84401. /**
  84402. * Define the number of samples to use in case of MSAA.
  84403. * It defaults to one meaning no MSAA has been enabled.
  84404. */
  84405. samples: number;
  84406. /**
  84407. * Resets the refresh counter of the texture and start bak from scratch.
  84408. * Could be useful to regenerate the texture if it is setup to render only once.
  84409. */
  84410. resetRefreshCounter(): void;
  84411. /**
  84412. * Define the refresh rate of the texture or the rendering frequency.
  84413. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84414. */
  84415. refreshRate: number;
  84416. /**
  84417. * Adds a post process to the render target rendering passes.
  84418. * @param postProcess define the post process to add
  84419. */
  84420. addPostProcess(postProcess: PostProcess): void;
  84421. /**
  84422. * Clear all the post processes attached to the render target
  84423. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84424. */
  84425. clearPostProcesses(dispose?: boolean): void;
  84426. /**
  84427. * Remove one of the post process from the list of attached post processes to the texture
  84428. * @param postProcess define the post process to remove from the list
  84429. */
  84430. removePostProcess(postProcess: PostProcess): void;
  84431. /** @hidden */
  84432. _shouldRender(): boolean;
  84433. /**
  84434. * Gets the actual render size of the texture.
  84435. * @returns the width of the render size
  84436. */
  84437. getRenderSize(): number;
  84438. /**
  84439. * Gets the actual render width of the texture.
  84440. * @returns the width of the render size
  84441. */
  84442. getRenderWidth(): number;
  84443. /**
  84444. * Gets the actual render height of the texture.
  84445. * @returns the height of the render size
  84446. */
  84447. getRenderHeight(): number;
  84448. /**
  84449. * Get if the texture can be rescaled or not.
  84450. */
  84451. readonly canRescale: boolean;
  84452. /**
  84453. * Resize the texture using a ratio.
  84454. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84455. */
  84456. scale(ratio: number): void;
  84457. /**
  84458. * Get the texture reflection matrix used to rotate/transform the reflection.
  84459. * @returns the reflection matrix
  84460. */
  84461. getReflectionTextureMatrix(): Matrix;
  84462. /**
  84463. * Resize the texture to a new desired size.
  84464. * Be carrefull as it will recreate all the data in the new texture.
  84465. * @param size Define the new size. It can be:
  84466. * - a number for squared texture,
  84467. * - an object containing { width: number, height: number }
  84468. * - or an object containing a ratio { ratio: number }
  84469. */
  84470. resize(size: number | {
  84471. width: number;
  84472. height: number;
  84473. } | {
  84474. ratio: number;
  84475. }): void;
  84476. /**
  84477. * Renders all the objects from the render list into the texture.
  84478. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84479. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84480. */
  84481. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84482. private _bestReflectionRenderTargetDimension;
  84483. /**
  84484. * @hidden
  84485. * @param faceIndex face index to bind to if this is a cubetexture
  84486. */
  84487. _bindFrameBuffer(faceIndex?: number): void;
  84488. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84489. private renderToTarget;
  84490. /**
  84491. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84492. * This allowed control for front to back rendering or reversly depending of the special needs.
  84493. *
  84494. * @param renderingGroupId The rendering group id corresponding to its index
  84495. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84496. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84497. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84498. */
  84499. 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;
  84500. /**
  84501. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84502. *
  84503. * @param renderingGroupId The rendering group id corresponding to its index
  84504. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84505. */
  84506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84507. /**
  84508. * Clones the texture.
  84509. * @returns the cloned texture
  84510. */
  84511. clone(): RenderTargetTexture;
  84512. /**
  84513. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84514. * @returns The JSON representation of the texture
  84515. */
  84516. serialize(): any;
  84517. /**
  84518. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84519. */
  84520. disposeFramebufferObjects(): void;
  84521. /**
  84522. * Dispose the texture and release its associated resources.
  84523. */
  84524. dispose(): void;
  84525. /** @hidden */
  84526. _rebuild(): void;
  84527. /**
  84528. * Clear the info related to rendering groups preventing retention point in material dispose.
  84529. */
  84530. freeRenderingGroups(): void;
  84531. /**
  84532. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84533. * @returns the view count
  84534. */
  84535. getViewCount(): number;
  84536. }
  84537. }
  84538. declare module BABYLON {
  84539. /**
  84540. * Base class for the main features of a material in Babylon.js
  84541. */
  84542. export class Material implements IAnimatable {
  84543. /**
  84544. * Returns the triangle fill mode
  84545. */
  84546. static readonly TriangleFillMode: number;
  84547. /**
  84548. * Returns the wireframe mode
  84549. */
  84550. static readonly WireFrameFillMode: number;
  84551. /**
  84552. * Returns the point fill mode
  84553. */
  84554. static readonly PointFillMode: number;
  84555. /**
  84556. * Returns the point list draw mode
  84557. */
  84558. static readonly PointListDrawMode: number;
  84559. /**
  84560. * Returns the line list draw mode
  84561. */
  84562. static readonly LineListDrawMode: number;
  84563. /**
  84564. * Returns the line loop draw mode
  84565. */
  84566. static readonly LineLoopDrawMode: number;
  84567. /**
  84568. * Returns the line strip draw mode
  84569. */
  84570. static readonly LineStripDrawMode: number;
  84571. /**
  84572. * Returns the triangle strip draw mode
  84573. */
  84574. static readonly TriangleStripDrawMode: number;
  84575. /**
  84576. * Returns the triangle fan draw mode
  84577. */
  84578. static readonly TriangleFanDrawMode: number;
  84579. /**
  84580. * Stores the clock-wise side orientation
  84581. */
  84582. static readonly ClockWiseSideOrientation: number;
  84583. /**
  84584. * Stores the counter clock-wise side orientation
  84585. */
  84586. static readonly CounterClockWiseSideOrientation: number;
  84587. /**
  84588. * The dirty texture flag value
  84589. */
  84590. static readonly TextureDirtyFlag: number;
  84591. /**
  84592. * The dirty light flag value
  84593. */
  84594. static readonly LightDirtyFlag: number;
  84595. /**
  84596. * The dirty fresnel flag value
  84597. */
  84598. static readonly FresnelDirtyFlag: number;
  84599. /**
  84600. * The dirty attribute flag value
  84601. */
  84602. static readonly AttributesDirtyFlag: number;
  84603. /**
  84604. * The dirty misc flag value
  84605. */
  84606. static readonly MiscDirtyFlag: number;
  84607. /**
  84608. * The all dirty flag value
  84609. */
  84610. static readonly AllDirtyFlag: number;
  84611. /**
  84612. * The ID of the material
  84613. */
  84614. id: string;
  84615. /**
  84616. * Gets or sets the unique id of the material
  84617. */
  84618. uniqueId: number;
  84619. /**
  84620. * The name of the material
  84621. */
  84622. name: string;
  84623. /**
  84624. * Gets or sets user defined metadata
  84625. */
  84626. metadata: any;
  84627. /**
  84628. * For internal use only. Please do not use.
  84629. */
  84630. reservedDataStore: any;
  84631. /**
  84632. * Specifies if the ready state should be checked on each call
  84633. */
  84634. checkReadyOnEveryCall: boolean;
  84635. /**
  84636. * Specifies if the ready state should be checked once
  84637. */
  84638. checkReadyOnlyOnce: boolean;
  84639. /**
  84640. * The state of the material
  84641. */
  84642. state: string;
  84643. /**
  84644. * The alpha value of the material
  84645. */
  84646. protected _alpha: number;
  84647. /**
  84648. * List of inspectable custom properties (used by the Inspector)
  84649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84650. */
  84651. inspectableCustomProperties: IInspectable[];
  84652. /**
  84653. * Sets the alpha value of the material
  84654. */
  84655. /**
  84656. * Gets the alpha value of the material
  84657. */
  84658. alpha: number;
  84659. /**
  84660. * Specifies if back face culling is enabled
  84661. */
  84662. protected _backFaceCulling: boolean;
  84663. /**
  84664. * Sets the back-face culling state
  84665. */
  84666. /**
  84667. * Gets the back-face culling state
  84668. */
  84669. backFaceCulling: boolean;
  84670. /**
  84671. * Stores the value for side orientation
  84672. */
  84673. sideOrientation: number;
  84674. /**
  84675. * Callback triggered when the material is compiled
  84676. */
  84677. onCompiled: Nullable<(effect: Effect) => void>;
  84678. /**
  84679. * Callback triggered when an error occurs
  84680. */
  84681. onError: Nullable<(effect: Effect, errors: string) => void>;
  84682. /**
  84683. * Callback triggered to get the render target textures
  84684. */
  84685. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84686. /**
  84687. * Gets a boolean indicating that current material needs to register RTT
  84688. */
  84689. readonly hasRenderTargetTextures: boolean;
  84690. /**
  84691. * Specifies if the material should be serialized
  84692. */
  84693. doNotSerialize: boolean;
  84694. /**
  84695. * @hidden
  84696. */
  84697. _storeEffectOnSubMeshes: boolean;
  84698. /**
  84699. * Stores the animations for the material
  84700. */
  84701. animations: Nullable<Array<Animation>>;
  84702. /**
  84703. * An event triggered when the material is disposed
  84704. */
  84705. onDisposeObservable: Observable<Material>;
  84706. /**
  84707. * An observer which watches for dispose events
  84708. */
  84709. private _onDisposeObserver;
  84710. private _onUnBindObservable;
  84711. /**
  84712. * Called during a dispose event
  84713. */
  84714. onDispose: () => void;
  84715. private _onBindObservable;
  84716. /**
  84717. * An event triggered when the material is bound
  84718. */
  84719. readonly onBindObservable: Observable<AbstractMesh>;
  84720. /**
  84721. * An observer which watches for bind events
  84722. */
  84723. private _onBindObserver;
  84724. /**
  84725. * Called during a bind event
  84726. */
  84727. onBind: (Mesh: AbstractMesh) => void;
  84728. /**
  84729. * An event triggered when the material is unbound
  84730. */
  84731. readonly onUnBindObservable: Observable<Material>;
  84732. /**
  84733. * Stores the value of the alpha mode
  84734. */
  84735. private _alphaMode;
  84736. /**
  84737. * Sets the value of the alpha mode.
  84738. *
  84739. * | Value | Type | Description |
  84740. * | --- | --- | --- |
  84741. * | 0 | ALPHA_DISABLE | |
  84742. * | 1 | ALPHA_ADD | |
  84743. * | 2 | ALPHA_COMBINE | |
  84744. * | 3 | ALPHA_SUBTRACT | |
  84745. * | 4 | ALPHA_MULTIPLY | |
  84746. * | 5 | ALPHA_MAXIMIZED | |
  84747. * | 6 | ALPHA_ONEONE | |
  84748. * | 7 | ALPHA_PREMULTIPLIED | |
  84749. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84750. * | 9 | ALPHA_INTERPOLATE | |
  84751. * | 10 | ALPHA_SCREENMODE | |
  84752. *
  84753. */
  84754. /**
  84755. * Gets the value of the alpha mode
  84756. */
  84757. alphaMode: number;
  84758. /**
  84759. * Stores the state of the need depth pre-pass value
  84760. */
  84761. private _needDepthPrePass;
  84762. /**
  84763. * Sets the need depth pre-pass value
  84764. */
  84765. /**
  84766. * Gets the depth pre-pass value
  84767. */
  84768. needDepthPrePass: boolean;
  84769. /**
  84770. * Specifies if depth writing should be disabled
  84771. */
  84772. disableDepthWrite: boolean;
  84773. /**
  84774. * Specifies if depth writing should be forced
  84775. */
  84776. forceDepthWrite: boolean;
  84777. /**
  84778. * Specifies if there should be a separate pass for culling
  84779. */
  84780. separateCullingPass: boolean;
  84781. /**
  84782. * Stores the state specifing if fog should be enabled
  84783. */
  84784. private _fogEnabled;
  84785. /**
  84786. * Sets the state for enabling fog
  84787. */
  84788. /**
  84789. * Gets the value of the fog enabled state
  84790. */
  84791. fogEnabled: boolean;
  84792. /**
  84793. * Stores the size of points
  84794. */
  84795. pointSize: number;
  84796. /**
  84797. * Stores the z offset value
  84798. */
  84799. zOffset: number;
  84800. /**
  84801. * Gets a value specifying if wireframe mode is enabled
  84802. */
  84803. /**
  84804. * Sets the state of wireframe mode
  84805. */
  84806. wireframe: boolean;
  84807. /**
  84808. * Gets the value specifying if point clouds are enabled
  84809. */
  84810. /**
  84811. * Sets the state of point cloud mode
  84812. */
  84813. pointsCloud: boolean;
  84814. /**
  84815. * Gets the material fill mode
  84816. */
  84817. /**
  84818. * Sets the material fill mode
  84819. */
  84820. fillMode: number;
  84821. /**
  84822. * @hidden
  84823. * Stores the effects for the material
  84824. */
  84825. _effect: Nullable<Effect>;
  84826. /**
  84827. * @hidden
  84828. * Specifies if the material was previously ready
  84829. */
  84830. _wasPreviouslyReady: boolean;
  84831. /**
  84832. * Specifies if uniform buffers should be used
  84833. */
  84834. private _useUBO;
  84835. /**
  84836. * Stores a reference to the scene
  84837. */
  84838. private _scene;
  84839. /**
  84840. * Stores the fill mode state
  84841. */
  84842. private _fillMode;
  84843. /**
  84844. * Specifies if the depth write state should be cached
  84845. */
  84846. private _cachedDepthWriteState;
  84847. /**
  84848. * Stores the uniform buffer
  84849. */
  84850. protected _uniformBuffer: UniformBuffer;
  84851. /** @hidden */
  84852. _indexInSceneMaterialArray: number;
  84853. /** @hidden */
  84854. meshMap: Nullable<{
  84855. [id: string]: AbstractMesh | undefined;
  84856. }>;
  84857. /**
  84858. * Creates a material instance
  84859. * @param name defines the name of the material
  84860. * @param scene defines the scene to reference
  84861. * @param doNotAdd specifies if the material should be added to the scene
  84862. */
  84863. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84864. /**
  84865. * Returns a string representation of the current material
  84866. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84867. * @returns a string with material information
  84868. */
  84869. toString(fullDetails?: boolean): string;
  84870. /**
  84871. * Gets the class name of the material
  84872. * @returns a string with the class name of the material
  84873. */
  84874. getClassName(): string;
  84875. /**
  84876. * Specifies if updates for the material been locked
  84877. */
  84878. readonly isFrozen: boolean;
  84879. /**
  84880. * Locks updates for the material
  84881. */
  84882. freeze(): void;
  84883. /**
  84884. * Unlocks updates for the material
  84885. */
  84886. unfreeze(): void;
  84887. /**
  84888. * Specifies if the material is ready to be used
  84889. * @param mesh defines the mesh to check
  84890. * @param useInstances specifies if instances should be used
  84891. * @returns a boolean indicating if the material is ready to be used
  84892. */
  84893. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84894. /**
  84895. * Specifies that the submesh is ready to be used
  84896. * @param mesh defines the mesh to check
  84897. * @param subMesh defines which submesh to check
  84898. * @param useInstances specifies that instances should be used
  84899. * @returns a boolean indicating that the submesh is ready or not
  84900. */
  84901. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84902. /**
  84903. * Returns the material effect
  84904. * @returns the effect associated with the material
  84905. */
  84906. getEffect(): Nullable<Effect>;
  84907. /**
  84908. * Returns the current scene
  84909. * @returns a Scene
  84910. */
  84911. getScene(): Scene;
  84912. /**
  84913. * Specifies if the material will require alpha blending
  84914. * @returns a boolean specifying if alpha blending is needed
  84915. */
  84916. needAlphaBlending(): boolean;
  84917. /**
  84918. * Specifies if the mesh will require alpha blending
  84919. * @param mesh defines the mesh to check
  84920. * @returns a boolean specifying if alpha blending is needed for the mesh
  84921. */
  84922. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84923. /**
  84924. * Specifies if this material should be rendered in alpha test mode
  84925. * @returns a boolean specifying if an alpha test is needed.
  84926. */
  84927. needAlphaTesting(): boolean;
  84928. /**
  84929. * Gets the texture used for the alpha test
  84930. * @returns the texture to use for alpha testing
  84931. */
  84932. getAlphaTestTexture(): Nullable<BaseTexture>;
  84933. /**
  84934. * Marks the material to indicate that it needs to be re-calculated
  84935. */
  84936. markDirty(): void;
  84937. /** @hidden */
  84938. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84939. /**
  84940. * Binds the material to the mesh
  84941. * @param world defines the world transformation matrix
  84942. * @param mesh defines the mesh to bind the material to
  84943. */
  84944. bind(world: Matrix, mesh?: Mesh): void;
  84945. /**
  84946. * Binds the submesh to the material
  84947. * @param world defines the world transformation matrix
  84948. * @param mesh defines the mesh containing the submesh
  84949. * @param subMesh defines the submesh to bind the material to
  84950. */
  84951. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84952. /**
  84953. * Binds the world matrix to the material
  84954. * @param world defines the world transformation matrix
  84955. */
  84956. bindOnlyWorldMatrix(world: Matrix): void;
  84957. /**
  84958. * Binds the scene's uniform buffer to the effect.
  84959. * @param effect defines the effect to bind to the scene uniform buffer
  84960. * @param sceneUbo defines the uniform buffer storing scene data
  84961. */
  84962. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84963. /**
  84964. * Binds the view matrix to the effect
  84965. * @param effect defines the effect to bind the view matrix to
  84966. */
  84967. bindView(effect: Effect): void;
  84968. /**
  84969. * Binds the view projection matrix to the effect
  84970. * @param effect defines the effect to bind the view projection matrix to
  84971. */
  84972. bindViewProjection(effect: Effect): void;
  84973. /**
  84974. * Specifies if material alpha testing should be turned on for the mesh
  84975. * @param mesh defines the mesh to check
  84976. */
  84977. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84978. /**
  84979. * Processes to execute after binding the material to a mesh
  84980. * @param mesh defines the rendered mesh
  84981. */
  84982. protected _afterBind(mesh?: Mesh): void;
  84983. /**
  84984. * Unbinds the material from the mesh
  84985. */
  84986. unbind(): void;
  84987. /**
  84988. * Gets the active textures from the material
  84989. * @returns an array of textures
  84990. */
  84991. getActiveTextures(): BaseTexture[];
  84992. /**
  84993. * Specifies if the material uses a texture
  84994. * @param texture defines the texture to check against the material
  84995. * @returns a boolean specifying if the material uses the texture
  84996. */
  84997. hasTexture(texture: BaseTexture): boolean;
  84998. /**
  84999. * Makes a duplicate of the material, and gives it a new name
  85000. * @param name defines the new name for the duplicated material
  85001. * @returns the cloned material
  85002. */
  85003. clone(name: string): Nullable<Material>;
  85004. /**
  85005. * Gets the meshes bound to the material
  85006. * @returns an array of meshes bound to the material
  85007. */
  85008. getBindedMeshes(): AbstractMesh[];
  85009. /**
  85010. * Force shader compilation
  85011. * @param mesh defines the mesh associated with this material
  85012. * @param onCompiled defines a function to execute once the material is compiled
  85013. * @param options defines the options to configure the compilation
  85014. */
  85015. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85016. clipPlane: boolean;
  85017. }>): void;
  85018. /**
  85019. * Force shader compilation
  85020. * @param mesh defines the mesh that will use this material
  85021. * @param options defines additional options for compiling the shaders
  85022. * @returns a promise that resolves when the compilation completes
  85023. */
  85024. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85025. clipPlane: boolean;
  85026. }>): Promise<void>;
  85027. private static readonly _AllDirtyCallBack;
  85028. private static readonly _ImageProcessingDirtyCallBack;
  85029. private static readonly _TextureDirtyCallBack;
  85030. private static readonly _FresnelDirtyCallBack;
  85031. private static readonly _MiscDirtyCallBack;
  85032. private static readonly _LightsDirtyCallBack;
  85033. private static readonly _AttributeDirtyCallBack;
  85034. private static _FresnelAndMiscDirtyCallBack;
  85035. private static _TextureAndMiscDirtyCallBack;
  85036. private static readonly _DirtyCallbackArray;
  85037. private static readonly _RunDirtyCallBacks;
  85038. /**
  85039. * Marks a define in the material to indicate that it needs to be re-computed
  85040. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85041. */
  85042. markAsDirty(flag: number): void;
  85043. /**
  85044. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85045. * @param func defines a function which checks material defines against the submeshes
  85046. */
  85047. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85048. /**
  85049. * Indicates that we need to re-calculated for all submeshes
  85050. */
  85051. protected _markAllSubMeshesAsAllDirty(): void;
  85052. /**
  85053. * Indicates that image processing needs to be re-calculated for all submeshes
  85054. */
  85055. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85056. /**
  85057. * Indicates that textures need to be re-calculated for all submeshes
  85058. */
  85059. protected _markAllSubMeshesAsTexturesDirty(): void;
  85060. /**
  85061. * Indicates that fresnel needs to be re-calculated for all submeshes
  85062. */
  85063. protected _markAllSubMeshesAsFresnelDirty(): void;
  85064. /**
  85065. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85066. */
  85067. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85068. /**
  85069. * Indicates that lights need to be re-calculated for all submeshes
  85070. */
  85071. protected _markAllSubMeshesAsLightsDirty(): void;
  85072. /**
  85073. * Indicates that attributes need to be re-calculated for all submeshes
  85074. */
  85075. protected _markAllSubMeshesAsAttributesDirty(): void;
  85076. /**
  85077. * Indicates that misc needs to be re-calculated for all submeshes
  85078. */
  85079. protected _markAllSubMeshesAsMiscDirty(): void;
  85080. /**
  85081. * Indicates that textures and misc need to be re-calculated for all submeshes
  85082. */
  85083. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85084. /**
  85085. * Disposes the material
  85086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85087. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85088. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85089. */
  85090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85091. /** @hidden */
  85092. private releaseVertexArrayObject;
  85093. /**
  85094. * Serializes this material
  85095. * @returns the serialized material object
  85096. */
  85097. serialize(): any;
  85098. /**
  85099. * Creates a material from parsed material data
  85100. * @param parsedMaterial defines parsed material data
  85101. * @param scene defines the hosting scene
  85102. * @param rootUrl defines the root URL to use to load textures
  85103. * @returns a new material
  85104. */
  85105. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85106. }
  85107. }
  85108. declare module BABYLON {
  85109. /**
  85110. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85111. * separate meshes. This can be use to improve performances.
  85112. * @see http://doc.babylonjs.com/how_to/multi_materials
  85113. */
  85114. export class MultiMaterial extends Material {
  85115. private _subMaterials;
  85116. /**
  85117. * Gets or Sets the list of Materials used within the multi material.
  85118. * They need to be ordered according to the submeshes order in the associated mesh
  85119. */
  85120. subMaterials: Nullable<Material>[];
  85121. /**
  85122. * Function used to align with Node.getChildren()
  85123. * @returns the list of Materials used within the multi material
  85124. */
  85125. getChildren(): Nullable<Material>[];
  85126. /**
  85127. * Instantiates a new Multi Material
  85128. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85129. * separate meshes. This can be use to improve performances.
  85130. * @see http://doc.babylonjs.com/how_to/multi_materials
  85131. * @param name Define the name in the scene
  85132. * @param scene Define the scene the material belongs to
  85133. */
  85134. constructor(name: string, scene: Scene);
  85135. private _hookArray;
  85136. /**
  85137. * Get one of the submaterial by its index in the submaterials array
  85138. * @param index The index to look the sub material at
  85139. * @returns The Material if the index has been defined
  85140. */
  85141. getSubMaterial(index: number): Nullable<Material>;
  85142. /**
  85143. * Get the list of active textures for the whole sub materials list.
  85144. * @returns All the textures that will be used during the rendering
  85145. */
  85146. getActiveTextures(): BaseTexture[];
  85147. /**
  85148. * Gets the current class name of the material e.g. "MultiMaterial"
  85149. * Mainly use in serialization.
  85150. * @returns the class name
  85151. */
  85152. getClassName(): string;
  85153. /**
  85154. * Checks if the material is ready to render the requested sub mesh
  85155. * @param mesh Define the mesh the submesh belongs to
  85156. * @param subMesh Define the sub mesh to look readyness for
  85157. * @param useInstances Define whether or not the material is used with instances
  85158. * @returns true if ready, otherwise false
  85159. */
  85160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85161. /**
  85162. * Clones the current material and its related sub materials
  85163. * @param name Define the name of the newly cloned material
  85164. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85165. * @returns the cloned material
  85166. */
  85167. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85168. /**
  85169. * Serializes the materials into a JSON representation.
  85170. * @returns the JSON representation
  85171. */
  85172. serialize(): any;
  85173. /**
  85174. * Dispose the material and release its associated resources
  85175. * @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)
  85176. * @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)
  85177. * @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)
  85178. */
  85179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85180. /**
  85181. * Creates a MultiMaterial from parsed MultiMaterial data.
  85182. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85183. * @param scene defines the hosting scene
  85184. * @returns a new MultiMaterial
  85185. */
  85186. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85187. }
  85188. }
  85189. declare module BABYLON {
  85190. /**
  85191. * Base class for submeshes
  85192. */
  85193. export class BaseSubMesh {
  85194. /** @hidden */
  85195. _materialDefines: Nullable<MaterialDefines>;
  85196. /** @hidden */
  85197. _materialEffect: Nullable<Effect>;
  85198. /**
  85199. * Gets associated effect
  85200. */
  85201. readonly effect: Nullable<Effect>;
  85202. /**
  85203. * Sets associated effect (effect used to render this submesh)
  85204. * @param effect defines the effect to associate with
  85205. * @param defines defines the set of defines used to compile this effect
  85206. */
  85207. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85208. }
  85209. /**
  85210. * Defines a subdivision inside a mesh
  85211. */
  85212. export class SubMesh extends BaseSubMesh implements ICullable {
  85213. /** the material index to use */
  85214. materialIndex: number;
  85215. /** vertex index start */
  85216. verticesStart: number;
  85217. /** vertices count */
  85218. verticesCount: number;
  85219. /** index start */
  85220. indexStart: number;
  85221. /** indices count */
  85222. indexCount: number;
  85223. /** @hidden */
  85224. _linesIndexCount: number;
  85225. private _mesh;
  85226. private _renderingMesh;
  85227. private _boundingInfo;
  85228. private _linesIndexBuffer;
  85229. /** @hidden */
  85230. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85231. /** @hidden */
  85232. _trianglePlanes: Plane[];
  85233. /** @hidden */
  85234. _lastColliderTransformMatrix: Nullable<Matrix>;
  85235. /** @hidden */
  85236. _renderId: number;
  85237. /** @hidden */
  85238. _alphaIndex: number;
  85239. /** @hidden */
  85240. _distanceToCamera: number;
  85241. /** @hidden */
  85242. _id: number;
  85243. private _currentMaterial;
  85244. /**
  85245. * Add a new submesh to a mesh
  85246. * @param materialIndex defines the material index to use
  85247. * @param verticesStart defines vertex index start
  85248. * @param verticesCount defines vertices count
  85249. * @param indexStart defines index start
  85250. * @param indexCount defines indices count
  85251. * @param mesh defines the parent mesh
  85252. * @param renderingMesh defines an optional rendering mesh
  85253. * @param createBoundingBox defines if bounding box should be created for this submesh
  85254. * @returns the new submesh
  85255. */
  85256. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85257. /**
  85258. * Creates a new submesh
  85259. * @param materialIndex defines the material index to use
  85260. * @param verticesStart defines vertex index start
  85261. * @param verticesCount defines vertices count
  85262. * @param indexStart defines index start
  85263. * @param indexCount defines indices count
  85264. * @param mesh defines the parent mesh
  85265. * @param renderingMesh defines an optional rendering mesh
  85266. * @param createBoundingBox defines if bounding box should be created for this submesh
  85267. */
  85268. constructor(
  85269. /** the material index to use */
  85270. materialIndex: number,
  85271. /** vertex index start */
  85272. verticesStart: number,
  85273. /** vertices count */
  85274. verticesCount: number,
  85275. /** index start */
  85276. indexStart: number,
  85277. /** indices count */
  85278. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85279. /**
  85280. * Returns true if this submesh covers the entire parent mesh
  85281. * @ignorenaming
  85282. */
  85283. readonly IsGlobal: boolean;
  85284. /**
  85285. * Returns the submesh BoudingInfo object
  85286. * @returns current bounding info (or mesh's one if the submesh is global)
  85287. */
  85288. getBoundingInfo(): BoundingInfo;
  85289. /**
  85290. * Sets the submesh BoundingInfo
  85291. * @param boundingInfo defines the new bounding info to use
  85292. * @returns the SubMesh
  85293. */
  85294. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85295. /**
  85296. * Returns the mesh of the current submesh
  85297. * @return the parent mesh
  85298. */
  85299. getMesh(): AbstractMesh;
  85300. /**
  85301. * Returns the rendering mesh of the submesh
  85302. * @returns the rendering mesh (could be different from parent mesh)
  85303. */
  85304. getRenderingMesh(): Mesh;
  85305. /**
  85306. * Returns the submesh material
  85307. * @returns null or the current material
  85308. */
  85309. getMaterial(): Nullable<Material>;
  85310. /**
  85311. * Sets a new updated BoundingInfo object to the submesh
  85312. * @param data defines an optional position array to use to determine the bounding info
  85313. * @returns the SubMesh
  85314. */
  85315. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85316. /** @hidden */
  85317. _checkCollision(collider: Collider): boolean;
  85318. /**
  85319. * Updates the submesh BoundingInfo
  85320. * @param world defines the world matrix to use to update the bounding info
  85321. * @returns the submesh
  85322. */
  85323. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85324. /**
  85325. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85326. * @param frustumPlanes defines the frustum planes
  85327. * @returns true if the submesh is intersecting with the frustum
  85328. */
  85329. isInFrustum(frustumPlanes: Plane[]): boolean;
  85330. /**
  85331. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85332. * @param frustumPlanes defines the frustum planes
  85333. * @returns true if the submesh is inside the frustum
  85334. */
  85335. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85336. /**
  85337. * Renders the submesh
  85338. * @param enableAlphaMode defines if alpha needs to be used
  85339. * @returns the submesh
  85340. */
  85341. render(enableAlphaMode: boolean): SubMesh;
  85342. /**
  85343. * @hidden
  85344. */
  85345. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85346. /**
  85347. * Checks if the submesh intersects with a ray
  85348. * @param ray defines the ray to test
  85349. * @returns true is the passed ray intersects the submesh bounding box
  85350. */
  85351. canIntersects(ray: Ray): boolean;
  85352. /**
  85353. * Intersects current submesh with a ray
  85354. * @param ray defines the ray to test
  85355. * @param positions defines mesh's positions array
  85356. * @param indices defines mesh's indices array
  85357. * @param fastCheck defines if only bounding info should be used
  85358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85359. * @returns intersection info or null if no intersection
  85360. */
  85361. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85362. /** @hidden */
  85363. private _intersectLines;
  85364. /** @hidden */
  85365. private _intersectUnIndexedLines;
  85366. /** @hidden */
  85367. private _intersectTriangles;
  85368. /** @hidden */
  85369. private _intersectUnIndexedTriangles;
  85370. /** @hidden */
  85371. _rebuild(): void;
  85372. /**
  85373. * Creates a new submesh from the passed mesh
  85374. * @param newMesh defines the new hosting mesh
  85375. * @param newRenderingMesh defines an optional rendering mesh
  85376. * @returns the new submesh
  85377. */
  85378. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85379. /**
  85380. * Release associated resources
  85381. */
  85382. dispose(): void;
  85383. /**
  85384. * Gets the class name
  85385. * @returns the string "SubMesh".
  85386. */
  85387. getClassName(): string;
  85388. /**
  85389. * Creates a new submesh from indices data
  85390. * @param materialIndex the index of the main mesh material
  85391. * @param startIndex the index where to start the copy in the mesh indices array
  85392. * @param indexCount the number of indices to copy then from the startIndex
  85393. * @param mesh the main mesh to create the submesh from
  85394. * @param renderingMesh the optional rendering mesh
  85395. * @returns a new submesh
  85396. */
  85397. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85398. }
  85399. }
  85400. declare module BABYLON {
  85401. /**
  85402. * Class used to represent data loading progression
  85403. */
  85404. export class SceneLoaderFlags {
  85405. private static _ForceFullSceneLoadingForIncremental;
  85406. private static _ShowLoadingScreen;
  85407. private static _CleanBoneMatrixWeights;
  85408. private static _loggingLevel;
  85409. /**
  85410. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85411. */
  85412. static ForceFullSceneLoadingForIncremental: boolean;
  85413. /**
  85414. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85415. */
  85416. static ShowLoadingScreen: boolean;
  85417. /**
  85418. * Defines the current logging level (while loading the scene)
  85419. * @ignorenaming
  85420. */
  85421. static loggingLevel: number;
  85422. /**
  85423. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85424. */
  85425. static CleanBoneMatrixWeights: boolean;
  85426. }
  85427. }
  85428. declare module BABYLON {
  85429. /**
  85430. * Class used to store geometry data (vertex buffers + index buffer)
  85431. */
  85432. export class Geometry implements IGetSetVerticesData {
  85433. /**
  85434. * Gets or sets the ID of the geometry
  85435. */
  85436. id: string;
  85437. /**
  85438. * Gets or sets the unique ID of the geometry
  85439. */
  85440. uniqueId: number;
  85441. /**
  85442. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85443. */
  85444. delayLoadState: number;
  85445. /**
  85446. * Gets the file containing the data to load when running in delay load state
  85447. */
  85448. delayLoadingFile: Nullable<string>;
  85449. /**
  85450. * Callback called when the geometry is updated
  85451. */
  85452. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85453. private _scene;
  85454. private _engine;
  85455. private _meshes;
  85456. private _totalVertices;
  85457. /** @hidden */
  85458. _indices: IndicesArray;
  85459. /** @hidden */
  85460. _vertexBuffers: {
  85461. [key: string]: VertexBuffer;
  85462. };
  85463. private _isDisposed;
  85464. private _extend;
  85465. private _boundingBias;
  85466. /** @hidden */
  85467. _delayInfo: Array<string>;
  85468. private _indexBuffer;
  85469. private _indexBufferIsUpdatable;
  85470. /** @hidden */
  85471. _boundingInfo: Nullable<BoundingInfo>;
  85472. /** @hidden */
  85473. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85474. /** @hidden */
  85475. _softwareSkinningFrameId: number;
  85476. private _vertexArrayObjects;
  85477. private _updatable;
  85478. /** @hidden */
  85479. _positions: Nullable<Vector3[]>;
  85480. /**
  85481. * 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
  85482. */
  85483. /**
  85484. * 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
  85485. */
  85486. boundingBias: Vector2;
  85487. /**
  85488. * Static function used to attach a new empty geometry to a mesh
  85489. * @param mesh defines the mesh to attach the geometry to
  85490. * @returns the new Geometry
  85491. */
  85492. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85493. /**
  85494. * Creates a new geometry
  85495. * @param id defines the unique ID
  85496. * @param scene defines the hosting scene
  85497. * @param vertexData defines the VertexData used to get geometry data
  85498. * @param updatable defines if geometry must be updatable (false by default)
  85499. * @param mesh defines the mesh that will be associated with the geometry
  85500. */
  85501. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85502. /**
  85503. * Gets the current extend of the geometry
  85504. */
  85505. readonly extend: {
  85506. minimum: Vector3;
  85507. maximum: Vector3;
  85508. };
  85509. /**
  85510. * Gets the hosting scene
  85511. * @returns the hosting Scene
  85512. */
  85513. getScene(): Scene;
  85514. /**
  85515. * Gets the hosting engine
  85516. * @returns the hosting Engine
  85517. */
  85518. getEngine(): Engine;
  85519. /**
  85520. * Defines if the geometry is ready to use
  85521. * @returns true if the geometry is ready to be used
  85522. */
  85523. isReady(): boolean;
  85524. /**
  85525. * Gets a value indicating that the geometry should not be serialized
  85526. */
  85527. readonly doNotSerialize: boolean;
  85528. /** @hidden */
  85529. _rebuild(): void;
  85530. /**
  85531. * Affects all geometry data in one call
  85532. * @param vertexData defines the geometry data
  85533. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85534. */
  85535. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85536. /**
  85537. * Set specific vertex data
  85538. * @param kind defines the data kind (Position, normal, etc...)
  85539. * @param data defines the vertex data to use
  85540. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85541. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85542. */
  85543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85544. /**
  85545. * Removes a specific vertex data
  85546. * @param kind defines the data kind (Position, normal, etc...)
  85547. */
  85548. removeVerticesData(kind: string): void;
  85549. /**
  85550. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85551. * @param buffer defines the vertex buffer to use
  85552. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85553. */
  85554. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85555. /**
  85556. * Update a specific vertex buffer
  85557. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85558. * It will do nothing if the buffer is not updatable
  85559. * @param kind defines the data kind (Position, normal, etc...)
  85560. * @param data defines the data to use
  85561. * @param offset defines the offset in the target buffer where to store the data
  85562. * @param useBytes set to true if the offset is in bytes
  85563. */
  85564. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85565. /**
  85566. * Update a specific vertex buffer
  85567. * This function will create a new buffer if the current one is not updatable
  85568. * @param kind defines the data kind (Position, normal, etc...)
  85569. * @param data defines the data to use
  85570. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85571. */
  85572. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85573. private _updateBoundingInfo;
  85574. /** @hidden */
  85575. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85576. /**
  85577. * Gets total number of vertices
  85578. * @returns the total number of vertices
  85579. */
  85580. getTotalVertices(): number;
  85581. /**
  85582. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85583. * @param kind defines the data kind (Position, normal, etc...)
  85584. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85586. * @returns a float array containing vertex data
  85587. */
  85588. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85589. /**
  85590. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85591. * @param kind defines the data kind (Position, normal, etc...)
  85592. * @returns true if the vertex buffer with the specified kind is updatable
  85593. */
  85594. isVertexBufferUpdatable(kind: string): boolean;
  85595. /**
  85596. * Gets a specific vertex buffer
  85597. * @param kind defines the data kind (Position, normal, etc...)
  85598. * @returns a VertexBuffer
  85599. */
  85600. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85601. /**
  85602. * Returns all vertex buffers
  85603. * @return an object holding all vertex buffers indexed by kind
  85604. */
  85605. getVertexBuffers(): Nullable<{
  85606. [key: string]: VertexBuffer;
  85607. }>;
  85608. /**
  85609. * Gets a boolean indicating if specific vertex buffer is present
  85610. * @param kind defines the data kind (Position, normal, etc...)
  85611. * @returns true if data is present
  85612. */
  85613. isVerticesDataPresent(kind: string): boolean;
  85614. /**
  85615. * Gets a list of all attached data kinds (Position, normal, etc...)
  85616. * @returns a list of string containing all kinds
  85617. */
  85618. getVerticesDataKinds(): string[];
  85619. /**
  85620. * Update index buffer
  85621. * @param indices defines the indices to store in the index buffer
  85622. * @param offset defines the offset in the target buffer where to store the data
  85623. * @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)
  85624. */
  85625. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85626. /**
  85627. * Creates a new index buffer
  85628. * @param indices defines the indices to store in the index buffer
  85629. * @param totalVertices defines the total number of vertices (could be null)
  85630. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85631. */
  85632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85633. /**
  85634. * Return the total number of indices
  85635. * @returns the total number of indices
  85636. */
  85637. getTotalIndices(): number;
  85638. /**
  85639. * Gets the index buffer array
  85640. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85641. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85642. * @returns the index buffer array
  85643. */
  85644. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85645. /**
  85646. * Gets the index buffer
  85647. * @return the index buffer
  85648. */
  85649. getIndexBuffer(): Nullable<DataBuffer>;
  85650. /** @hidden */
  85651. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85652. /**
  85653. * Release the associated resources for a specific mesh
  85654. * @param mesh defines the source mesh
  85655. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85656. */
  85657. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85658. /**
  85659. * Apply current geometry to a given mesh
  85660. * @param mesh defines the mesh to apply geometry to
  85661. */
  85662. applyToMesh(mesh: Mesh): void;
  85663. private _updateExtend;
  85664. private _applyToMesh;
  85665. private notifyUpdate;
  85666. /**
  85667. * Load the geometry if it was flagged as delay loaded
  85668. * @param scene defines the hosting scene
  85669. * @param onLoaded defines a callback called when the geometry is loaded
  85670. */
  85671. load(scene: Scene, onLoaded?: () => void): void;
  85672. private _queueLoad;
  85673. /**
  85674. * Invert the geometry to move from a right handed system to a left handed one.
  85675. */
  85676. toLeftHanded(): void;
  85677. /** @hidden */
  85678. _resetPointsArrayCache(): void;
  85679. /** @hidden */
  85680. _generatePointsArray(): boolean;
  85681. /**
  85682. * Gets a value indicating if the geometry is disposed
  85683. * @returns true if the geometry was disposed
  85684. */
  85685. isDisposed(): boolean;
  85686. private _disposeVertexArrayObjects;
  85687. /**
  85688. * Free all associated resources
  85689. */
  85690. dispose(): void;
  85691. /**
  85692. * Clone the current geometry into a new geometry
  85693. * @param id defines the unique ID of the new geometry
  85694. * @returns a new geometry object
  85695. */
  85696. copy(id: string): Geometry;
  85697. /**
  85698. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85699. * @return a JSON representation of the current geometry data (without the vertices data)
  85700. */
  85701. serialize(): any;
  85702. private toNumberArray;
  85703. /**
  85704. * Serialize all vertices data into a JSON oject
  85705. * @returns a JSON representation of the current geometry data
  85706. */
  85707. serializeVerticeData(): any;
  85708. /**
  85709. * Extracts a clone of a mesh geometry
  85710. * @param mesh defines the source mesh
  85711. * @param id defines the unique ID of the new geometry object
  85712. * @returns the new geometry object
  85713. */
  85714. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85715. /**
  85716. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85717. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85718. * Be aware Math.random() could cause collisions, but:
  85719. * "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"
  85720. * @returns a string containing a new GUID
  85721. */
  85722. static RandomId(): string;
  85723. /** @hidden */
  85724. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85725. private static _CleanMatricesWeights;
  85726. /**
  85727. * Create a new geometry from persisted data (Using .babylon file format)
  85728. * @param parsedVertexData defines the persisted data
  85729. * @param scene defines the hosting scene
  85730. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85731. * @returns the new geometry object
  85732. */
  85733. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85734. }
  85735. }
  85736. declare module BABYLON {
  85737. /**
  85738. * Define an interface for all classes that will get and set the data on vertices
  85739. */
  85740. export interface IGetSetVerticesData {
  85741. /**
  85742. * Gets a boolean indicating if specific vertex data is present
  85743. * @param kind defines the vertex data kind to use
  85744. * @returns true is data kind is present
  85745. */
  85746. isVerticesDataPresent(kind: string): boolean;
  85747. /**
  85748. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85749. * @param kind defines the data kind (Position, normal, etc...)
  85750. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85751. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85752. * @returns a float array containing vertex data
  85753. */
  85754. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85755. /**
  85756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85757. * @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.
  85758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85759. * @returns the indices array or an empty array if the mesh has no geometry
  85760. */
  85761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85762. /**
  85763. * Set specific vertex data
  85764. * @param kind defines the data kind (Position, normal, etc...)
  85765. * @param data defines the vertex data to use
  85766. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85767. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85768. */
  85769. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85770. /**
  85771. * Update a specific associated vertex buffer
  85772. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85773. * - VertexBuffer.PositionKind
  85774. * - VertexBuffer.UVKind
  85775. * - VertexBuffer.UV2Kind
  85776. * - VertexBuffer.UV3Kind
  85777. * - VertexBuffer.UV4Kind
  85778. * - VertexBuffer.UV5Kind
  85779. * - VertexBuffer.UV6Kind
  85780. * - VertexBuffer.ColorKind
  85781. * - VertexBuffer.MatricesIndicesKind
  85782. * - VertexBuffer.MatricesIndicesExtraKind
  85783. * - VertexBuffer.MatricesWeightsKind
  85784. * - VertexBuffer.MatricesWeightsExtraKind
  85785. * @param data defines the data source
  85786. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85787. * @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)
  85788. */
  85789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85790. /**
  85791. * Creates a new index buffer
  85792. * @param indices defines the indices to store in the index buffer
  85793. * @param totalVertices defines the total number of vertices (could be null)
  85794. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85795. */
  85796. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85797. }
  85798. /**
  85799. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85800. */
  85801. export class VertexData {
  85802. /**
  85803. * Mesh side orientation : usually the external or front surface
  85804. */
  85805. static readonly FRONTSIDE: number;
  85806. /**
  85807. * Mesh side orientation : usually the internal or back surface
  85808. */
  85809. static readonly BACKSIDE: number;
  85810. /**
  85811. * Mesh side orientation : both internal and external or front and back surfaces
  85812. */
  85813. static readonly DOUBLESIDE: number;
  85814. /**
  85815. * Mesh side orientation : by default, `FRONTSIDE`
  85816. */
  85817. static readonly DEFAULTSIDE: number;
  85818. /**
  85819. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85820. */
  85821. positions: Nullable<FloatArray>;
  85822. /**
  85823. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85824. */
  85825. normals: Nullable<FloatArray>;
  85826. /**
  85827. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85828. */
  85829. tangents: Nullable<FloatArray>;
  85830. /**
  85831. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85832. */
  85833. uvs: Nullable<FloatArray>;
  85834. /**
  85835. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85836. */
  85837. uvs2: Nullable<FloatArray>;
  85838. /**
  85839. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85840. */
  85841. uvs3: Nullable<FloatArray>;
  85842. /**
  85843. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85844. */
  85845. uvs4: Nullable<FloatArray>;
  85846. /**
  85847. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85848. */
  85849. uvs5: Nullable<FloatArray>;
  85850. /**
  85851. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85852. */
  85853. uvs6: Nullable<FloatArray>;
  85854. /**
  85855. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85856. */
  85857. colors: Nullable<FloatArray>;
  85858. /**
  85859. * 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).
  85860. */
  85861. matricesIndices: Nullable<FloatArray>;
  85862. /**
  85863. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85864. */
  85865. matricesWeights: Nullable<FloatArray>;
  85866. /**
  85867. * An array extending the number of possible indices
  85868. */
  85869. matricesIndicesExtra: Nullable<FloatArray>;
  85870. /**
  85871. * An array extending the number of possible weights when the number of indices is extended
  85872. */
  85873. matricesWeightsExtra: Nullable<FloatArray>;
  85874. /**
  85875. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85876. */
  85877. indices: Nullable<IndicesArray>;
  85878. /**
  85879. * Uses the passed data array to set the set the values for the specified kind of data
  85880. * @param data a linear array of floating numbers
  85881. * @param kind the type of data that is being set, eg positions, colors etc
  85882. */
  85883. set(data: FloatArray, kind: string): void;
  85884. /**
  85885. * Associates the vertexData to the passed Mesh.
  85886. * Sets it as updatable or not (default `false`)
  85887. * @param mesh the mesh the vertexData is applied to
  85888. * @param updatable when used and having the value true allows new data to update the vertexData
  85889. * @returns the VertexData
  85890. */
  85891. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85892. /**
  85893. * Associates the vertexData to the passed Geometry.
  85894. * Sets it as updatable or not (default `false`)
  85895. * @param geometry the geometry the vertexData is applied to
  85896. * @param updatable when used and having the value true allows new data to update the vertexData
  85897. * @returns VertexData
  85898. */
  85899. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85900. /**
  85901. * Updates the associated mesh
  85902. * @param mesh the mesh to be updated
  85903. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85904. * @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
  85905. * @returns VertexData
  85906. */
  85907. updateMesh(mesh: Mesh): VertexData;
  85908. /**
  85909. * Updates the associated geometry
  85910. * @param geometry the geometry to be updated
  85911. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85912. * @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
  85913. * @returns VertexData.
  85914. */
  85915. updateGeometry(geometry: Geometry): VertexData;
  85916. private _applyTo;
  85917. private _update;
  85918. /**
  85919. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85920. * @param matrix the transforming matrix
  85921. * @returns the VertexData
  85922. */
  85923. transform(matrix: Matrix): VertexData;
  85924. /**
  85925. * Merges the passed VertexData into the current one
  85926. * @param other the VertexData to be merged into the current one
  85927. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85928. * @returns the modified VertexData
  85929. */
  85930. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85931. private _mergeElement;
  85932. private _validate;
  85933. /**
  85934. * Serializes the VertexData
  85935. * @returns a serialized object
  85936. */
  85937. serialize(): any;
  85938. /**
  85939. * Extracts the vertexData from a mesh
  85940. * @param mesh the mesh from which to extract the VertexData
  85941. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85942. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85943. * @returns the object VertexData associated to the passed mesh
  85944. */
  85945. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85946. /**
  85947. * Extracts the vertexData from the geometry
  85948. * @param geometry the geometry from which to extract the VertexData
  85949. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85951. * @returns the object VertexData associated to the passed mesh
  85952. */
  85953. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85954. private static _ExtractFrom;
  85955. /**
  85956. * Creates the VertexData for a Ribbon
  85957. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85958. * * pathArray array of paths, each of which an array of successive Vector3
  85959. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85960. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85961. * * 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
  85962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85963. * * 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)
  85964. * * 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)
  85965. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85966. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85967. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85968. * @returns the VertexData of the ribbon
  85969. */
  85970. static CreateRibbon(options: {
  85971. pathArray: Vector3[][];
  85972. closeArray?: boolean;
  85973. closePath?: boolean;
  85974. offset?: number;
  85975. sideOrientation?: number;
  85976. frontUVs?: Vector4;
  85977. backUVs?: Vector4;
  85978. invertUV?: boolean;
  85979. uvs?: Vector2[];
  85980. colors?: Color4[];
  85981. }): VertexData;
  85982. /**
  85983. * Creates the VertexData for a box
  85984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85985. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85986. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85987. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85988. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85989. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85990. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85992. * * 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)
  85993. * * 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)
  85994. * @returns the VertexData of the box
  85995. */
  85996. static CreateBox(options: {
  85997. size?: number;
  85998. width?: number;
  85999. height?: number;
  86000. depth?: number;
  86001. faceUV?: Vector4[];
  86002. faceColors?: Color4[];
  86003. sideOrientation?: number;
  86004. frontUVs?: Vector4;
  86005. backUVs?: Vector4;
  86006. }): VertexData;
  86007. /**
  86008. * Creates the VertexData for a tiled box
  86009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86010. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86011. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86012. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86014. * @returns the VertexData of the box
  86015. */
  86016. static CreateTiledBox(options: {
  86017. pattern?: number;
  86018. width?: number;
  86019. height?: number;
  86020. depth?: number;
  86021. tileSize?: number;
  86022. tileWidth?: number;
  86023. tileHeight?: number;
  86024. alignHorizontal?: number;
  86025. alignVertical?: number;
  86026. faceUV?: Vector4[];
  86027. faceColors?: Color4[];
  86028. sideOrientation?: number;
  86029. }): VertexData;
  86030. /**
  86031. * Creates the VertexData for a tiled plane
  86032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86033. * * pattern a limited pattern arrangement depending on the number
  86034. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86035. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86036. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86038. * * 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)
  86039. * * 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)
  86040. * @returns the VertexData of the tiled plane
  86041. */
  86042. static CreateTiledPlane(options: {
  86043. pattern?: number;
  86044. tileSize?: number;
  86045. tileWidth?: number;
  86046. tileHeight?: number;
  86047. size?: number;
  86048. width?: number;
  86049. height?: number;
  86050. alignHorizontal?: number;
  86051. alignVertical?: number;
  86052. sideOrientation?: number;
  86053. frontUVs?: Vector4;
  86054. backUVs?: Vector4;
  86055. }): VertexData;
  86056. /**
  86057. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86059. * * segments sets the number of horizontal strips optional, default 32
  86060. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86061. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86062. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86063. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86064. * * 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
  86065. * * 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
  86066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86067. * * 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)
  86068. * * 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)
  86069. * @returns the VertexData of the ellipsoid
  86070. */
  86071. static CreateSphere(options: {
  86072. segments?: number;
  86073. diameter?: number;
  86074. diameterX?: number;
  86075. diameterY?: number;
  86076. diameterZ?: number;
  86077. arc?: number;
  86078. slice?: number;
  86079. sideOrientation?: number;
  86080. frontUVs?: Vector4;
  86081. backUVs?: Vector4;
  86082. }): VertexData;
  86083. /**
  86084. * Creates the VertexData for a cylinder, cone or prism
  86085. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86086. * * height sets the height (y direction) of the cylinder, optional, default 2
  86087. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86088. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86089. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86090. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86091. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86092. * * 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
  86093. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86094. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86095. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86096. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86098. * * 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)
  86099. * * 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)
  86100. * @returns the VertexData of the cylinder, cone or prism
  86101. */
  86102. static CreateCylinder(options: {
  86103. height?: number;
  86104. diameterTop?: number;
  86105. diameterBottom?: number;
  86106. diameter?: number;
  86107. tessellation?: number;
  86108. subdivisions?: number;
  86109. arc?: number;
  86110. faceColors?: Color4[];
  86111. faceUV?: Vector4[];
  86112. hasRings?: boolean;
  86113. enclose?: boolean;
  86114. sideOrientation?: number;
  86115. frontUVs?: Vector4;
  86116. backUVs?: Vector4;
  86117. }): VertexData;
  86118. /**
  86119. * Creates the VertexData for a torus
  86120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86121. * * diameter the diameter of the torus, optional default 1
  86122. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86123. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86125. * * 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)
  86126. * * 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)
  86127. * @returns the VertexData of the torus
  86128. */
  86129. static CreateTorus(options: {
  86130. diameter?: number;
  86131. thickness?: number;
  86132. tessellation?: number;
  86133. sideOrientation?: number;
  86134. frontUVs?: Vector4;
  86135. backUVs?: Vector4;
  86136. }): VertexData;
  86137. /**
  86138. * Creates the VertexData of the LineSystem
  86139. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86140. * - lines an array of lines, each line being an array of successive Vector3
  86141. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86142. * @returns the VertexData of the LineSystem
  86143. */
  86144. static CreateLineSystem(options: {
  86145. lines: Vector3[][];
  86146. colors?: Nullable<Color4[][]>;
  86147. }): VertexData;
  86148. /**
  86149. * Create the VertexData for a DashedLines
  86150. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86151. * - points an array successive Vector3
  86152. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86153. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86154. * - dashNb the intended total number of dashes, optional, default 200
  86155. * @returns the VertexData for the DashedLines
  86156. */
  86157. static CreateDashedLines(options: {
  86158. points: Vector3[];
  86159. dashSize?: number;
  86160. gapSize?: number;
  86161. dashNb?: number;
  86162. }): VertexData;
  86163. /**
  86164. * Creates the VertexData for a Ground
  86165. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86166. * - width the width (x direction) of the ground, optional, default 1
  86167. * - height the height (z direction) of the ground, optional, default 1
  86168. * - subdivisions the number of subdivisions per side, optional, default 1
  86169. * @returns the VertexData of the Ground
  86170. */
  86171. static CreateGround(options: {
  86172. width?: number;
  86173. height?: number;
  86174. subdivisions?: number;
  86175. subdivisionsX?: number;
  86176. subdivisionsY?: number;
  86177. }): VertexData;
  86178. /**
  86179. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86180. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86181. * * xmin the ground minimum X coordinate, optional, default -1
  86182. * * zmin the ground minimum Z coordinate, optional, default -1
  86183. * * xmax the ground maximum X coordinate, optional, default 1
  86184. * * zmax the ground maximum Z coordinate, optional, default 1
  86185. * * 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}
  86186. * * 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}
  86187. * @returns the VertexData of the TiledGround
  86188. */
  86189. static CreateTiledGround(options: {
  86190. xmin: number;
  86191. zmin: number;
  86192. xmax: number;
  86193. zmax: number;
  86194. subdivisions?: {
  86195. w: number;
  86196. h: number;
  86197. };
  86198. precision?: {
  86199. w: number;
  86200. h: number;
  86201. };
  86202. }): VertexData;
  86203. /**
  86204. * Creates the VertexData of the Ground designed from a heightmap
  86205. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86206. * * width the width (x direction) of the ground
  86207. * * height the height (z direction) of the ground
  86208. * * subdivisions the number of subdivisions per side
  86209. * * minHeight the minimum altitude on the ground, optional, default 0
  86210. * * maxHeight the maximum altitude on the ground, optional default 1
  86211. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86212. * * buffer the array holding the image color data
  86213. * * bufferWidth the width of image
  86214. * * bufferHeight the height of image
  86215. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86216. * @returns the VertexData of the Ground designed from a heightmap
  86217. */
  86218. static CreateGroundFromHeightMap(options: {
  86219. width: number;
  86220. height: number;
  86221. subdivisions: number;
  86222. minHeight: number;
  86223. maxHeight: number;
  86224. colorFilter: Color3;
  86225. buffer: Uint8Array;
  86226. bufferWidth: number;
  86227. bufferHeight: number;
  86228. alphaFilter: number;
  86229. }): VertexData;
  86230. /**
  86231. * Creates the VertexData for a Plane
  86232. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86233. * * size sets the width and height of the plane to the value of size, optional default 1
  86234. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86235. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86237. * * 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)
  86238. * * 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)
  86239. * @returns the VertexData of the box
  86240. */
  86241. static CreatePlane(options: {
  86242. size?: number;
  86243. width?: number;
  86244. height?: number;
  86245. sideOrientation?: number;
  86246. frontUVs?: Vector4;
  86247. backUVs?: Vector4;
  86248. }): VertexData;
  86249. /**
  86250. * Creates the VertexData of the Disc or regular Polygon
  86251. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86252. * * radius the radius of the disc, optional default 0.5
  86253. * * tessellation the number of polygon sides, optional, default 64
  86254. * * 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
  86255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86256. * * 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)
  86257. * * 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)
  86258. * @returns the VertexData of the box
  86259. */
  86260. static CreateDisc(options: {
  86261. radius?: number;
  86262. tessellation?: number;
  86263. arc?: number;
  86264. sideOrientation?: number;
  86265. frontUVs?: Vector4;
  86266. backUVs?: Vector4;
  86267. }): VertexData;
  86268. /**
  86269. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86270. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86271. * @param polygon a mesh built from polygonTriangulation.build()
  86272. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86273. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86274. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86275. * @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)
  86276. * @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)
  86277. * @returns the VertexData of the Polygon
  86278. */
  86279. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86280. /**
  86281. * Creates the VertexData of the IcoSphere
  86282. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86283. * * radius the radius of the IcoSphere, optional default 1
  86284. * * radiusX allows stretching in the x direction, optional, default radius
  86285. * * radiusY allows stretching in the y direction, optional, default radius
  86286. * * radiusZ allows stretching in the z direction, optional, default radius
  86287. * * flat when true creates a flat shaded mesh, optional, default true
  86288. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86290. * * 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)
  86291. * * 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)
  86292. * @returns the VertexData of the IcoSphere
  86293. */
  86294. static CreateIcoSphere(options: {
  86295. radius?: number;
  86296. radiusX?: number;
  86297. radiusY?: number;
  86298. radiusZ?: number;
  86299. flat?: boolean;
  86300. subdivisions?: number;
  86301. sideOrientation?: number;
  86302. frontUVs?: Vector4;
  86303. backUVs?: Vector4;
  86304. }): VertexData;
  86305. /**
  86306. * Creates the VertexData for a Polyhedron
  86307. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86308. * * type provided types are:
  86309. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86310. * * 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)
  86311. * * size the size of the IcoSphere, optional default 1
  86312. * * sizeX allows stretching in the x direction, optional, default size
  86313. * * sizeY allows stretching in the y direction, optional, default size
  86314. * * sizeZ allows stretching in the z direction, optional, default size
  86315. * * 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
  86316. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86318. * * flat when true creates a flat shaded mesh, optional, default true
  86319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86321. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  86322. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  86323. * @returns the VertexData of the Polyhedron
  86324. */
  86325. static CreatePolyhedron(options: {
  86326. type?: number;
  86327. size?: number;
  86328. sizeX?: number;
  86329. sizeY?: number;
  86330. sizeZ?: number;
  86331. custom?: any;
  86332. faceUV?: Vector4[];
  86333. faceColors?: Color4[];
  86334. flat?: boolean;
  86335. sideOrientation?: number;
  86336. frontUVs?: Vector4;
  86337. backUVs?: Vector4;
  86338. }): VertexData;
  86339. /**
  86340. * Creates the VertexData for a TorusKnot
  86341. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86342. * * radius the radius of the torus knot, optional, default 2
  86343. * * tube the thickness of the tube, optional, default 0.5
  86344. * * radialSegments the number of sides on each tube segments, optional, default 32
  86345. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86346. * * p the number of windings around the z axis, optional, default 2
  86347. * * q the number of windings around the x axis, optional, default 3
  86348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86349. * * 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)
  86350. * * 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)
  86351. * @returns the VertexData of the Torus Knot
  86352. */
  86353. static CreateTorusKnot(options: {
  86354. radius?: number;
  86355. tube?: number;
  86356. radialSegments?: number;
  86357. tubularSegments?: number;
  86358. p?: number;
  86359. q?: number;
  86360. sideOrientation?: number;
  86361. frontUVs?: Vector4;
  86362. backUVs?: Vector4;
  86363. }): VertexData;
  86364. /**
  86365. * Compute normals for given positions and indices
  86366. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86367. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86368. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86369. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86370. * * facetNormals : optional array of facet normals (vector3)
  86371. * * facetPositions : optional array of facet positions (vector3)
  86372. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86373. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86374. * * bInfo : optional bounding info, required for facetPartitioning computation
  86375. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86376. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86377. * * useRightHandedSystem: optional boolean to for right handed system computation
  86378. * * depthSort : optional boolean to enable the facet depth sort computation
  86379. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86380. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86381. */
  86382. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86383. facetNormals?: any;
  86384. facetPositions?: any;
  86385. facetPartitioning?: any;
  86386. ratio?: number;
  86387. bInfo?: any;
  86388. bbSize?: Vector3;
  86389. subDiv?: any;
  86390. useRightHandedSystem?: boolean;
  86391. depthSort?: boolean;
  86392. distanceTo?: Vector3;
  86393. depthSortedFacets?: any;
  86394. }): void;
  86395. /** @hidden */
  86396. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86397. /**
  86398. * Applies VertexData created from the imported parameters to the geometry
  86399. * @param parsedVertexData the parsed data from an imported file
  86400. * @param geometry the geometry to apply the VertexData to
  86401. */
  86402. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86403. }
  86404. }
  86405. declare module BABYLON {
  86406. /**
  86407. * Defines a target to use with MorphTargetManager
  86408. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86409. */
  86410. export class MorphTarget implements IAnimatable {
  86411. /** defines the name of the target */
  86412. name: string;
  86413. /**
  86414. * Gets or sets the list of animations
  86415. */
  86416. animations: Animation[];
  86417. private _scene;
  86418. private _positions;
  86419. private _normals;
  86420. private _tangents;
  86421. private _uvs;
  86422. private _influence;
  86423. /**
  86424. * Observable raised when the influence changes
  86425. */
  86426. onInfluenceChanged: Observable<boolean>;
  86427. /** @hidden */
  86428. _onDataLayoutChanged: Observable<void>;
  86429. /**
  86430. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86431. */
  86432. influence: number;
  86433. /**
  86434. * Gets or sets the id of the morph Target
  86435. */
  86436. id: string;
  86437. private _animationPropertiesOverride;
  86438. /**
  86439. * Gets or sets the animation properties override
  86440. */
  86441. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86442. /**
  86443. * Creates a new MorphTarget
  86444. * @param name defines the name of the target
  86445. * @param influence defines the influence to use
  86446. * @param scene defines the scene the morphtarget belongs to
  86447. */
  86448. constructor(
  86449. /** defines the name of the target */
  86450. name: string, influence?: number, scene?: Nullable<Scene>);
  86451. /**
  86452. * Gets a boolean defining if the target contains position data
  86453. */
  86454. readonly hasPositions: boolean;
  86455. /**
  86456. * Gets a boolean defining if the target contains normal data
  86457. */
  86458. readonly hasNormals: boolean;
  86459. /**
  86460. * Gets a boolean defining if the target contains tangent data
  86461. */
  86462. readonly hasTangents: boolean;
  86463. /**
  86464. * Gets a boolean defining if the target contains texture coordinates data
  86465. */
  86466. readonly hasUVs: boolean;
  86467. /**
  86468. * Affects position data to this target
  86469. * @param data defines the position data to use
  86470. */
  86471. setPositions(data: Nullable<FloatArray>): void;
  86472. /**
  86473. * Gets the position data stored in this target
  86474. * @returns a FloatArray containing the position data (or null if not present)
  86475. */
  86476. getPositions(): Nullable<FloatArray>;
  86477. /**
  86478. * Affects normal data to this target
  86479. * @param data defines the normal data to use
  86480. */
  86481. setNormals(data: Nullable<FloatArray>): void;
  86482. /**
  86483. * Gets the normal data stored in this target
  86484. * @returns a FloatArray containing the normal data (or null if not present)
  86485. */
  86486. getNormals(): Nullable<FloatArray>;
  86487. /**
  86488. * Affects tangent data to this target
  86489. * @param data defines the tangent data to use
  86490. */
  86491. setTangents(data: Nullable<FloatArray>): void;
  86492. /**
  86493. * Gets the tangent data stored in this target
  86494. * @returns a FloatArray containing the tangent data (or null if not present)
  86495. */
  86496. getTangents(): Nullable<FloatArray>;
  86497. /**
  86498. * Affects texture coordinates data to this target
  86499. * @param data defines the texture coordinates data to use
  86500. */
  86501. setUVs(data: Nullable<FloatArray>): void;
  86502. /**
  86503. * Gets the texture coordinates data stored in this target
  86504. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86505. */
  86506. getUVs(): Nullable<FloatArray>;
  86507. /**
  86508. * Serializes the current target into a Serialization object
  86509. * @returns the serialized object
  86510. */
  86511. serialize(): any;
  86512. /**
  86513. * Returns the string "MorphTarget"
  86514. * @returns "MorphTarget"
  86515. */
  86516. getClassName(): string;
  86517. /**
  86518. * Creates a new target from serialized data
  86519. * @param serializationObject defines the serialized data to use
  86520. * @returns a new MorphTarget
  86521. */
  86522. static Parse(serializationObject: any): MorphTarget;
  86523. /**
  86524. * Creates a MorphTarget from mesh data
  86525. * @param mesh defines the source mesh
  86526. * @param name defines the name to use for the new target
  86527. * @param influence defines the influence to attach to the target
  86528. * @returns a new MorphTarget
  86529. */
  86530. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86531. }
  86532. }
  86533. declare module BABYLON {
  86534. /**
  86535. * This class is used to deform meshes using morphing between different targets
  86536. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86537. */
  86538. export class MorphTargetManager {
  86539. private _targets;
  86540. private _targetInfluenceChangedObservers;
  86541. private _targetDataLayoutChangedObservers;
  86542. private _activeTargets;
  86543. private _scene;
  86544. private _influences;
  86545. private _supportsNormals;
  86546. private _supportsTangents;
  86547. private _supportsUVs;
  86548. private _vertexCount;
  86549. private _uniqueId;
  86550. private _tempInfluences;
  86551. /**
  86552. * Gets or sets a boolean indicating if normals must be morphed
  86553. */
  86554. enableNormalMorphing: boolean;
  86555. /**
  86556. * Gets or sets a boolean indicating if tangents must be morphed
  86557. */
  86558. enableTangentMorphing: boolean;
  86559. /**
  86560. * Gets or sets a boolean indicating if UV must be morphed
  86561. */
  86562. enableUVMorphing: boolean;
  86563. /**
  86564. * Creates a new MorphTargetManager
  86565. * @param scene defines the current scene
  86566. */
  86567. constructor(scene?: Nullable<Scene>);
  86568. /**
  86569. * Gets the unique ID of this manager
  86570. */
  86571. readonly uniqueId: number;
  86572. /**
  86573. * Gets the number of vertices handled by this manager
  86574. */
  86575. readonly vertexCount: number;
  86576. /**
  86577. * Gets a boolean indicating if this manager supports morphing of normals
  86578. */
  86579. readonly supportsNormals: boolean;
  86580. /**
  86581. * Gets a boolean indicating if this manager supports morphing of tangents
  86582. */
  86583. readonly supportsTangents: boolean;
  86584. /**
  86585. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86586. */
  86587. readonly supportsUVs: boolean;
  86588. /**
  86589. * Gets the number of targets stored in this manager
  86590. */
  86591. readonly numTargets: number;
  86592. /**
  86593. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86594. */
  86595. readonly numInfluencers: number;
  86596. /**
  86597. * Gets the list of influences (one per target)
  86598. */
  86599. readonly influences: Float32Array;
  86600. /**
  86601. * Gets the active target at specified index. An active target is a target with an influence > 0
  86602. * @param index defines the index to check
  86603. * @returns the requested target
  86604. */
  86605. getActiveTarget(index: number): MorphTarget;
  86606. /**
  86607. * Gets the target at specified index
  86608. * @param index defines the index to check
  86609. * @returns the requested target
  86610. */
  86611. getTarget(index: number): MorphTarget;
  86612. /**
  86613. * Add a new target to this manager
  86614. * @param target defines the target to add
  86615. */
  86616. addTarget(target: MorphTarget): void;
  86617. /**
  86618. * Removes a target from the manager
  86619. * @param target defines the target to remove
  86620. */
  86621. removeTarget(target: MorphTarget): void;
  86622. /**
  86623. * Serializes the current manager into a Serialization object
  86624. * @returns the serialized object
  86625. */
  86626. serialize(): any;
  86627. private _syncActiveTargets;
  86628. /**
  86629. * Syncrhonize the targets with all the meshes using this morph target manager
  86630. */
  86631. synchronize(): void;
  86632. /**
  86633. * Creates a new MorphTargetManager from serialized data
  86634. * @param serializationObject defines the serialized data
  86635. * @param scene defines the hosting scene
  86636. * @returns the new MorphTargetManager
  86637. */
  86638. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86639. }
  86640. }
  86641. declare module BABYLON {
  86642. /**
  86643. * Class used to represent a specific level of detail of a mesh
  86644. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86645. */
  86646. export class MeshLODLevel {
  86647. /** Defines the distance where this level should star being displayed */
  86648. distance: number;
  86649. /** Defines the mesh to use to render this level */
  86650. mesh: Nullable<Mesh>;
  86651. /**
  86652. * Creates a new LOD level
  86653. * @param distance defines the distance where this level should star being displayed
  86654. * @param mesh defines the mesh to use to render this level
  86655. */
  86656. constructor(
  86657. /** Defines the distance where this level should star being displayed */
  86658. distance: number,
  86659. /** Defines the mesh to use to render this level */
  86660. mesh: Nullable<Mesh>);
  86661. }
  86662. }
  86663. declare module BABYLON {
  86664. /**
  86665. * Mesh representing the gorund
  86666. */
  86667. export class GroundMesh extends Mesh {
  86668. /** If octree should be generated */
  86669. generateOctree: boolean;
  86670. private _heightQuads;
  86671. /** @hidden */
  86672. _subdivisionsX: number;
  86673. /** @hidden */
  86674. _subdivisionsY: number;
  86675. /** @hidden */
  86676. _width: number;
  86677. /** @hidden */
  86678. _height: number;
  86679. /** @hidden */
  86680. _minX: number;
  86681. /** @hidden */
  86682. _maxX: number;
  86683. /** @hidden */
  86684. _minZ: number;
  86685. /** @hidden */
  86686. _maxZ: number;
  86687. constructor(name: string, scene: Scene);
  86688. /**
  86689. * "GroundMesh"
  86690. * @returns "GroundMesh"
  86691. */
  86692. getClassName(): string;
  86693. /**
  86694. * The minimum of x and y subdivisions
  86695. */
  86696. readonly subdivisions: number;
  86697. /**
  86698. * X subdivisions
  86699. */
  86700. readonly subdivisionsX: number;
  86701. /**
  86702. * Y subdivisions
  86703. */
  86704. readonly subdivisionsY: number;
  86705. /**
  86706. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86707. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86708. * @param chunksCount the number of subdivisions for x and y
  86709. * @param octreeBlocksSize (Default: 32)
  86710. */
  86711. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86712. /**
  86713. * Returns a height (y) value in the Worl system :
  86714. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86715. * @param x x coordinate
  86716. * @param z z coordinate
  86717. * @returns the ground y position if (x, z) are outside the ground surface.
  86718. */
  86719. getHeightAtCoordinates(x: number, z: number): number;
  86720. /**
  86721. * Returns a normalized vector (Vector3) orthogonal to the ground
  86722. * at the ground coordinates (x, z) expressed in the World system.
  86723. * @param x x coordinate
  86724. * @param z z coordinate
  86725. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86726. */
  86727. getNormalAtCoordinates(x: number, z: number): Vector3;
  86728. /**
  86729. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86730. * at the ground coordinates (x, z) expressed in the World system.
  86731. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86732. * @param x x coordinate
  86733. * @param z z coordinate
  86734. * @param ref vector to store the result
  86735. * @returns the GroundMesh.
  86736. */
  86737. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86738. /**
  86739. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86740. * if the ground has been updated.
  86741. * This can be used in the render loop.
  86742. * @returns the GroundMesh.
  86743. */
  86744. updateCoordinateHeights(): GroundMesh;
  86745. private _getFacetAt;
  86746. private _initHeightQuads;
  86747. private _computeHeightQuads;
  86748. /**
  86749. * Serializes this ground mesh
  86750. * @param serializationObject object to write serialization to
  86751. */
  86752. serialize(serializationObject: any): void;
  86753. /**
  86754. * Parses a serialized ground mesh
  86755. * @param parsedMesh the serialized mesh
  86756. * @param scene the scene to create the ground mesh in
  86757. * @returns the created ground mesh
  86758. */
  86759. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86760. }
  86761. }
  86762. declare module BABYLON {
  86763. /**
  86764. * Interface for Physics-Joint data
  86765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86766. */
  86767. export interface PhysicsJointData {
  86768. /**
  86769. * The main pivot of the joint
  86770. */
  86771. mainPivot?: Vector3;
  86772. /**
  86773. * The connected pivot of the joint
  86774. */
  86775. connectedPivot?: Vector3;
  86776. /**
  86777. * The main axis of the joint
  86778. */
  86779. mainAxis?: Vector3;
  86780. /**
  86781. * The connected axis of the joint
  86782. */
  86783. connectedAxis?: Vector3;
  86784. /**
  86785. * The collision of the joint
  86786. */
  86787. collision?: boolean;
  86788. /**
  86789. * Native Oimo/Cannon/Energy data
  86790. */
  86791. nativeParams?: any;
  86792. }
  86793. /**
  86794. * This is a holder class for the physics joint created by the physics plugin
  86795. * It holds a set of functions to control the underlying joint
  86796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86797. */
  86798. export class PhysicsJoint {
  86799. /**
  86800. * The type of the physics joint
  86801. */
  86802. type: number;
  86803. /**
  86804. * The data for the physics joint
  86805. */
  86806. jointData: PhysicsJointData;
  86807. private _physicsJoint;
  86808. protected _physicsPlugin: IPhysicsEnginePlugin;
  86809. /**
  86810. * Initializes the physics joint
  86811. * @param type The type of the physics joint
  86812. * @param jointData The data for the physics joint
  86813. */
  86814. constructor(
  86815. /**
  86816. * The type of the physics joint
  86817. */
  86818. type: number,
  86819. /**
  86820. * The data for the physics joint
  86821. */
  86822. jointData: PhysicsJointData);
  86823. /**
  86824. * Gets the physics joint
  86825. */
  86826. /**
  86827. * Sets the physics joint
  86828. */
  86829. physicsJoint: any;
  86830. /**
  86831. * Sets the physics plugin
  86832. */
  86833. physicsPlugin: IPhysicsEnginePlugin;
  86834. /**
  86835. * Execute a function that is physics-plugin specific.
  86836. * @param {Function} func the function that will be executed.
  86837. * It accepts two parameters: the physics world and the physics joint
  86838. */
  86839. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86840. /**
  86841. * Distance-Joint type
  86842. */
  86843. static DistanceJoint: number;
  86844. /**
  86845. * Hinge-Joint type
  86846. */
  86847. static HingeJoint: number;
  86848. /**
  86849. * Ball-and-Socket joint type
  86850. */
  86851. static BallAndSocketJoint: number;
  86852. /**
  86853. * Wheel-Joint type
  86854. */
  86855. static WheelJoint: number;
  86856. /**
  86857. * Slider-Joint type
  86858. */
  86859. static SliderJoint: number;
  86860. /**
  86861. * Prismatic-Joint type
  86862. */
  86863. static PrismaticJoint: number;
  86864. /**
  86865. * Universal-Joint type
  86866. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86867. */
  86868. static UniversalJoint: number;
  86869. /**
  86870. * Hinge-Joint 2 type
  86871. */
  86872. static Hinge2Joint: number;
  86873. /**
  86874. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86875. */
  86876. static PointToPointJoint: number;
  86877. /**
  86878. * Spring-Joint type
  86879. */
  86880. static SpringJoint: number;
  86881. /**
  86882. * Lock-Joint type
  86883. */
  86884. static LockJoint: number;
  86885. }
  86886. /**
  86887. * A class representing a physics distance joint
  86888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86889. */
  86890. export class DistanceJoint extends PhysicsJoint {
  86891. /**
  86892. *
  86893. * @param jointData The data for the Distance-Joint
  86894. */
  86895. constructor(jointData: DistanceJointData);
  86896. /**
  86897. * Update the predefined distance.
  86898. * @param maxDistance The maximum preferred distance
  86899. * @param minDistance The minimum preferred distance
  86900. */
  86901. updateDistance(maxDistance: number, minDistance?: number): void;
  86902. }
  86903. /**
  86904. * Represents a Motor-Enabled Joint
  86905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86906. */
  86907. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86908. /**
  86909. * Initializes the Motor-Enabled Joint
  86910. * @param type The type of the joint
  86911. * @param jointData The physica joint data for the joint
  86912. */
  86913. constructor(type: number, jointData: PhysicsJointData);
  86914. /**
  86915. * Set the motor values.
  86916. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86917. * @param force the force to apply
  86918. * @param maxForce max force for this motor.
  86919. */
  86920. setMotor(force?: number, maxForce?: number): void;
  86921. /**
  86922. * Set the motor's limits.
  86923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86924. * @param upperLimit The upper limit of the motor
  86925. * @param lowerLimit The lower limit of the motor
  86926. */
  86927. setLimit(upperLimit: number, lowerLimit?: number): void;
  86928. }
  86929. /**
  86930. * This class represents a single physics Hinge-Joint
  86931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86932. */
  86933. export class HingeJoint extends MotorEnabledJoint {
  86934. /**
  86935. * Initializes the Hinge-Joint
  86936. * @param jointData The joint data for the Hinge-Joint
  86937. */
  86938. constructor(jointData: PhysicsJointData);
  86939. /**
  86940. * Set the motor values.
  86941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86942. * @param {number} force the force to apply
  86943. * @param {number} maxForce max force for this motor.
  86944. */
  86945. setMotor(force?: number, maxForce?: number): void;
  86946. /**
  86947. * Set the motor's limits.
  86948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86949. * @param upperLimit The upper limit of the motor
  86950. * @param lowerLimit The lower limit of the motor
  86951. */
  86952. setLimit(upperLimit: number, lowerLimit?: number): void;
  86953. }
  86954. /**
  86955. * This class represents a dual hinge physics joint (same as wheel joint)
  86956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86957. */
  86958. export class Hinge2Joint extends MotorEnabledJoint {
  86959. /**
  86960. * Initializes the Hinge2-Joint
  86961. * @param jointData The joint data for the Hinge2-Joint
  86962. */
  86963. constructor(jointData: PhysicsJointData);
  86964. /**
  86965. * Set the motor values.
  86966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86967. * @param {number} targetSpeed the speed the motor is to reach
  86968. * @param {number} maxForce max force for this motor.
  86969. * @param {motorIndex} the motor's index, 0 or 1.
  86970. */
  86971. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86972. /**
  86973. * Set the motor limits.
  86974. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86975. * @param {number} upperLimit the upper limit
  86976. * @param {number} lowerLimit lower limit
  86977. * @param {motorIndex} the motor's index, 0 or 1.
  86978. */
  86979. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86980. }
  86981. /**
  86982. * Interface for a motor enabled joint
  86983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86984. */
  86985. export interface IMotorEnabledJoint {
  86986. /**
  86987. * Physics joint
  86988. */
  86989. physicsJoint: any;
  86990. /**
  86991. * Sets the motor of the motor-enabled joint
  86992. * @param force The force of the motor
  86993. * @param maxForce The maximum force of the motor
  86994. * @param motorIndex The index of the motor
  86995. */
  86996. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86997. /**
  86998. * Sets the limit of the motor
  86999. * @param upperLimit The upper limit of the motor
  87000. * @param lowerLimit The lower limit of the motor
  87001. * @param motorIndex The index of the motor
  87002. */
  87003. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87004. }
  87005. /**
  87006. * Joint data for a Distance-Joint
  87007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87008. */
  87009. export interface DistanceJointData extends PhysicsJointData {
  87010. /**
  87011. * Max distance the 2 joint objects can be apart
  87012. */
  87013. maxDistance: number;
  87014. }
  87015. /**
  87016. * Joint data from a spring joint
  87017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87018. */
  87019. export interface SpringJointData extends PhysicsJointData {
  87020. /**
  87021. * Length of the spring
  87022. */
  87023. length: number;
  87024. /**
  87025. * Stiffness of the spring
  87026. */
  87027. stiffness: number;
  87028. /**
  87029. * Damping of the spring
  87030. */
  87031. damping: number;
  87032. /** this callback will be called when applying the force to the impostors. */
  87033. forceApplicationCallback: () => void;
  87034. }
  87035. }
  87036. declare module BABYLON {
  87037. /**
  87038. * Holds the data for the raycast result
  87039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87040. */
  87041. export class PhysicsRaycastResult {
  87042. private _hasHit;
  87043. private _hitDistance;
  87044. private _hitNormalWorld;
  87045. private _hitPointWorld;
  87046. private _rayFromWorld;
  87047. private _rayToWorld;
  87048. /**
  87049. * Gets if there was a hit
  87050. */
  87051. readonly hasHit: boolean;
  87052. /**
  87053. * Gets the distance from the hit
  87054. */
  87055. readonly hitDistance: number;
  87056. /**
  87057. * Gets the hit normal/direction in the world
  87058. */
  87059. readonly hitNormalWorld: Vector3;
  87060. /**
  87061. * Gets the hit point in the world
  87062. */
  87063. readonly hitPointWorld: Vector3;
  87064. /**
  87065. * Gets the ray "start point" of the ray in the world
  87066. */
  87067. readonly rayFromWorld: Vector3;
  87068. /**
  87069. * Gets the ray "end point" of the ray in the world
  87070. */
  87071. readonly rayToWorld: Vector3;
  87072. /**
  87073. * Sets the hit data (normal & point in world space)
  87074. * @param hitNormalWorld defines the normal in world space
  87075. * @param hitPointWorld defines the point in world space
  87076. */
  87077. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87078. /**
  87079. * Sets the distance from the start point to the hit point
  87080. * @param distance
  87081. */
  87082. setHitDistance(distance: number): void;
  87083. /**
  87084. * Calculates the distance manually
  87085. */
  87086. calculateHitDistance(): void;
  87087. /**
  87088. * Resets all the values to default
  87089. * @param from The from point on world space
  87090. * @param to The to point on world space
  87091. */
  87092. reset(from?: Vector3, to?: Vector3): void;
  87093. }
  87094. /**
  87095. * Interface for the size containing width and height
  87096. */
  87097. interface IXYZ {
  87098. /**
  87099. * X
  87100. */
  87101. x: number;
  87102. /**
  87103. * Y
  87104. */
  87105. y: number;
  87106. /**
  87107. * Z
  87108. */
  87109. z: number;
  87110. }
  87111. }
  87112. declare module BABYLON {
  87113. /**
  87114. * Interface used to describe a physics joint
  87115. */
  87116. export interface PhysicsImpostorJoint {
  87117. /** Defines the main impostor to which the joint is linked */
  87118. mainImpostor: PhysicsImpostor;
  87119. /** Defines the impostor that is connected to the main impostor using this joint */
  87120. connectedImpostor: PhysicsImpostor;
  87121. /** Defines the joint itself */
  87122. joint: PhysicsJoint;
  87123. }
  87124. /** @hidden */
  87125. export interface IPhysicsEnginePlugin {
  87126. world: any;
  87127. name: string;
  87128. setGravity(gravity: Vector3): void;
  87129. setTimeStep(timeStep: number): void;
  87130. getTimeStep(): number;
  87131. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  87132. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87133. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87134. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87135. removePhysicsBody(impostor: PhysicsImpostor): void;
  87136. generateJoint(joint: PhysicsImpostorJoint): void;
  87137. removeJoint(joint: PhysicsImpostorJoint): void;
  87138. isSupported(): boolean;
  87139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87146. getBodyMass(impostor: PhysicsImpostor): number;
  87147. getBodyFriction(impostor: PhysicsImpostor): number;
  87148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87149. getBodyRestitution(impostor: PhysicsImpostor): number;
  87150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87151. getBodyPressure?(impostor: PhysicsImpostor): number;
  87152. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87153. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87154. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87155. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87156. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87157. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87158. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87159. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87160. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87161. sleepBody(impostor: PhysicsImpostor): void;
  87162. wakeUpBody(impostor: PhysicsImpostor): void;
  87163. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87164. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87165. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87166. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87167. getRadius(impostor: PhysicsImpostor): number;
  87168. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87170. dispose(): void;
  87171. }
  87172. /**
  87173. * Interface used to define a physics engine
  87174. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87175. */
  87176. export interface IPhysicsEngine {
  87177. /**
  87178. * Gets the gravity vector used by the simulation
  87179. */
  87180. gravity: Vector3;
  87181. /**
  87182. * Sets the gravity vector used by the simulation
  87183. * @param gravity defines the gravity vector to use
  87184. */
  87185. setGravity(gravity: Vector3): void;
  87186. /**
  87187. * Set the time step of the physics engine.
  87188. * Default is 1/60.
  87189. * To slow it down, enter 1/600 for example.
  87190. * To speed it up, 1/30
  87191. * @param newTimeStep the new timestep to apply to this world.
  87192. */
  87193. setTimeStep(newTimeStep: number): void;
  87194. /**
  87195. * Get the time step of the physics engine.
  87196. * @returns the current time step
  87197. */
  87198. getTimeStep(): number;
  87199. /**
  87200. * Release all resources
  87201. */
  87202. dispose(): void;
  87203. /**
  87204. * Gets the name of the current physics plugin
  87205. * @returns the name of the plugin
  87206. */
  87207. getPhysicsPluginName(): string;
  87208. /**
  87209. * Adding a new impostor for the impostor tracking.
  87210. * This will be done by the impostor itself.
  87211. * @param impostor the impostor to add
  87212. */
  87213. addImpostor(impostor: PhysicsImpostor): void;
  87214. /**
  87215. * Remove an impostor from the engine.
  87216. * This impostor and its mesh will not longer be updated by the physics engine.
  87217. * @param impostor the impostor to remove
  87218. */
  87219. removeImpostor(impostor: PhysicsImpostor): void;
  87220. /**
  87221. * Add a joint to the physics engine
  87222. * @param mainImpostor defines the main impostor to which the joint is added.
  87223. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87224. * @param joint defines the joint that will connect both impostors.
  87225. */
  87226. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87227. /**
  87228. * Removes a joint from the simulation
  87229. * @param mainImpostor defines the impostor used with the joint
  87230. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87231. * @param joint defines the joint to remove
  87232. */
  87233. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87234. /**
  87235. * Gets the current plugin used to run the simulation
  87236. * @returns current plugin
  87237. */
  87238. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87239. /**
  87240. * Gets the list of physic impostors
  87241. * @returns an array of PhysicsImpostor
  87242. */
  87243. getImpostors(): Array<PhysicsImpostor>;
  87244. /**
  87245. * Gets the impostor for a physics enabled object
  87246. * @param object defines the object impersonated by the impostor
  87247. * @returns the PhysicsImpostor or null if not found
  87248. */
  87249. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87250. /**
  87251. * Gets the impostor for a physics body object
  87252. * @param body defines physics body used by the impostor
  87253. * @returns the PhysicsImpostor or null if not found
  87254. */
  87255. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87256. /**
  87257. * Does a raycast in the physics world
  87258. * @param from when should the ray start?
  87259. * @param to when should the ray end?
  87260. * @returns PhysicsRaycastResult
  87261. */
  87262. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87263. /**
  87264. * Called by the scene. No need to call it.
  87265. * @param delta defines the timespam between frames
  87266. */
  87267. _step(delta: number): void;
  87268. }
  87269. }
  87270. declare module BABYLON {
  87271. /**
  87272. * The interface for the physics imposter parameters
  87273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87274. */
  87275. export interface PhysicsImpostorParameters {
  87276. /**
  87277. * The mass of the physics imposter
  87278. */
  87279. mass: number;
  87280. /**
  87281. * The friction of the physics imposter
  87282. */
  87283. friction?: number;
  87284. /**
  87285. * The coefficient of restitution of the physics imposter
  87286. */
  87287. restitution?: number;
  87288. /**
  87289. * The native options of the physics imposter
  87290. */
  87291. nativeOptions?: any;
  87292. /**
  87293. * Specifies if the parent should be ignored
  87294. */
  87295. ignoreParent?: boolean;
  87296. /**
  87297. * Specifies if bi-directional transformations should be disabled
  87298. */
  87299. disableBidirectionalTransformation?: boolean;
  87300. /**
  87301. * The pressure inside the physics imposter, soft object only
  87302. */
  87303. pressure?: number;
  87304. /**
  87305. * The stiffness the physics imposter, soft object only
  87306. */
  87307. stiffness?: number;
  87308. /**
  87309. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87310. */
  87311. velocityIterations?: number;
  87312. /**
  87313. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87314. */
  87315. positionIterations?: number;
  87316. /**
  87317. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87318. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87319. * Add to fix multiple points
  87320. */
  87321. fixedPoints?: number;
  87322. /**
  87323. * The collision margin around a soft object
  87324. */
  87325. margin?: number;
  87326. /**
  87327. * The collision margin around a soft object
  87328. */
  87329. damping?: number;
  87330. /**
  87331. * The path for a rope based on an extrusion
  87332. */
  87333. path?: any;
  87334. /**
  87335. * The shape of an extrusion used for a rope based on an extrusion
  87336. */
  87337. shape?: any;
  87338. }
  87339. /**
  87340. * Interface for a physics-enabled object
  87341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87342. */
  87343. export interface IPhysicsEnabledObject {
  87344. /**
  87345. * The position of the physics-enabled object
  87346. */
  87347. position: Vector3;
  87348. /**
  87349. * The rotation of the physics-enabled object
  87350. */
  87351. rotationQuaternion: Nullable<Quaternion>;
  87352. /**
  87353. * The scale of the physics-enabled object
  87354. */
  87355. scaling: Vector3;
  87356. /**
  87357. * The rotation of the physics-enabled object
  87358. */
  87359. rotation?: Vector3;
  87360. /**
  87361. * The parent of the physics-enabled object
  87362. */
  87363. parent?: any;
  87364. /**
  87365. * The bounding info of the physics-enabled object
  87366. * @returns The bounding info of the physics-enabled object
  87367. */
  87368. getBoundingInfo(): BoundingInfo;
  87369. /**
  87370. * Computes the world matrix
  87371. * @param force Specifies if the world matrix should be computed by force
  87372. * @returns A world matrix
  87373. */
  87374. computeWorldMatrix(force: boolean): Matrix;
  87375. /**
  87376. * Gets the world matrix
  87377. * @returns A world matrix
  87378. */
  87379. getWorldMatrix?(): Matrix;
  87380. /**
  87381. * Gets the child meshes
  87382. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87383. * @returns An array of abstract meshes
  87384. */
  87385. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87386. /**
  87387. * Gets the vertex data
  87388. * @param kind The type of vertex data
  87389. * @returns A nullable array of numbers, or a float32 array
  87390. */
  87391. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87392. /**
  87393. * Gets the indices from the mesh
  87394. * @returns A nullable array of index arrays
  87395. */
  87396. getIndices?(): Nullable<IndicesArray>;
  87397. /**
  87398. * Gets the scene from the mesh
  87399. * @returns the indices array or null
  87400. */
  87401. getScene?(): Scene;
  87402. /**
  87403. * Gets the absolute position from the mesh
  87404. * @returns the absolute position
  87405. */
  87406. getAbsolutePosition(): Vector3;
  87407. /**
  87408. * Gets the absolute pivot point from the mesh
  87409. * @returns the absolute pivot point
  87410. */
  87411. getAbsolutePivotPoint(): Vector3;
  87412. /**
  87413. * Rotates the mesh
  87414. * @param axis The axis of rotation
  87415. * @param amount The amount of rotation
  87416. * @param space The space of the rotation
  87417. * @returns The rotation transform node
  87418. */
  87419. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87420. /**
  87421. * Translates the mesh
  87422. * @param axis The axis of translation
  87423. * @param distance The distance of translation
  87424. * @param space The space of the translation
  87425. * @returns The transform node
  87426. */
  87427. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87428. /**
  87429. * Sets the absolute position of the mesh
  87430. * @param absolutePosition The absolute position of the mesh
  87431. * @returns The transform node
  87432. */
  87433. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87434. /**
  87435. * Gets the class name of the mesh
  87436. * @returns The class name
  87437. */
  87438. getClassName(): string;
  87439. }
  87440. /**
  87441. * Represents a physics imposter
  87442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87443. */
  87444. export class PhysicsImpostor {
  87445. /**
  87446. * The physics-enabled object used as the physics imposter
  87447. */
  87448. object: IPhysicsEnabledObject;
  87449. /**
  87450. * The type of the physics imposter
  87451. */
  87452. type: number;
  87453. private _options;
  87454. private _scene?;
  87455. /**
  87456. * The default object size of the imposter
  87457. */
  87458. static DEFAULT_OBJECT_SIZE: Vector3;
  87459. /**
  87460. * The identity quaternion of the imposter
  87461. */
  87462. static IDENTITY_QUATERNION: Quaternion;
  87463. /** @hidden */
  87464. _pluginData: any;
  87465. private _physicsEngine;
  87466. private _physicsBody;
  87467. private _bodyUpdateRequired;
  87468. private _onBeforePhysicsStepCallbacks;
  87469. private _onAfterPhysicsStepCallbacks;
  87470. /** @hidden */
  87471. _onPhysicsCollideCallbacks: Array<{
  87472. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87473. otherImpostors: Array<PhysicsImpostor>;
  87474. }>;
  87475. private _deltaPosition;
  87476. private _deltaRotation;
  87477. private _deltaRotationConjugated;
  87478. /** @hidden */
  87479. _isFromLine: boolean;
  87480. private _parent;
  87481. private _isDisposed;
  87482. private static _tmpVecs;
  87483. private static _tmpQuat;
  87484. /**
  87485. * Specifies if the physics imposter is disposed
  87486. */
  87487. readonly isDisposed: boolean;
  87488. /**
  87489. * Gets the mass of the physics imposter
  87490. */
  87491. mass: number;
  87492. /**
  87493. * Gets the coefficient of friction
  87494. */
  87495. /**
  87496. * Sets the coefficient of friction
  87497. */
  87498. friction: number;
  87499. /**
  87500. * Gets the coefficient of restitution
  87501. */
  87502. /**
  87503. * Sets the coefficient of restitution
  87504. */
  87505. restitution: number;
  87506. /**
  87507. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87508. */
  87509. /**
  87510. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87511. */
  87512. pressure: number;
  87513. /**
  87514. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87515. */
  87516. /**
  87517. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87518. */
  87519. stiffness: number;
  87520. /**
  87521. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87522. */
  87523. /**
  87524. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87525. */
  87526. velocityIterations: number;
  87527. /**
  87528. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87529. */
  87530. /**
  87531. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87532. */
  87533. positionIterations: number;
  87534. /**
  87535. * The unique id of the physics imposter
  87536. * set by the physics engine when adding this impostor to the array
  87537. */
  87538. uniqueId: number;
  87539. /**
  87540. * @hidden
  87541. */
  87542. soft: boolean;
  87543. /**
  87544. * @hidden
  87545. */
  87546. segments: number;
  87547. private _joints;
  87548. /**
  87549. * Initializes the physics imposter
  87550. * @param object The physics-enabled object used as the physics imposter
  87551. * @param type The type of the physics imposter
  87552. * @param _options The options for the physics imposter
  87553. * @param _scene The Babylon scene
  87554. */
  87555. constructor(
  87556. /**
  87557. * The physics-enabled object used as the physics imposter
  87558. */
  87559. object: IPhysicsEnabledObject,
  87560. /**
  87561. * The type of the physics imposter
  87562. */
  87563. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87564. /**
  87565. * This function will completly initialize this impostor.
  87566. * It will create a new body - but only if this mesh has no parent.
  87567. * If it has, this impostor will not be used other than to define the impostor
  87568. * of the child mesh.
  87569. * @hidden
  87570. */
  87571. _init(): void;
  87572. private _getPhysicsParent;
  87573. /**
  87574. * Should a new body be generated.
  87575. * @returns boolean specifying if body initialization is required
  87576. */
  87577. isBodyInitRequired(): boolean;
  87578. /**
  87579. * Sets the updated scaling
  87580. * @param updated Specifies if the scaling is updated
  87581. */
  87582. setScalingUpdated(): void;
  87583. /**
  87584. * Force a regeneration of this or the parent's impostor's body.
  87585. * Use under cautious - This will remove all joints already implemented.
  87586. */
  87587. forceUpdate(): void;
  87588. /**
  87589. * Gets the body that holds this impostor. Either its own, or its parent.
  87590. */
  87591. /**
  87592. * Set the physics body. Used mainly by the physics engine/plugin
  87593. */
  87594. physicsBody: any;
  87595. /**
  87596. * Get the parent of the physics imposter
  87597. * @returns Physics imposter or null
  87598. */
  87599. /**
  87600. * Sets the parent of the physics imposter
  87601. */
  87602. parent: Nullable<PhysicsImpostor>;
  87603. /**
  87604. * Resets the update flags
  87605. */
  87606. resetUpdateFlags(): void;
  87607. /**
  87608. * Gets the object extend size
  87609. * @returns the object extend size
  87610. */
  87611. getObjectExtendSize(): Vector3;
  87612. /**
  87613. * Gets the object center
  87614. * @returns The object center
  87615. */
  87616. getObjectCenter(): Vector3;
  87617. /**
  87618. * Get a specific parametes from the options parameter
  87619. * @param paramName The object parameter name
  87620. * @returns The object parameter
  87621. */
  87622. getParam(paramName: string): any;
  87623. /**
  87624. * Sets a specific parameter in the options given to the physics plugin
  87625. * @param paramName The parameter name
  87626. * @param value The value of the parameter
  87627. */
  87628. setParam(paramName: string, value: number): void;
  87629. /**
  87630. * Specifically change the body's mass option. Won't recreate the physics body object
  87631. * @param mass The mass of the physics imposter
  87632. */
  87633. setMass(mass: number): void;
  87634. /**
  87635. * Gets the linear velocity
  87636. * @returns linear velocity or null
  87637. */
  87638. getLinearVelocity(): Nullable<Vector3>;
  87639. /**
  87640. * Sets the linear velocity
  87641. * @param velocity linear velocity or null
  87642. */
  87643. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87644. /**
  87645. * Gets the angular velocity
  87646. * @returns angular velocity or null
  87647. */
  87648. getAngularVelocity(): Nullable<Vector3>;
  87649. /**
  87650. * Sets the angular velocity
  87651. * @param velocity The velocity or null
  87652. */
  87653. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87654. /**
  87655. * Execute a function with the physics plugin native code
  87656. * Provide a function the will have two variables - the world object and the physics body object
  87657. * @param func The function to execute with the physics plugin native code
  87658. */
  87659. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87660. /**
  87661. * Register a function that will be executed before the physics world is stepping forward
  87662. * @param func The function to execute before the physics world is stepped forward
  87663. */
  87664. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87665. /**
  87666. * Unregister a function that will be executed before the physics world is stepping forward
  87667. * @param func The function to execute before the physics world is stepped forward
  87668. */
  87669. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87670. /**
  87671. * Register a function that will be executed after the physics step
  87672. * @param func The function to execute after physics step
  87673. */
  87674. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87675. /**
  87676. * Unregisters a function that will be executed after the physics step
  87677. * @param func The function to execute after physics step
  87678. */
  87679. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87680. /**
  87681. * register a function that will be executed when this impostor collides against a different body
  87682. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87683. * @param func Callback that is executed on collision
  87684. */
  87685. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87686. /**
  87687. * Unregisters the physics imposter on contact
  87688. * @param collideAgainst The physics object to collide against
  87689. * @param func Callback to execute on collision
  87690. */
  87691. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87692. private _tmpQuat;
  87693. private _tmpQuat2;
  87694. /**
  87695. * Get the parent rotation
  87696. * @returns The parent rotation
  87697. */
  87698. getParentsRotation(): Quaternion;
  87699. /**
  87700. * this function is executed by the physics engine.
  87701. */
  87702. beforeStep: () => void;
  87703. /**
  87704. * this function is executed by the physics engine
  87705. */
  87706. afterStep: () => void;
  87707. /**
  87708. * Legacy collision detection event support
  87709. */
  87710. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87711. /**
  87712. * event and body object due to cannon's event-based architecture.
  87713. */
  87714. onCollide: (e: {
  87715. body: any;
  87716. }) => void;
  87717. /**
  87718. * Apply a force
  87719. * @param force The force to apply
  87720. * @param contactPoint The contact point for the force
  87721. * @returns The physics imposter
  87722. */
  87723. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87724. /**
  87725. * Apply an impulse
  87726. * @param force The impulse force
  87727. * @param contactPoint The contact point for the impulse force
  87728. * @returns The physics imposter
  87729. */
  87730. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87731. /**
  87732. * A help function to create a joint
  87733. * @param otherImpostor A physics imposter used to create a joint
  87734. * @param jointType The type of joint
  87735. * @param jointData The data for the joint
  87736. * @returns The physics imposter
  87737. */
  87738. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87739. /**
  87740. * Add a joint to this impostor with a different impostor
  87741. * @param otherImpostor A physics imposter used to add a joint
  87742. * @param joint The joint to add
  87743. * @returns The physics imposter
  87744. */
  87745. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87746. /**
  87747. * Add an anchor to a cloth impostor
  87748. * @param otherImpostor rigid impostor to anchor to
  87749. * @param width ratio across width from 0 to 1
  87750. * @param height ratio up height from 0 to 1
  87751. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87752. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87753. * @returns impostor the soft imposter
  87754. */
  87755. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87756. /**
  87757. * Add a hook to a rope impostor
  87758. * @param otherImpostor rigid impostor to anchor to
  87759. * @param length ratio across rope from 0 to 1
  87760. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87761. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87762. * @returns impostor the rope imposter
  87763. */
  87764. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87765. /**
  87766. * Will keep this body still, in a sleep mode.
  87767. * @returns the physics imposter
  87768. */
  87769. sleep(): PhysicsImpostor;
  87770. /**
  87771. * Wake the body up.
  87772. * @returns The physics imposter
  87773. */
  87774. wakeUp(): PhysicsImpostor;
  87775. /**
  87776. * Clones the physics imposter
  87777. * @param newObject The physics imposter clones to this physics-enabled object
  87778. * @returns A nullable physics imposter
  87779. */
  87780. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87781. /**
  87782. * Disposes the physics imposter
  87783. */
  87784. dispose(): void;
  87785. /**
  87786. * Sets the delta position
  87787. * @param position The delta position amount
  87788. */
  87789. setDeltaPosition(position: Vector3): void;
  87790. /**
  87791. * Sets the delta rotation
  87792. * @param rotation The delta rotation amount
  87793. */
  87794. setDeltaRotation(rotation: Quaternion): void;
  87795. /**
  87796. * Gets the box size of the physics imposter and stores the result in the input parameter
  87797. * @param result Stores the box size
  87798. * @returns The physics imposter
  87799. */
  87800. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87801. /**
  87802. * Gets the radius of the physics imposter
  87803. * @returns Radius of the physics imposter
  87804. */
  87805. getRadius(): number;
  87806. /**
  87807. * Sync a bone with this impostor
  87808. * @param bone The bone to sync to the impostor.
  87809. * @param boneMesh The mesh that the bone is influencing.
  87810. * @param jointPivot The pivot of the joint / bone in local space.
  87811. * @param distToJoint Optional distance from the impostor to the joint.
  87812. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87813. */
  87814. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87815. /**
  87816. * Sync impostor to a bone
  87817. * @param bone The bone that the impostor will be synced to.
  87818. * @param boneMesh The mesh that the bone is influencing.
  87819. * @param jointPivot The pivot of the joint / bone in local space.
  87820. * @param distToJoint Optional distance from the impostor to the joint.
  87821. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87822. * @param boneAxis Optional vector3 axis the bone is aligned with
  87823. */
  87824. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87825. /**
  87826. * No-Imposter type
  87827. */
  87828. static NoImpostor: number;
  87829. /**
  87830. * Sphere-Imposter type
  87831. */
  87832. static SphereImpostor: number;
  87833. /**
  87834. * Box-Imposter type
  87835. */
  87836. static BoxImpostor: number;
  87837. /**
  87838. * Plane-Imposter type
  87839. */
  87840. static PlaneImpostor: number;
  87841. /**
  87842. * Mesh-imposter type
  87843. */
  87844. static MeshImpostor: number;
  87845. /**
  87846. * Capsule-Impostor type (Ammo.js plugin only)
  87847. */
  87848. static CapsuleImpostor: number;
  87849. /**
  87850. * Cylinder-Imposter type
  87851. */
  87852. static CylinderImpostor: number;
  87853. /**
  87854. * Particle-Imposter type
  87855. */
  87856. static ParticleImpostor: number;
  87857. /**
  87858. * Heightmap-Imposter type
  87859. */
  87860. static HeightmapImpostor: number;
  87861. /**
  87862. * ConvexHull-Impostor type (Ammo.js plugin only)
  87863. */
  87864. static ConvexHullImpostor: number;
  87865. /**
  87866. * Rope-Imposter type
  87867. */
  87868. static RopeImpostor: number;
  87869. /**
  87870. * Cloth-Imposter type
  87871. */
  87872. static ClothImpostor: number;
  87873. /**
  87874. * Softbody-Imposter type
  87875. */
  87876. static SoftbodyImpostor: number;
  87877. }
  87878. }
  87879. declare module BABYLON {
  87880. /**
  87881. * @hidden
  87882. **/
  87883. export class _CreationDataStorage {
  87884. closePath?: boolean;
  87885. closeArray?: boolean;
  87886. idx: number[];
  87887. dashSize: number;
  87888. gapSize: number;
  87889. path3D: Path3D;
  87890. pathArray: Vector3[][];
  87891. arc: number;
  87892. radius: number;
  87893. cap: number;
  87894. tessellation: number;
  87895. }
  87896. /**
  87897. * @hidden
  87898. **/
  87899. class _InstanceDataStorage {
  87900. visibleInstances: any;
  87901. batchCache: _InstancesBatch;
  87902. instancesBufferSize: number;
  87903. instancesBuffer: Nullable<Buffer>;
  87904. instancesData: Float32Array;
  87905. overridenInstanceCount: number;
  87906. isFrozen: boolean;
  87907. previousBatch: Nullable<_InstancesBatch>;
  87908. hardwareInstancedRendering: boolean;
  87909. sideOrientation: number;
  87910. }
  87911. /**
  87912. * @hidden
  87913. **/
  87914. export class _InstancesBatch {
  87915. mustReturn: boolean;
  87916. visibleInstances: Nullable<InstancedMesh[]>[];
  87917. renderSelf: boolean[];
  87918. hardwareInstancedRendering: boolean[];
  87919. }
  87920. /**
  87921. * Class used to represent renderable models
  87922. */
  87923. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87924. /**
  87925. * Mesh side orientation : usually the external or front surface
  87926. */
  87927. static readonly FRONTSIDE: number;
  87928. /**
  87929. * Mesh side orientation : usually the internal or back surface
  87930. */
  87931. static readonly BACKSIDE: number;
  87932. /**
  87933. * Mesh side orientation : both internal and external or front and back surfaces
  87934. */
  87935. static readonly DOUBLESIDE: number;
  87936. /**
  87937. * Mesh side orientation : by default, `FRONTSIDE`
  87938. */
  87939. static readonly DEFAULTSIDE: number;
  87940. /**
  87941. * Mesh cap setting : no cap
  87942. */
  87943. static readonly NO_CAP: number;
  87944. /**
  87945. * Mesh cap setting : one cap at the beginning of the mesh
  87946. */
  87947. static readonly CAP_START: number;
  87948. /**
  87949. * Mesh cap setting : one cap at the end of the mesh
  87950. */
  87951. static readonly CAP_END: number;
  87952. /**
  87953. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87954. */
  87955. static readonly CAP_ALL: number;
  87956. /**
  87957. * Mesh pattern setting : no flip or rotate
  87958. */
  87959. static readonly NO_FLIP: number;
  87960. /**
  87961. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87962. */
  87963. static readonly FLIP_TILE: number;
  87964. /**
  87965. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87966. */
  87967. static readonly ROTATE_TILE: number;
  87968. /**
  87969. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87970. */
  87971. static readonly FLIP_ROW: number;
  87972. /**
  87973. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87974. */
  87975. static readonly ROTATE_ROW: number;
  87976. /**
  87977. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87978. */
  87979. static readonly FLIP_N_ROTATE_TILE: number;
  87980. /**
  87981. * Mesh pattern setting : rotate pattern and rotate
  87982. */
  87983. static readonly FLIP_N_ROTATE_ROW: number;
  87984. /**
  87985. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87986. */
  87987. static readonly CENTER: number;
  87988. /**
  87989. * Mesh tile positioning : part tiles on left
  87990. */
  87991. static readonly LEFT: number;
  87992. /**
  87993. * Mesh tile positioning : part tiles on right
  87994. */
  87995. static readonly RIGHT: number;
  87996. /**
  87997. * Mesh tile positioning : part tiles on top
  87998. */
  87999. static readonly TOP: number;
  88000. /**
  88001. * Mesh tile positioning : part tiles on bottom
  88002. */
  88003. static readonly BOTTOM: number;
  88004. /**
  88005. * Gets the default side orientation.
  88006. * @param orientation the orientation to value to attempt to get
  88007. * @returns the default orientation
  88008. * @hidden
  88009. */
  88010. static _GetDefaultSideOrientation(orientation?: number): number;
  88011. private _internalMeshDataInfo;
  88012. /**
  88013. * An event triggered before rendering the mesh
  88014. */
  88015. readonly onBeforeRenderObservable: Observable<Mesh>;
  88016. /**
  88017. * An event triggered before binding the mesh
  88018. */
  88019. readonly onBeforeBindObservable: Observable<Mesh>;
  88020. /**
  88021. * An event triggered after rendering the mesh
  88022. */
  88023. readonly onAfterRenderObservable: Observable<Mesh>;
  88024. /**
  88025. * An event triggered before drawing the mesh
  88026. */
  88027. readonly onBeforeDrawObservable: Observable<Mesh>;
  88028. private _onBeforeDrawObserver;
  88029. /**
  88030. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88031. */
  88032. onBeforeDraw: () => void;
  88033. readonly hasInstances: boolean;
  88034. /**
  88035. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88036. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88037. */
  88038. delayLoadState: number;
  88039. /**
  88040. * Gets the list of instances created from this mesh
  88041. * it is not supposed to be modified manually.
  88042. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88043. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88044. */
  88045. instances: InstancedMesh[];
  88046. /**
  88047. * Gets the file containing delay loading data for this mesh
  88048. */
  88049. delayLoadingFile: string;
  88050. /** @hidden */
  88051. _binaryInfo: any;
  88052. /**
  88053. * User defined function used to change how LOD level selection is done
  88054. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88055. */
  88056. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88057. /**
  88058. * Gets or sets the morph target manager
  88059. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88060. */
  88061. morphTargetManager: Nullable<MorphTargetManager>;
  88062. /** @hidden */
  88063. _creationDataStorage: Nullable<_CreationDataStorage>;
  88064. /** @hidden */
  88065. _geometry: Nullable<Geometry>;
  88066. /** @hidden */
  88067. _delayInfo: Array<string>;
  88068. /** @hidden */
  88069. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88070. /** @hidden */
  88071. _instanceDataStorage: _InstanceDataStorage;
  88072. private _effectiveMaterial;
  88073. /** @hidden */
  88074. _shouldGenerateFlatShading: boolean;
  88075. /** @hidden */
  88076. _originalBuilderSideOrientation: number;
  88077. /**
  88078. * Use this property to change the original side orientation defined at construction time
  88079. */
  88080. overrideMaterialSideOrientation: Nullable<number>;
  88081. /**
  88082. * Gets the source mesh (the one used to clone this one from)
  88083. */
  88084. readonly source: Nullable<Mesh>;
  88085. /**
  88086. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88087. */
  88088. isUnIndexed: boolean;
  88089. /**
  88090. * @constructor
  88091. * @param name The value used by scene.getMeshByName() to do a lookup.
  88092. * @param scene The scene to add this mesh to.
  88093. * @param parent The parent of this mesh, if it has one
  88094. * @param source An optional Mesh from which geometry is shared, cloned.
  88095. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88096. * When false, achieved by calling a clone(), also passing False.
  88097. * This will make creation of children, recursive.
  88098. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88099. */
  88100. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88101. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88102. /**
  88103. * Gets the class name
  88104. * @returns the string "Mesh".
  88105. */
  88106. getClassName(): string;
  88107. /** @hidden */
  88108. readonly _isMesh: boolean;
  88109. /**
  88110. * Returns a description of this mesh
  88111. * @param fullDetails define if full details about this mesh must be used
  88112. * @returns a descriptive string representing this mesh
  88113. */
  88114. toString(fullDetails?: boolean): string;
  88115. /** @hidden */
  88116. _unBindEffect(): void;
  88117. /**
  88118. * Gets a boolean indicating if this mesh has LOD
  88119. */
  88120. readonly hasLODLevels: boolean;
  88121. /**
  88122. * Gets the list of MeshLODLevel associated with the current mesh
  88123. * @returns an array of MeshLODLevel
  88124. */
  88125. getLODLevels(): MeshLODLevel[];
  88126. private _sortLODLevels;
  88127. /**
  88128. * Add a mesh as LOD level triggered at the given distance.
  88129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88130. * @param distance The distance from the center of the object to show this level
  88131. * @param mesh The mesh to be added as LOD level (can be null)
  88132. * @return This mesh (for chaining)
  88133. */
  88134. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88135. /**
  88136. * Returns the LOD level mesh at the passed distance or null if not found.
  88137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88138. * @param distance The distance from the center of the object to show this level
  88139. * @returns a Mesh or `null`
  88140. */
  88141. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88142. /**
  88143. * Remove a mesh from the LOD array
  88144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88145. * @param mesh defines the mesh to be removed
  88146. * @return This mesh (for chaining)
  88147. */
  88148. removeLODLevel(mesh: Mesh): Mesh;
  88149. /**
  88150. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88152. * @param camera defines the camera to use to compute distance
  88153. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88154. * @return This mesh (for chaining)
  88155. */
  88156. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88157. /**
  88158. * Gets the mesh internal Geometry object
  88159. */
  88160. readonly geometry: Nullable<Geometry>;
  88161. /**
  88162. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88163. * @returns the total number of vertices
  88164. */
  88165. getTotalVertices(): number;
  88166. /**
  88167. * Returns the content of an associated vertex buffer
  88168. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88169. * - VertexBuffer.PositionKind
  88170. * - VertexBuffer.UVKind
  88171. * - VertexBuffer.UV2Kind
  88172. * - VertexBuffer.UV3Kind
  88173. * - VertexBuffer.UV4Kind
  88174. * - VertexBuffer.UV5Kind
  88175. * - VertexBuffer.UV6Kind
  88176. * - VertexBuffer.ColorKind
  88177. * - VertexBuffer.MatricesIndicesKind
  88178. * - VertexBuffer.MatricesIndicesExtraKind
  88179. * - VertexBuffer.MatricesWeightsKind
  88180. * - VertexBuffer.MatricesWeightsExtraKind
  88181. * @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
  88182. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88183. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88184. */
  88185. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88186. /**
  88187. * Returns the mesh VertexBuffer object from the requested `kind`
  88188. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88189. * - VertexBuffer.PositionKind
  88190. * - VertexBuffer.NormalKind
  88191. * - VertexBuffer.UVKind
  88192. * - VertexBuffer.UV2Kind
  88193. * - VertexBuffer.UV3Kind
  88194. * - VertexBuffer.UV4Kind
  88195. * - VertexBuffer.UV5Kind
  88196. * - VertexBuffer.UV6Kind
  88197. * - VertexBuffer.ColorKind
  88198. * - VertexBuffer.MatricesIndicesKind
  88199. * - VertexBuffer.MatricesIndicesExtraKind
  88200. * - VertexBuffer.MatricesWeightsKind
  88201. * - VertexBuffer.MatricesWeightsExtraKind
  88202. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88203. */
  88204. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88205. /**
  88206. * Tests if a specific vertex buffer is associated with this mesh
  88207. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88208. * - VertexBuffer.PositionKind
  88209. * - VertexBuffer.NormalKind
  88210. * - VertexBuffer.UVKind
  88211. * - VertexBuffer.UV2Kind
  88212. * - VertexBuffer.UV3Kind
  88213. * - VertexBuffer.UV4Kind
  88214. * - VertexBuffer.UV5Kind
  88215. * - VertexBuffer.UV6Kind
  88216. * - VertexBuffer.ColorKind
  88217. * - VertexBuffer.MatricesIndicesKind
  88218. * - VertexBuffer.MatricesIndicesExtraKind
  88219. * - VertexBuffer.MatricesWeightsKind
  88220. * - VertexBuffer.MatricesWeightsExtraKind
  88221. * @returns a boolean
  88222. */
  88223. isVerticesDataPresent(kind: string): boolean;
  88224. /**
  88225. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88226. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88227. * - VertexBuffer.PositionKind
  88228. * - VertexBuffer.UVKind
  88229. * - VertexBuffer.UV2Kind
  88230. * - VertexBuffer.UV3Kind
  88231. * - VertexBuffer.UV4Kind
  88232. * - VertexBuffer.UV5Kind
  88233. * - VertexBuffer.UV6Kind
  88234. * - VertexBuffer.ColorKind
  88235. * - VertexBuffer.MatricesIndicesKind
  88236. * - VertexBuffer.MatricesIndicesExtraKind
  88237. * - VertexBuffer.MatricesWeightsKind
  88238. * - VertexBuffer.MatricesWeightsExtraKind
  88239. * @returns a boolean
  88240. */
  88241. isVertexBufferUpdatable(kind: string): boolean;
  88242. /**
  88243. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88245. * - VertexBuffer.PositionKind
  88246. * - VertexBuffer.NormalKind
  88247. * - VertexBuffer.UVKind
  88248. * - VertexBuffer.UV2Kind
  88249. * - VertexBuffer.UV3Kind
  88250. * - VertexBuffer.UV4Kind
  88251. * - VertexBuffer.UV5Kind
  88252. * - VertexBuffer.UV6Kind
  88253. * - VertexBuffer.ColorKind
  88254. * - VertexBuffer.MatricesIndicesKind
  88255. * - VertexBuffer.MatricesIndicesExtraKind
  88256. * - VertexBuffer.MatricesWeightsKind
  88257. * - VertexBuffer.MatricesWeightsExtraKind
  88258. * @returns an array of strings
  88259. */
  88260. getVerticesDataKinds(): string[];
  88261. /**
  88262. * Returns a positive integer : the total number of indices in this mesh geometry.
  88263. * @returns the numner of indices or zero if the mesh has no geometry.
  88264. */
  88265. getTotalIndices(): number;
  88266. /**
  88267. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88268. * @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.
  88269. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88270. * @returns the indices array or an empty array if the mesh has no geometry
  88271. */
  88272. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88273. readonly isBlocked: boolean;
  88274. /**
  88275. * Determine if the current mesh is ready to be rendered
  88276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88277. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88278. * @returns true if all associated assets are ready (material, textures, shaders)
  88279. */
  88280. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88281. /**
  88282. * 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.
  88283. */
  88284. readonly areNormalsFrozen: boolean;
  88285. /**
  88286. * 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.
  88287. * @returns the current mesh
  88288. */
  88289. freezeNormals(): Mesh;
  88290. /**
  88291. * 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
  88292. * @returns the current mesh
  88293. */
  88294. unfreezeNormals(): Mesh;
  88295. /**
  88296. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88297. */
  88298. overridenInstanceCount: number;
  88299. /** @hidden */
  88300. _preActivate(): Mesh;
  88301. /** @hidden */
  88302. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88303. /** @hidden */
  88304. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88305. /**
  88306. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88307. * This means the mesh underlying bounding box and sphere are recomputed.
  88308. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88309. * @returns the current mesh
  88310. */
  88311. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88312. /** @hidden */
  88313. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88314. /**
  88315. * This function will subdivide the mesh into multiple submeshes
  88316. * @param count defines the expected number of submeshes
  88317. */
  88318. subdivide(count: number): void;
  88319. /**
  88320. * Copy a FloatArray into a specific associated vertex buffer
  88321. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88322. * - VertexBuffer.PositionKind
  88323. * - VertexBuffer.UVKind
  88324. * - VertexBuffer.UV2Kind
  88325. * - VertexBuffer.UV3Kind
  88326. * - VertexBuffer.UV4Kind
  88327. * - VertexBuffer.UV5Kind
  88328. * - VertexBuffer.UV6Kind
  88329. * - VertexBuffer.ColorKind
  88330. * - VertexBuffer.MatricesIndicesKind
  88331. * - VertexBuffer.MatricesIndicesExtraKind
  88332. * - VertexBuffer.MatricesWeightsKind
  88333. * - VertexBuffer.MatricesWeightsExtraKind
  88334. * @param data defines the data source
  88335. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88336. * @param stride defines the data stride size (can be null)
  88337. * @returns the current mesh
  88338. */
  88339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88340. /**
  88341. * Flags an associated vertex buffer as updatable
  88342. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88343. * - VertexBuffer.PositionKind
  88344. * - VertexBuffer.UVKind
  88345. * - VertexBuffer.UV2Kind
  88346. * - VertexBuffer.UV3Kind
  88347. * - VertexBuffer.UV4Kind
  88348. * - VertexBuffer.UV5Kind
  88349. * - VertexBuffer.UV6Kind
  88350. * - VertexBuffer.ColorKind
  88351. * - VertexBuffer.MatricesIndicesKind
  88352. * - VertexBuffer.MatricesIndicesExtraKind
  88353. * - VertexBuffer.MatricesWeightsKind
  88354. * - VertexBuffer.MatricesWeightsExtraKind
  88355. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88356. */
  88357. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88358. /**
  88359. * Sets the mesh global Vertex Buffer
  88360. * @param buffer defines the buffer to use
  88361. * @returns the current mesh
  88362. */
  88363. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88364. /**
  88365. * Update a specific associated vertex buffer
  88366. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88367. * - VertexBuffer.PositionKind
  88368. * - VertexBuffer.UVKind
  88369. * - VertexBuffer.UV2Kind
  88370. * - VertexBuffer.UV3Kind
  88371. * - VertexBuffer.UV4Kind
  88372. * - VertexBuffer.UV5Kind
  88373. * - VertexBuffer.UV6Kind
  88374. * - VertexBuffer.ColorKind
  88375. * - VertexBuffer.MatricesIndicesKind
  88376. * - VertexBuffer.MatricesIndicesExtraKind
  88377. * - VertexBuffer.MatricesWeightsKind
  88378. * - VertexBuffer.MatricesWeightsExtraKind
  88379. * @param data defines the data source
  88380. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88381. * @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)
  88382. * @returns the current mesh
  88383. */
  88384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  88385. /**
  88386. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88387. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88388. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88389. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88390. * @returns the current mesh
  88391. */
  88392. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88393. /**
  88394. * Creates a un-shared specific occurence of the geometry for the mesh.
  88395. * @returns the current mesh
  88396. */
  88397. makeGeometryUnique(): Mesh;
  88398. /**
  88399. * Set the index buffer of this mesh
  88400. * @param indices defines the source data
  88401. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88402. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88403. * @returns the current mesh
  88404. */
  88405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  88406. /**
  88407. * Update the current index buffer
  88408. * @param indices defines the source data
  88409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88410. * @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)
  88411. * @returns the current mesh
  88412. */
  88413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88414. /**
  88415. * Invert the geometry to move from a right handed system to a left handed one.
  88416. * @returns the current mesh
  88417. */
  88418. toLeftHanded(): Mesh;
  88419. /** @hidden */
  88420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88421. /** @hidden */
  88422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88423. /**
  88424. * Registers for this mesh a javascript function called just before the rendering process
  88425. * @param func defines the function to call before rendering this mesh
  88426. * @returns the current mesh
  88427. */
  88428. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88429. /**
  88430. * Disposes a previously registered javascript function called before the rendering
  88431. * @param func defines the function to remove
  88432. * @returns the current mesh
  88433. */
  88434. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88435. /**
  88436. * Registers for this mesh a javascript function called just after the rendering is complete
  88437. * @param func defines the function to call after rendering this mesh
  88438. * @returns the current mesh
  88439. */
  88440. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88441. /**
  88442. * Disposes a previously registered javascript function called after the rendering.
  88443. * @param func defines the function to remove
  88444. * @returns the current mesh
  88445. */
  88446. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88447. /** @hidden */
  88448. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88449. /** @hidden */
  88450. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88451. /** @hidden */
  88452. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88453. /** @hidden */
  88454. _rebuild(): void;
  88455. /** @hidden */
  88456. _freeze(): void;
  88457. /** @hidden */
  88458. _unFreeze(): void;
  88459. /**
  88460. * 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
  88461. * @param subMesh defines the subMesh to render
  88462. * @param enableAlphaMode defines if alpha mode can be changed
  88463. * @returns the current mesh
  88464. */
  88465. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88466. private _onBeforeDraw;
  88467. /**
  88468. * Renormalize the mesh and patch it up if there are no weights
  88469. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88470. * However in the case of zero weights then we set just a single influence to 1.
  88471. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88472. */
  88473. cleanMatrixWeights(): void;
  88474. private normalizeSkinFourWeights;
  88475. private normalizeSkinWeightsAndExtra;
  88476. /**
  88477. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88478. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88479. * the user know there was an issue with importing the mesh
  88480. * @returns a validation object with skinned, valid and report string
  88481. */
  88482. validateSkinning(): {
  88483. skinned: boolean;
  88484. valid: boolean;
  88485. report: string;
  88486. };
  88487. /** @hidden */
  88488. _checkDelayState(): Mesh;
  88489. private _queueLoad;
  88490. /**
  88491. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88492. * A mesh is in the frustum if its bounding box intersects the frustum
  88493. * @param frustumPlanes defines the frustum to test
  88494. * @returns true if the mesh is in the frustum planes
  88495. */
  88496. isInFrustum(frustumPlanes: Plane[]): boolean;
  88497. /**
  88498. * Sets the mesh material by the material or multiMaterial `id` property
  88499. * @param id is a string identifying the material or the multiMaterial
  88500. * @returns the current mesh
  88501. */
  88502. setMaterialByID(id: string): Mesh;
  88503. /**
  88504. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88505. * @returns an array of IAnimatable
  88506. */
  88507. getAnimatables(): IAnimatable[];
  88508. /**
  88509. * Modifies the mesh geometry according to the passed transformation matrix.
  88510. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88511. * The mesh normals are modified using the same transformation.
  88512. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88513. * @param transform defines the transform matrix to use
  88514. * @see http://doc.babylonjs.com/resources/baking_transformations
  88515. * @returns the current mesh
  88516. */
  88517. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88518. /**
  88519. * Modifies the mesh geometry according to its own current World Matrix.
  88520. * The mesh World Matrix is then reset.
  88521. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88522. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88523. * @see http://doc.babylonjs.com/resources/baking_transformations
  88524. * @returns the current mesh
  88525. */
  88526. bakeCurrentTransformIntoVertices(): Mesh;
  88527. /** @hidden */
  88528. readonly _positions: Nullable<Vector3[]>;
  88529. /** @hidden */
  88530. _resetPointsArrayCache(): Mesh;
  88531. /** @hidden */
  88532. _generatePointsArray(): boolean;
  88533. /**
  88534. * Returns a new Mesh object generated from the current mesh properties.
  88535. * This method must not get confused with createInstance()
  88536. * @param name is a string, the name given to the new mesh
  88537. * @param newParent can be any Node object (default `null`)
  88538. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88539. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88540. * @returns a new mesh
  88541. */
  88542. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  88543. /**
  88544. * Releases resources associated with this mesh.
  88545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88547. */
  88548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88549. /**
  88550. * Modifies the mesh geometry according to a displacement map.
  88551. * 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.
  88552. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88553. * @param url is a string, the URL from the image file is to be downloaded.
  88554. * @param minHeight is the lower limit of the displacement.
  88555. * @param maxHeight is the upper limit of the displacement.
  88556. * @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.
  88557. * @param uvOffset is an optional vector2 used to offset UV.
  88558. * @param uvScale is an optional vector2 used to scale UV.
  88559. * @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.
  88560. * @returns the Mesh.
  88561. */
  88562. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88563. /**
  88564. * Modifies the mesh geometry according to a displacementMap buffer.
  88565. * 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.
  88566. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88567. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88568. * @param heightMapWidth is the width of the buffer image.
  88569. * @param heightMapHeight is the height of the buffer image.
  88570. * @param minHeight is the lower limit of the displacement.
  88571. * @param maxHeight is the upper limit of the displacement.
  88572. * @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.
  88573. * @param uvOffset is an optional vector2 used to offset UV.
  88574. * @param uvScale is an optional vector2 used to scale UV.
  88575. * @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.
  88576. * @returns the Mesh.
  88577. */
  88578. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88579. /**
  88580. * Modify the mesh to get a flat shading rendering.
  88581. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88582. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88583. * @returns current mesh
  88584. */
  88585. convertToFlatShadedMesh(): Mesh;
  88586. /**
  88587. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88588. * In other words, more vertices, no more indices and a single bigger VBO.
  88589. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88590. * @returns current mesh
  88591. */
  88592. convertToUnIndexedMesh(): Mesh;
  88593. /**
  88594. * Inverses facet orientations.
  88595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88596. * @param flipNormals will also inverts the normals
  88597. * @returns current mesh
  88598. */
  88599. flipFaces(flipNormals?: boolean): Mesh;
  88600. /**
  88601. * Increase the number of facets and hence vertices in a mesh
  88602. * Vertex normals are interpolated from existing vertex normals
  88603. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88604. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88605. */
  88606. increaseVertices(numberPerEdge: number): void;
  88607. /**
  88608. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88609. * This will undo any application of covertToFlatShadedMesh
  88610. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88611. */
  88612. forceSharedVertices(): void;
  88613. /** @hidden */
  88614. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88615. /** @hidden */
  88616. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88617. /**
  88618. * Creates a new InstancedMesh object from the mesh model.
  88619. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88620. * @param name defines the name of the new instance
  88621. * @returns a new InstancedMesh
  88622. */
  88623. createInstance(name: string): InstancedMesh;
  88624. /**
  88625. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88626. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88627. * @returns the current mesh
  88628. */
  88629. synchronizeInstances(): Mesh;
  88630. /**
  88631. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88632. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88633. * This should be used together with the simplification to avoid disappearing triangles.
  88634. * @param successCallback an optional success callback to be called after the optimization finished.
  88635. * @returns the current mesh
  88636. */
  88637. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88638. /**
  88639. * Serialize current mesh
  88640. * @param serializationObject defines the object which will receive the serialization data
  88641. */
  88642. serialize(serializationObject: any): void;
  88643. /** @hidden */
  88644. _syncGeometryWithMorphTargetManager(): void;
  88645. /** @hidden */
  88646. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88647. /**
  88648. * Returns a new Mesh object parsed from the source provided.
  88649. * @param parsedMesh is the source
  88650. * @param scene defines the hosting scene
  88651. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88652. * @returns a new Mesh
  88653. */
  88654. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88655. /**
  88656. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88657. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88658. * @param name defines the name of the mesh to create
  88659. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88660. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88661. * @param closePath creates a seam between the first and the last points of each path of the path array
  88662. * @param offset is taken in account only if the `pathArray` is containing a single path
  88663. * @param scene defines the hosting scene
  88664. * @param updatable defines if the mesh must be flagged as updatable
  88665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88666. * @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)
  88667. * @returns a new Mesh
  88668. */
  88669. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88670. /**
  88671. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88672. * @param name defines the name of the mesh to create
  88673. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88674. * @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
  88675. * @param scene defines the hosting scene
  88676. * @param updatable defines if the mesh must be flagged as updatable
  88677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88678. * @returns a new Mesh
  88679. */
  88680. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88681. /**
  88682. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88683. * @param name defines the name of the mesh to create
  88684. * @param size sets the size (float) of each box side (default 1)
  88685. * @param scene defines the hosting scene
  88686. * @param updatable defines if the mesh must be flagged as updatable
  88687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88688. * @returns a new Mesh
  88689. */
  88690. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88691. /**
  88692. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88693. * @param name defines the name of the mesh to create
  88694. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88695. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88696. * @param scene defines the hosting scene
  88697. * @param updatable defines if the mesh must be flagged as updatable
  88698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88699. * @returns a new Mesh
  88700. */
  88701. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88702. /**
  88703. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88704. * @param name defines the name of the mesh to create
  88705. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88706. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88707. * @param scene defines the hosting scene
  88708. * @returns a new Mesh
  88709. */
  88710. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88711. /**
  88712. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88713. * @param name defines the name of the mesh to create
  88714. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88715. * @param diameterTop set the top cap diameter (floats, default 1)
  88716. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88717. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88718. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88719. * @param scene defines the hosting scene
  88720. * @param updatable defines if the mesh must be flagged as updatable
  88721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88722. * @returns a new Mesh
  88723. */
  88724. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88725. /**
  88726. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88727. * @param name defines the name of the mesh to create
  88728. * @param diameter sets the diameter size (float) of the torus (default 1)
  88729. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88730. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88731. * @param scene defines the hosting scene
  88732. * @param updatable defines if the mesh must be flagged as updatable
  88733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88734. * @returns a new Mesh
  88735. */
  88736. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88737. /**
  88738. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88739. * @param name defines the name of the mesh to create
  88740. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88741. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88742. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88743. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88744. * @param p the number of windings on X axis (positive integers, default 2)
  88745. * @param q the number of windings on Y axis (positive integers, default 3)
  88746. * @param scene defines the hosting scene
  88747. * @param updatable defines if the mesh must be flagged as updatable
  88748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88749. * @returns a new Mesh
  88750. */
  88751. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88752. /**
  88753. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88754. * @param name defines the name of the mesh to create
  88755. * @param points is an array successive Vector3
  88756. * @param scene defines the hosting scene
  88757. * @param updatable defines if the mesh must be flagged as updatable
  88758. * @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).
  88759. * @returns a new Mesh
  88760. */
  88761. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88762. /**
  88763. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88764. * @param name defines the name of the mesh to create
  88765. * @param points is an array successive Vector3
  88766. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88767. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88768. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88769. * @param scene defines the hosting scene
  88770. * @param updatable defines if the mesh must be flagged as updatable
  88771. * @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)
  88772. * @returns a new Mesh
  88773. */
  88774. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88775. /**
  88776. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88777. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88778. * 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.
  88779. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88780. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88781. * Remember you can only change the shape positions, not their number when updating a polygon.
  88782. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88783. * @param name defines the name of the mesh to create
  88784. * @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
  88785. * @param scene defines the hosting scene
  88786. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88787. * @param updatable defines if the mesh must be flagged as updatable
  88788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88789. * @param earcutInjection can be used to inject your own earcut reference
  88790. * @returns a new Mesh
  88791. */
  88792. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88793. /**
  88794. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88796. * @param name defines the name of the mesh to create
  88797. * @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
  88798. * @param depth defines the height of extrusion
  88799. * @param scene defines the hosting scene
  88800. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88801. * @param updatable defines if the mesh must be flagged as updatable
  88802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88803. * @param earcutInjection can be used to inject your own earcut reference
  88804. * @returns a new Mesh
  88805. */
  88806. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88807. /**
  88808. * Creates an extruded shape mesh.
  88809. * 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
  88810. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88811. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88812. * @param name defines the name of the mesh to create
  88813. * @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
  88814. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88815. * @param scale is the value to scale the shape
  88816. * @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
  88817. * @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
  88818. * @param scene defines the hosting scene
  88819. * @param updatable defines if the mesh must be flagged as updatable
  88820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88821. * @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)
  88822. * @returns a new Mesh
  88823. */
  88824. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88825. /**
  88826. * Creates an custom extruded shape mesh.
  88827. * The custom extrusion is a parametric shape.
  88828. * It has no predefined shape. Its final shape will depend on the input parameters.
  88829. * Please consider using the same method from the MeshBuilder class instead
  88830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88831. * @param name defines the name of the mesh to create
  88832. * @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
  88833. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88834. * @param scaleFunction is a custom Javascript function called on each path point
  88835. * @param rotationFunction is a custom Javascript function called on each path point
  88836. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88837. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88838. * @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
  88839. * @param scene defines the hosting scene
  88840. * @param updatable defines if the mesh must be flagged as updatable
  88841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88842. * @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)
  88843. * @returns a new Mesh
  88844. */
  88845. 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;
  88846. /**
  88847. * Creates lathe mesh.
  88848. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88849. * Please consider using the same method from the MeshBuilder class instead
  88850. * @param name defines the name of the mesh to create
  88851. * @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
  88852. * @param radius is the radius value of the lathe
  88853. * @param tessellation is the side number of the lathe.
  88854. * @param scene defines the hosting scene
  88855. * @param updatable defines if the mesh must be flagged as updatable
  88856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88857. * @returns a new Mesh
  88858. */
  88859. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88860. /**
  88861. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88862. * @param name defines the name of the mesh to create
  88863. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88864. * @param scene defines the hosting scene
  88865. * @param updatable defines if the mesh must be flagged as updatable
  88866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88867. * @returns a new Mesh
  88868. */
  88869. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88870. /**
  88871. * Creates a ground mesh.
  88872. * Please consider using the same method from the MeshBuilder class instead
  88873. * @param name defines the name of the mesh to create
  88874. * @param width set the width of the ground
  88875. * @param height set the height of the ground
  88876. * @param subdivisions sets the number of subdivisions per side
  88877. * @param scene defines the hosting scene
  88878. * @param updatable defines if the mesh must be flagged as updatable
  88879. * @returns a new Mesh
  88880. */
  88881. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88882. /**
  88883. * Creates a tiled ground mesh.
  88884. * Please consider using the same method from the MeshBuilder class instead
  88885. * @param name defines the name of the mesh to create
  88886. * @param xmin set the ground minimum X coordinate
  88887. * @param zmin set the ground minimum Y coordinate
  88888. * @param xmax set the ground maximum X coordinate
  88889. * @param zmax set the ground maximum Z coordinate
  88890. * @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
  88891. * @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
  88892. * @param scene defines the hosting scene
  88893. * @param updatable defines if the mesh must be flagged as updatable
  88894. * @returns a new Mesh
  88895. */
  88896. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88897. w: number;
  88898. h: number;
  88899. }, precision: {
  88900. w: number;
  88901. h: number;
  88902. }, scene: Scene, updatable?: boolean): Mesh;
  88903. /**
  88904. * Creates a ground mesh from a height map.
  88905. * Please consider using the same method from the MeshBuilder class instead
  88906. * @see http://doc.babylonjs.com/babylon101/height_map
  88907. * @param name defines the name of the mesh to create
  88908. * @param url sets the URL of the height map image resource
  88909. * @param width set the ground width size
  88910. * @param height set the ground height size
  88911. * @param subdivisions sets the number of subdivision per side
  88912. * @param minHeight is the minimum altitude on the ground
  88913. * @param maxHeight is the maximum altitude on the ground
  88914. * @param scene defines the hosting scene
  88915. * @param updatable defines if the mesh must be flagged as updatable
  88916. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88917. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88918. * @returns a new Mesh
  88919. */
  88920. 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;
  88921. /**
  88922. * Creates a tube mesh.
  88923. * The tube is a parametric shape.
  88924. * It has no predefined shape. Its final shape will depend on the input parameters.
  88925. * Please consider using the same method from the MeshBuilder class instead
  88926. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88927. * @param name defines the name of the mesh to create
  88928. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88929. * @param radius sets the tube radius size
  88930. * @param tessellation is the number of sides on the tubular surface
  88931. * @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
  88932. * @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
  88933. * @param scene defines the hosting scene
  88934. * @param updatable defines if the mesh must be flagged as updatable
  88935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88936. * @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)
  88937. * @returns a new Mesh
  88938. */
  88939. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88940. (i: number, distance: number): number;
  88941. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88942. /**
  88943. * Creates a polyhedron mesh.
  88944. * Please consider using the same method from the MeshBuilder class instead.
  88945. * * 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
  88946. * * The parameter `size` (positive float, default 1) sets the polygon size
  88947. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88948. * * 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`
  88949. * * 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
  88950. * * 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)`)
  88951. * * 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
  88952. * * 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
  88953. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88954. * * If you create a double-sided mesh, you can choose what parts of 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
  88955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88956. * @param name defines the name of the mesh to create
  88957. * @param options defines the options used to create the mesh
  88958. * @param scene defines the hosting scene
  88959. * @returns a new Mesh
  88960. */
  88961. static CreatePolyhedron(name: string, options: {
  88962. type?: number;
  88963. size?: number;
  88964. sizeX?: number;
  88965. sizeY?: number;
  88966. sizeZ?: number;
  88967. custom?: any;
  88968. faceUV?: Vector4[];
  88969. faceColors?: Color4[];
  88970. updatable?: boolean;
  88971. sideOrientation?: number;
  88972. }, scene: Scene): Mesh;
  88973. /**
  88974. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88975. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88976. * * 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`)
  88977. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88978. * * 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
  88979. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88980. * * If you create a double-sided mesh, you can choose what parts of 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
  88981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88982. * @param name defines the name of the mesh
  88983. * @param options defines the options used to create the mesh
  88984. * @param scene defines the hosting scene
  88985. * @returns a new Mesh
  88986. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88987. */
  88988. static CreateIcoSphere(name: string, options: {
  88989. radius?: number;
  88990. flat?: boolean;
  88991. subdivisions?: number;
  88992. sideOrientation?: number;
  88993. updatable?: boolean;
  88994. }, scene: Scene): Mesh;
  88995. /**
  88996. * Creates a decal mesh.
  88997. * Please consider using the same method from the MeshBuilder class instead.
  88998. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88999. * @param name defines the name of the mesh
  89000. * @param sourceMesh defines the mesh receiving the decal
  89001. * @param position sets the position of the decal in world coordinates
  89002. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89003. * @param size sets the decal scaling
  89004. * @param angle sets the angle to rotate the decal
  89005. * @returns a new Mesh
  89006. */
  89007. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89008. /**
  89009. * Prepare internal position array for software CPU skinning
  89010. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89011. */
  89012. setPositionsForCPUSkinning(): Float32Array;
  89013. /**
  89014. * Prepare internal normal array for software CPU skinning
  89015. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89016. */
  89017. setNormalsForCPUSkinning(): Float32Array;
  89018. /**
  89019. * Updates the vertex buffer by applying transformation from the bones
  89020. * @param skeleton defines the skeleton to apply to current mesh
  89021. * @returns the current mesh
  89022. */
  89023. applySkeleton(skeleton: Skeleton): Mesh;
  89024. /**
  89025. * 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
  89026. * @param meshes defines the list of meshes to scan
  89027. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89028. */
  89029. static MinMax(meshes: AbstractMesh[]): {
  89030. min: Vector3;
  89031. max: Vector3;
  89032. };
  89033. /**
  89034. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89035. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89036. * @returns a vector3
  89037. */
  89038. static Center(meshesOrMinMaxVector: {
  89039. min: Vector3;
  89040. max: Vector3;
  89041. } | AbstractMesh[]): Vector3;
  89042. /**
  89043. * Merge the array of meshes into a single mesh for performance reasons.
  89044. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89045. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89046. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89047. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89048. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89049. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89050. * @returns a new mesh
  89051. */
  89052. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89053. /** @hidden */
  89054. addInstance(instance: InstancedMesh): void;
  89055. /** @hidden */
  89056. removeInstance(instance: InstancedMesh): void;
  89057. }
  89058. }
  89059. declare module BABYLON {
  89060. /**
  89061. * This is the base class of all the camera used in the application.
  89062. * @see http://doc.babylonjs.com/features/cameras
  89063. */
  89064. export class Camera extends Node {
  89065. /** @hidden */
  89066. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89067. /**
  89068. * This is the default projection mode used by the cameras.
  89069. * It helps recreating a feeling of perspective and better appreciate depth.
  89070. * This is the best way to simulate real life cameras.
  89071. */
  89072. static readonly PERSPECTIVE_CAMERA: number;
  89073. /**
  89074. * This helps creating camera with an orthographic mode.
  89075. * 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.
  89076. */
  89077. static readonly ORTHOGRAPHIC_CAMERA: number;
  89078. /**
  89079. * This is the default FOV mode for perspective cameras.
  89080. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89081. */
  89082. static readonly FOVMODE_VERTICAL_FIXED: number;
  89083. /**
  89084. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89085. */
  89086. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89087. /**
  89088. * This specifies ther is no need for a camera rig.
  89089. * Basically only one eye is rendered corresponding to the camera.
  89090. */
  89091. static readonly RIG_MODE_NONE: number;
  89092. /**
  89093. * Simulates a camera Rig with one blue eye and one red eye.
  89094. * This can be use with 3d blue and red glasses.
  89095. */
  89096. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89097. /**
  89098. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89099. */
  89100. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89101. /**
  89102. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89103. */
  89104. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89105. /**
  89106. * Defines that both eyes of the camera will be rendered over under each other.
  89107. */
  89108. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89109. /**
  89110. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89111. */
  89112. static readonly RIG_MODE_VR: number;
  89113. /**
  89114. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89115. */
  89116. static readonly RIG_MODE_WEBVR: number;
  89117. /**
  89118. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89119. */
  89120. static readonly RIG_MODE_CUSTOM: number;
  89121. /**
  89122. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89123. */
  89124. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89125. /**
  89126. * Define the input manager associated with the camera.
  89127. */
  89128. inputs: CameraInputsManager<Camera>;
  89129. /** @hidden */
  89130. _position: Vector3;
  89131. /**
  89132. * Define the current local position of the camera in the scene
  89133. */
  89134. position: Vector3;
  89135. /**
  89136. * The vector the camera should consider as up.
  89137. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89138. */
  89139. upVector: Vector3;
  89140. /**
  89141. * Define the current limit on the left side for an orthographic camera
  89142. * In scene unit
  89143. */
  89144. orthoLeft: Nullable<number>;
  89145. /**
  89146. * Define the current limit on the right side for an orthographic camera
  89147. * In scene unit
  89148. */
  89149. orthoRight: Nullable<number>;
  89150. /**
  89151. * Define the current limit on the bottom side for an orthographic camera
  89152. * In scene unit
  89153. */
  89154. orthoBottom: Nullable<number>;
  89155. /**
  89156. * Define the current limit on the top side for an orthographic camera
  89157. * In scene unit
  89158. */
  89159. orthoTop: Nullable<number>;
  89160. /**
  89161. * Field Of View is set in Radians. (default is 0.8)
  89162. */
  89163. fov: number;
  89164. /**
  89165. * Define the minimum distance the camera can see from.
  89166. * This is important to note that the depth buffer are not infinite and the closer it starts
  89167. * the more your scene might encounter depth fighting issue.
  89168. */
  89169. minZ: number;
  89170. /**
  89171. * Define the maximum distance the camera can see to.
  89172. * This is important to note that the depth buffer are not infinite and the further it end
  89173. * the more your scene might encounter depth fighting issue.
  89174. */
  89175. maxZ: number;
  89176. /**
  89177. * Define the default inertia of the camera.
  89178. * This helps giving a smooth feeling to the camera movement.
  89179. */
  89180. inertia: number;
  89181. /**
  89182. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89183. */
  89184. mode: number;
  89185. /**
  89186. * Define wether the camera is intermediate.
  89187. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89188. */
  89189. isIntermediate: boolean;
  89190. /**
  89191. * Define the viewport of the camera.
  89192. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89193. */
  89194. viewport: Viewport;
  89195. /**
  89196. * Restricts the camera to viewing objects with the same layerMask.
  89197. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89198. */
  89199. layerMask: number;
  89200. /**
  89201. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89202. */
  89203. fovMode: number;
  89204. /**
  89205. * Rig mode of the camera.
  89206. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89207. * This is normally controlled byt the camera themselves as internal use.
  89208. */
  89209. cameraRigMode: number;
  89210. /**
  89211. * Defines the distance between both "eyes" in case of a RIG
  89212. */
  89213. interaxialDistance: number;
  89214. /**
  89215. * Defines if stereoscopic rendering is done side by side or over under.
  89216. */
  89217. isStereoscopicSideBySide: boolean;
  89218. /**
  89219. * 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
  89220. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89221. * else in the scene. (Eg. security camera)
  89222. *
  89223. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  89224. */
  89225. customRenderTargets: RenderTargetTexture[];
  89226. /**
  89227. * When set, the camera will render to this render target instead of the default canvas
  89228. *
  89229. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89230. */
  89231. outputRenderTarget: Nullable<RenderTargetTexture>;
  89232. /**
  89233. * Observable triggered when the camera view matrix has changed.
  89234. */
  89235. onViewMatrixChangedObservable: Observable<Camera>;
  89236. /**
  89237. * Observable triggered when the camera Projection matrix has changed.
  89238. */
  89239. onProjectionMatrixChangedObservable: Observable<Camera>;
  89240. /**
  89241. * Observable triggered when the inputs have been processed.
  89242. */
  89243. onAfterCheckInputsObservable: Observable<Camera>;
  89244. /**
  89245. * Observable triggered when reset has been called and applied to the camera.
  89246. */
  89247. onRestoreStateObservable: Observable<Camera>;
  89248. /** @hidden */
  89249. _cameraRigParams: any;
  89250. /** @hidden */
  89251. _rigCameras: Camera[];
  89252. /** @hidden */
  89253. _rigPostProcess: Nullable<PostProcess>;
  89254. protected _webvrViewMatrix: Matrix;
  89255. /** @hidden */
  89256. _skipRendering: boolean;
  89257. /** @hidden */
  89258. _projectionMatrix: Matrix;
  89259. /** @hidden */
  89260. _postProcesses: Nullable<PostProcess>[];
  89261. /** @hidden */
  89262. _activeMeshes: SmartArray<AbstractMesh>;
  89263. protected _globalPosition: Vector3;
  89264. /** @hidden */
  89265. _computedViewMatrix: Matrix;
  89266. private _doNotComputeProjectionMatrix;
  89267. private _transformMatrix;
  89268. private _frustumPlanes;
  89269. private _refreshFrustumPlanes;
  89270. private _storedFov;
  89271. private _stateStored;
  89272. /**
  89273. * Instantiates a new camera object.
  89274. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89275. * @see http://doc.babylonjs.com/features/cameras
  89276. * @param name Defines the name of the camera in the scene
  89277. * @param position Defines the position of the camera
  89278. * @param scene Defines the scene the camera belongs too
  89279. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89280. */
  89281. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89282. /**
  89283. * Store current camera state (fov, position, etc..)
  89284. * @returns the camera
  89285. */
  89286. storeState(): Camera;
  89287. /**
  89288. * Restores the camera state values if it has been stored. You must call storeState() first
  89289. */
  89290. protected _restoreStateValues(): boolean;
  89291. /**
  89292. * Restored camera state. You must call storeState() first.
  89293. * @returns true if restored and false otherwise
  89294. */
  89295. restoreState(): boolean;
  89296. /**
  89297. * Gets the class name of the camera.
  89298. * @returns the class name
  89299. */
  89300. getClassName(): string;
  89301. /** @hidden */
  89302. readonly _isCamera: boolean;
  89303. /**
  89304. * Gets a string representation of the camera useful for debug purpose.
  89305. * @param fullDetails Defines that a more verboe level of logging is required
  89306. * @returns the string representation
  89307. */
  89308. toString(fullDetails?: boolean): string;
  89309. /**
  89310. * Gets the current world space position of the camera.
  89311. */
  89312. readonly globalPosition: Vector3;
  89313. /**
  89314. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89315. * @returns the active meshe list
  89316. */
  89317. getActiveMeshes(): SmartArray<AbstractMesh>;
  89318. /**
  89319. * Check wether a mesh is part of the current active mesh list of the camera
  89320. * @param mesh Defines the mesh to check
  89321. * @returns true if active, false otherwise
  89322. */
  89323. isActiveMesh(mesh: Mesh): boolean;
  89324. /**
  89325. * Is this camera ready to be used/rendered
  89326. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89327. * @return true if the camera is ready
  89328. */
  89329. isReady(completeCheck?: boolean): boolean;
  89330. /** @hidden */
  89331. _initCache(): void;
  89332. /** @hidden */
  89333. _updateCache(ignoreParentClass?: boolean): void;
  89334. /** @hidden */
  89335. _isSynchronized(): boolean;
  89336. /** @hidden */
  89337. _isSynchronizedViewMatrix(): boolean;
  89338. /** @hidden */
  89339. _isSynchronizedProjectionMatrix(): boolean;
  89340. /**
  89341. * Attach the input controls to a specific dom element to get the input from.
  89342. * @param element Defines the element the controls should be listened from
  89343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89344. */
  89345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89346. /**
  89347. * Detach the current controls from the specified dom element.
  89348. * @param element Defines the element to stop listening the inputs from
  89349. */
  89350. detachControl(element: HTMLElement): void;
  89351. /**
  89352. * Update the camera state according to the different inputs gathered during the frame.
  89353. */
  89354. update(): void;
  89355. /** @hidden */
  89356. _checkInputs(): void;
  89357. /** @hidden */
  89358. readonly rigCameras: Camera[];
  89359. /**
  89360. * Gets the post process used by the rig cameras
  89361. */
  89362. readonly rigPostProcess: Nullable<PostProcess>;
  89363. /**
  89364. * Internal, gets the first post proces.
  89365. * @returns the first post process to be run on this camera.
  89366. */
  89367. _getFirstPostProcess(): Nullable<PostProcess>;
  89368. private _cascadePostProcessesToRigCams;
  89369. /**
  89370. * Attach a post process to the camera.
  89371. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89372. * @param postProcess The post process to attach to the camera
  89373. * @param insertAt The position of the post process in case several of them are in use in the scene
  89374. * @returns the position the post process has been inserted at
  89375. */
  89376. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89377. /**
  89378. * Detach a post process to the camera.
  89379. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89380. * @param postProcess The post process to detach from the camera
  89381. */
  89382. detachPostProcess(postProcess: PostProcess): void;
  89383. /**
  89384. * Gets the current world matrix of the camera
  89385. */
  89386. getWorldMatrix(): Matrix;
  89387. /** @hidden */
  89388. _getViewMatrix(): Matrix;
  89389. /**
  89390. * Gets the current view matrix of the camera.
  89391. * @param force forces the camera to recompute the matrix without looking at the cached state
  89392. * @returns the view matrix
  89393. */
  89394. getViewMatrix(force?: boolean): Matrix;
  89395. /**
  89396. * Freeze the projection matrix.
  89397. * It will prevent the cache check of the camera projection compute and can speed up perf
  89398. * if no parameter of the camera are meant to change
  89399. * @param projection Defines manually a projection if necessary
  89400. */
  89401. freezeProjectionMatrix(projection?: Matrix): void;
  89402. /**
  89403. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89404. */
  89405. unfreezeProjectionMatrix(): void;
  89406. /**
  89407. * Gets the current projection matrix of the camera.
  89408. * @param force forces the camera to recompute the matrix without looking at the cached state
  89409. * @returns the projection matrix
  89410. */
  89411. getProjectionMatrix(force?: boolean): Matrix;
  89412. /**
  89413. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89414. * @returns a Matrix
  89415. */
  89416. getTransformationMatrix(): Matrix;
  89417. private _updateFrustumPlanes;
  89418. /**
  89419. * Checks if a cullable object (mesh...) is in the camera frustum
  89420. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89421. * @param target The object to check
  89422. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89423. * @returns true if the object is in frustum otherwise false
  89424. */
  89425. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89426. /**
  89427. * Checks if a cullable object (mesh...) is in the camera frustum
  89428. * Unlike isInFrustum this cheks the full bounding box
  89429. * @param target The object to check
  89430. * @returns true if the object is in frustum otherwise false
  89431. */
  89432. isCompletelyInFrustum(target: ICullable): boolean;
  89433. /**
  89434. * Gets a ray in the forward direction from the camera.
  89435. * @param length Defines the length of the ray to create
  89436. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89437. * @param origin Defines the start point of the ray which defaults to the camera position
  89438. * @returns the forward ray
  89439. */
  89440. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89441. /**
  89442. * Releases resources associated with this node.
  89443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89445. */
  89446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89447. /** @hidden */
  89448. _isLeftCamera: boolean;
  89449. /**
  89450. * Gets the left camera of a rig setup in case of Rigged Camera
  89451. */
  89452. readonly isLeftCamera: boolean;
  89453. /** @hidden */
  89454. _isRightCamera: boolean;
  89455. /**
  89456. * Gets the right camera of a rig setup in case of Rigged Camera
  89457. */
  89458. readonly isRightCamera: boolean;
  89459. /**
  89460. * Gets the left camera of a rig setup in case of Rigged Camera
  89461. */
  89462. readonly leftCamera: Nullable<FreeCamera>;
  89463. /**
  89464. * Gets the right camera of a rig setup in case of Rigged Camera
  89465. */
  89466. readonly rightCamera: Nullable<FreeCamera>;
  89467. /**
  89468. * Gets the left camera target of a rig setup in case of Rigged Camera
  89469. * @returns the target position
  89470. */
  89471. getLeftTarget(): Nullable<Vector3>;
  89472. /**
  89473. * Gets the right camera target of a rig setup in case of Rigged Camera
  89474. * @returns the target position
  89475. */
  89476. getRightTarget(): Nullable<Vector3>;
  89477. /**
  89478. * @hidden
  89479. */
  89480. setCameraRigMode(mode: number, rigParams: any): void;
  89481. /** @hidden */
  89482. static _setStereoscopicRigMode(camera: Camera): void;
  89483. /** @hidden */
  89484. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89485. /** @hidden */
  89486. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89487. /** @hidden */
  89488. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89489. /** @hidden */
  89490. _getVRProjectionMatrix(): Matrix;
  89491. protected _updateCameraRotationMatrix(): void;
  89492. protected _updateWebVRCameraRotationMatrix(): void;
  89493. /**
  89494. * This function MUST be overwritten by the different WebVR cameras available.
  89495. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89496. * @hidden
  89497. */
  89498. _getWebVRProjectionMatrix(): Matrix;
  89499. /**
  89500. * This function MUST be overwritten by the different WebVR cameras available.
  89501. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89502. * @hidden
  89503. */
  89504. _getWebVRViewMatrix(): Matrix;
  89505. /** @hidden */
  89506. setCameraRigParameter(name: string, value: any): void;
  89507. /**
  89508. * needs to be overridden by children so sub has required properties to be copied
  89509. * @hidden
  89510. */
  89511. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89512. /**
  89513. * May need to be overridden by children
  89514. * @hidden
  89515. */
  89516. _updateRigCameras(): void;
  89517. /** @hidden */
  89518. _setupInputs(): void;
  89519. /**
  89520. * Serialiaze the camera setup to a json represention
  89521. * @returns the JSON representation
  89522. */
  89523. serialize(): any;
  89524. /**
  89525. * Clones the current camera.
  89526. * @param name The cloned camera name
  89527. * @returns the cloned camera
  89528. */
  89529. clone(name: string): Camera;
  89530. /**
  89531. * Gets the direction of the camera relative to a given local axis.
  89532. * @param localAxis Defines the reference axis to provide a relative direction.
  89533. * @return the direction
  89534. */
  89535. getDirection(localAxis: Vector3): Vector3;
  89536. /**
  89537. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89538. * @param localAxis Defines the reference axis to provide a relative direction.
  89539. * @param result Defines the vector to store the result in
  89540. */
  89541. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89542. /**
  89543. * Gets a camera constructor for a given camera type
  89544. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89545. * @param name The name of the camera the result will be able to instantiate
  89546. * @param scene The scene the result will construct the camera in
  89547. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89548. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89549. * @returns a factory method to construc the camera
  89550. */
  89551. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89552. /**
  89553. * Compute the world matrix of the camera.
  89554. * @returns the camera workd matrix
  89555. */
  89556. computeWorldMatrix(): Matrix;
  89557. /**
  89558. * Parse a JSON and creates the camera from the parsed information
  89559. * @param parsedCamera The JSON to parse
  89560. * @param scene The scene to instantiate the camera in
  89561. * @returns the newly constructed camera
  89562. */
  89563. static Parse(parsedCamera: any, scene: Scene): Camera;
  89564. }
  89565. }
  89566. declare module BABYLON {
  89567. /**
  89568. * Class containing static functions to help procedurally build meshes
  89569. */
  89570. export class DiscBuilder {
  89571. /**
  89572. * Creates a plane polygonal mesh. By default, this is a disc
  89573. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89574. * * 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
  89575. * * 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
  89576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89579. * @param name defines the name of the mesh
  89580. * @param options defines the options used to create the mesh
  89581. * @param scene defines the hosting scene
  89582. * @returns the plane polygonal mesh
  89583. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89584. */
  89585. static CreateDisc(name: string, options: {
  89586. radius?: number;
  89587. tessellation?: number;
  89588. arc?: number;
  89589. updatable?: boolean;
  89590. sideOrientation?: number;
  89591. frontUVs?: Vector4;
  89592. backUVs?: Vector4;
  89593. }, scene?: Nullable<Scene>): Mesh;
  89594. }
  89595. }
  89596. declare module BABYLON {
  89597. /**
  89598. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89599. *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.
  89600. * The SPS is also a particle system. It provides some methods to manage the particles.
  89601. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89602. *
  89603. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89604. */
  89605. export class SolidParticleSystem implements IDisposable {
  89606. /**
  89607. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89608. * Example : var p = SPS.particles[i];
  89609. */
  89610. particles: SolidParticle[];
  89611. /**
  89612. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89613. */
  89614. nbParticles: number;
  89615. /**
  89616. * If the particles must ever face the camera (default false). Useful for planar particles.
  89617. */
  89618. billboard: boolean;
  89619. /**
  89620. * Recompute normals when adding a shape
  89621. */
  89622. recomputeNormals: boolean;
  89623. /**
  89624. * This a counter ofr your own usage. It's not set by any SPS functions.
  89625. */
  89626. counter: number;
  89627. /**
  89628. * The SPS name. This name is also given to the underlying mesh.
  89629. */
  89630. name: string;
  89631. /**
  89632. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89633. */
  89634. mesh: Mesh;
  89635. /**
  89636. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89637. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89638. */
  89639. vars: any;
  89640. /**
  89641. * This array is populated when the SPS is set as 'pickable'.
  89642. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89643. * Each element of this array is an object `{idx: int, faceId: int}`.
  89644. * `idx` is the picked particle index in the `SPS.particles` array
  89645. * `faceId` is the picked face index counted within this particle.
  89646. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89647. */
  89648. pickedParticles: {
  89649. idx: number;
  89650. faceId: number;
  89651. }[];
  89652. /**
  89653. * This array is populated when `enableDepthSort` is set to true.
  89654. * Each element of this array is an instance of the class DepthSortedParticle.
  89655. */
  89656. depthSortedParticles: DepthSortedParticle[];
  89657. /**
  89658. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89659. * @hidden
  89660. */
  89661. _bSphereOnly: boolean;
  89662. /**
  89663. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89664. * @hidden
  89665. */
  89666. _bSphereRadiusFactor: number;
  89667. private _scene;
  89668. private _positions;
  89669. private _indices;
  89670. private _normals;
  89671. private _colors;
  89672. private _uvs;
  89673. private _indices32;
  89674. private _positions32;
  89675. private _normals32;
  89676. private _fixedNormal32;
  89677. private _colors32;
  89678. private _uvs32;
  89679. private _index;
  89680. private _updatable;
  89681. private _pickable;
  89682. private _isVisibilityBoxLocked;
  89683. private _alwaysVisible;
  89684. private _depthSort;
  89685. private _shapeCounter;
  89686. private _copy;
  89687. private _color;
  89688. private _computeParticleColor;
  89689. private _computeParticleTexture;
  89690. private _computeParticleRotation;
  89691. private _computeParticleVertex;
  89692. private _computeBoundingBox;
  89693. private _depthSortParticles;
  89694. private _camera;
  89695. private _mustUnrotateFixedNormals;
  89696. private _particlesIntersect;
  89697. private _needs32Bits;
  89698. /**
  89699. * Creates a SPS (Solid Particle System) object.
  89700. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89701. * @param scene (Scene) is the scene in which the SPS is added.
  89702. * @param options defines the options of the sps e.g.
  89703. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89704. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89705. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89706. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89707. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89708. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89709. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89710. */
  89711. constructor(name: string, scene: Scene, options?: {
  89712. updatable?: boolean;
  89713. isPickable?: boolean;
  89714. enableDepthSort?: boolean;
  89715. particleIntersection?: boolean;
  89716. boundingSphereOnly?: boolean;
  89717. bSphereRadiusFactor?: number;
  89718. });
  89719. /**
  89720. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89721. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89722. * @returns the created mesh
  89723. */
  89724. buildMesh(): Mesh;
  89725. /**
  89726. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89727. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89728. * Thus the particles generated from `digest()` have their property `position` set yet.
  89729. * @param mesh ( Mesh ) is the mesh to be digested
  89730. * @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
  89731. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89732. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89733. * @returns the current SPS
  89734. */
  89735. digest(mesh: Mesh, options?: {
  89736. facetNb?: number;
  89737. number?: number;
  89738. delta?: number;
  89739. }): SolidParticleSystem;
  89740. private _unrotateFixedNormals;
  89741. private _resetCopy;
  89742. private _meshBuilder;
  89743. private _posToShape;
  89744. private _uvsToShapeUV;
  89745. private _addParticle;
  89746. /**
  89747. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89748. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89749. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89750. * @param nb (positive integer) the number of particles to be created from this model
  89751. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89752. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89753. * @returns the number of shapes in the system
  89754. */
  89755. addShape(mesh: Mesh, nb: number, options?: {
  89756. positionFunction?: any;
  89757. vertexFunction?: any;
  89758. }): number;
  89759. private _rebuildParticle;
  89760. /**
  89761. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89762. * @returns the SPS.
  89763. */
  89764. rebuildMesh(): SolidParticleSystem;
  89765. /**
  89766. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89767. * This method calls `updateParticle()` for each particle of the SPS.
  89768. * For an animated SPS, it is usually called within the render loop.
  89769. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89770. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89771. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89772. * @returns the SPS.
  89773. */
  89774. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89775. /**
  89776. * Disposes the SPS.
  89777. */
  89778. dispose(): void;
  89779. /**
  89780. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89781. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89782. * @returns the SPS.
  89783. */
  89784. refreshVisibleSize(): SolidParticleSystem;
  89785. /**
  89786. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89787. * @param size the size (float) of the visibility box
  89788. * note : this doesn't lock the SPS mesh bounding box.
  89789. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89790. */
  89791. setVisibilityBox(size: number): void;
  89792. /**
  89793. * Gets whether the SPS as always visible or not
  89794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89795. */
  89796. /**
  89797. * Sets the SPS as always visible or not
  89798. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89799. */
  89800. isAlwaysVisible: boolean;
  89801. /**
  89802. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89804. */
  89805. /**
  89806. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89807. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89808. */
  89809. isVisibilityBoxLocked: boolean;
  89810. /**
  89811. * Tells to `setParticles()` to compute the particle rotations or not.
  89812. * Default value : true. The SPS is faster when it's set to false.
  89813. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89814. */
  89815. /**
  89816. * Gets if `setParticles()` computes the particle rotations or not.
  89817. * Default value : true. The SPS is faster when it's set to false.
  89818. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89819. */
  89820. computeParticleRotation: boolean;
  89821. /**
  89822. * Tells to `setParticles()` to compute the particle colors or not.
  89823. * Default value : true. The SPS is faster when it's set to false.
  89824. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89825. */
  89826. /**
  89827. * Gets if `setParticles()` computes the particle colors or not.
  89828. * Default value : true. The SPS is faster when it's set to false.
  89829. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89830. */
  89831. computeParticleColor: boolean;
  89832. /**
  89833. * Gets if `setParticles()` computes the particle textures or not.
  89834. * Default value : true. The SPS is faster when it's set to false.
  89835. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89836. */
  89837. computeParticleTexture: boolean;
  89838. /**
  89839. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89840. * Default value : false. The SPS is faster when it's set to false.
  89841. * Note : the particle custom vertex positions aren't stored values.
  89842. */
  89843. /**
  89844. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89845. * Default value : false. The SPS is faster when it's set to false.
  89846. * Note : the particle custom vertex positions aren't stored values.
  89847. */
  89848. computeParticleVertex: boolean;
  89849. /**
  89850. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89851. */
  89852. /**
  89853. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89854. */
  89855. computeBoundingBox: boolean;
  89856. /**
  89857. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89858. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89859. * Default : `true`
  89860. */
  89861. /**
  89862. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89863. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89864. * Default : `true`
  89865. */
  89866. depthSortParticles: boolean;
  89867. /**
  89868. * This function does nothing. It may be overwritten to set all the particle first values.
  89869. * The SPS doesn't call this function, you may have to call it by your own.
  89870. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89871. */
  89872. initParticles(): void;
  89873. /**
  89874. * This function does nothing. It may be overwritten to recycle a particle.
  89875. * The SPS doesn't call this function, you may have to call it by your own.
  89876. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89877. * @param particle The particle to recycle
  89878. * @returns the recycled particle
  89879. */
  89880. recycleParticle(particle: SolidParticle): SolidParticle;
  89881. /**
  89882. * Updates a particle : this function should be overwritten by the user.
  89883. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89885. * @example : just set a particle position or velocity and recycle conditions
  89886. * @param particle The particle to update
  89887. * @returns the updated particle
  89888. */
  89889. updateParticle(particle: SolidParticle): SolidParticle;
  89890. /**
  89891. * Updates a vertex of a particle : it can be overwritten by the user.
  89892. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89893. * @param particle the current particle
  89894. * @param vertex the current index of the current particle
  89895. * @param pt the index of the current vertex in the particle shape
  89896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89897. * @example : just set a vertex particle position
  89898. * @returns the updated vertex
  89899. */
  89900. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89901. /**
  89902. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89903. * This does nothing and may be overwritten by the user.
  89904. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89905. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89906. * @param update the boolean update value actually passed to setParticles()
  89907. */
  89908. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89909. /**
  89910. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89911. * This will be passed three parameters.
  89912. * This does nothing and may be overwritten by the user.
  89913. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89914. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89915. * @param update the boolean update value actually passed to setParticles()
  89916. */
  89917. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89918. }
  89919. }
  89920. declare module BABYLON {
  89921. /**
  89922. * Represents one particle of a solid particle system.
  89923. */
  89924. export class SolidParticle {
  89925. /**
  89926. * particle global index
  89927. */
  89928. idx: number;
  89929. /**
  89930. * The color of the particle
  89931. */
  89932. color: Nullable<Color4>;
  89933. /**
  89934. * The world space position of the particle.
  89935. */
  89936. position: Vector3;
  89937. /**
  89938. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89939. */
  89940. rotation: Vector3;
  89941. /**
  89942. * The world space rotation quaternion of the particle.
  89943. */
  89944. rotationQuaternion: Nullable<Quaternion>;
  89945. /**
  89946. * The scaling of the particle.
  89947. */
  89948. scaling: Vector3;
  89949. /**
  89950. * The uvs of the particle.
  89951. */
  89952. uvs: Vector4;
  89953. /**
  89954. * The current speed of the particle.
  89955. */
  89956. velocity: Vector3;
  89957. /**
  89958. * The pivot point in the particle local space.
  89959. */
  89960. pivot: Vector3;
  89961. /**
  89962. * Must the particle be translated from its pivot point in its local space ?
  89963. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89964. * Default : false
  89965. */
  89966. translateFromPivot: boolean;
  89967. /**
  89968. * Is the particle active or not ?
  89969. */
  89970. alive: boolean;
  89971. /**
  89972. * Is the particle visible or not ?
  89973. */
  89974. isVisible: boolean;
  89975. /**
  89976. * Index of this particle in the global "positions" array (Internal use)
  89977. * @hidden
  89978. */
  89979. _pos: number;
  89980. /**
  89981. * @hidden Index of this particle in the global "indices" array (Internal use)
  89982. */
  89983. _ind: number;
  89984. /**
  89985. * @hidden ModelShape of this particle (Internal use)
  89986. */
  89987. _model: ModelShape;
  89988. /**
  89989. * ModelShape id of this particle
  89990. */
  89991. shapeId: number;
  89992. /**
  89993. * Index of the particle in its shape id (Internal use)
  89994. */
  89995. idxInShape: number;
  89996. /**
  89997. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89998. */
  89999. _modelBoundingInfo: BoundingInfo;
  90000. /**
  90001. * @hidden Particle BoundingInfo object (Internal use)
  90002. */
  90003. _boundingInfo: BoundingInfo;
  90004. /**
  90005. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90006. */
  90007. _sps: SolidParticleSystem;
  90008. /**
  90009. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90010. */
  90011. _stillInvisible: boolean;
  90012. /**
  90013. * @hidden Last computed particle rotation matrix
  90014. */
  90015. _rotationMatrix: number[];
  90016. /**
  90017. * Parent particle Id, if any.
  90018. * Default null.
  90019. */
  90020. parentId: Nullable<number>;
  90021. /**
  90022. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90023. * The possible values are :
  90024. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90025. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90028. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90029. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90030. * */
  90031. cullingStrategy: number;
  90032. /**
  90033. * @hidden Internal global position in the SPS.
  90034. */
  90035. _globalPosition: Vector3;
  90036. /**
  90037. * Creates a Solid Particle object.
  90038. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90039. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90040. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90041. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90042. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90043. * @param shapeId (integer) is the model shape identifier in the SPS.
  90044. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90045. * @param sps defines the sps it is associated to
  90046. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90047. */
  90048. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90049. /**
  90050. * Legacy support, changed scale to scaling
  90051. */
  90052. /**
  90053. * Legacy support, changed scale to scaling
  90054. */
  90055. scale: Vector3;
  90056. /**
  90057. * Legacy support, changed quaternion to rotationQuaternion
  90058. */
  90059. /**
  90060. * Legacy support, changed quaternion to rotationQuaternion
  90061. */
  90062. quaternion: Nullable<Quaternion>;
  90063. /**
  90064. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90065. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90066. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90067. * @returns true if it intersects
  90068. */
  90069. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90070. /**
  90071. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90072. * A particle is in the frustum if its bounding box intersects the frustum
  90073. * @param frustumPlanes defines the frustum to test
  90074. * @returns true if the particle is in the frustum planes
  90075. */
  90076. isInFrustum(frustumPlanes: Plane[]): boolean;
  90077. /**
  90078. * get the rotation matrix of the particle
  90079. * @hidden
  90080. */
  90081. getRotationMatrix(m: Matrix): void;
  90082. }
  90083. /**
  90084. * Represents the shape of the model used by one particle of a solid particle system.
  90085. * SPS internal tool, don't use it manually.
  90086. */
  90087. export class ModelShape {
  90088. /**
  90089. * The shape id
  90090. * @hidden
  90091. */
  90092. shapeID: number;
  90093. /**
  90094. * flat array of model positions (internal use)
  90095. * @hidden
  90096. */
  90097. _shape: Vector3[];
  90098. /**
  90099. * flat array of model UVs (internal use)
  90100. * @hidden
  90101. */
  90102. _shapeUV: number[];
  90103. /**
  90104. * length of the shape in the model indices array (internal use)
  90105. * @hidden
  90106. */
  90107. _indicesLength: number;
  90108. /**
  90109. * Custom position function (internal use)
  90110. * @hidden
  90111. */
  90112. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90113. /**
  90114. * Custom vertex function (internal use)
  90115. * @hidden
  90116. */
  90117. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90118. /**
  90119. * 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.
  90120. * SPS internal tool, don't use it manually.
  90121. * @hidden
  90122. */
  90123. 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>);
  90124. }
  90125. /**
  90126. * Represents a Depth Sorted Particle in the solid particle system.
  90127. */
  90128. export class DepthSortedParticle {
  90129. /**
  90130. * Index of the particle in the "indices" array
  90131. */
  90132. ind: number;
  90133. /**
  90134. * Length of the particle shape in the "indices" array
  90135. */
  90136. indicesLength: number;
  90137. /**
  90138. * Squared distance from the particle to the camera
  90139. */
  90140. sqDistance: number;
  90141. }
  90142. }
  90143. declare module BABYLON {
  90144. /**
  90145. * @hidden
  90146. */
  90147. export class _MeshCollisionData {
  90148. _checkCollisions: boolean;
  90149. _collisionMask: number;
  90150. _collisionGroup: number;
  90151. _collider: Nullable<Collider>;
  90152. _oldPositionForCollisions: Vector3;
  90153. _diffPositionForCollisions: Vector3;
  90154. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90155. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90156. }
  90157. }
  90158. declare module BABYLON {
  90159. /** @hidden */
  90160. class _FacetDataStorage {
  90161. facetPositions: Vector3[];
  90162. facetNormals: Vector3[];
  90163. facetPartitioning: number[][];
  90164. facetNb: number;
  90165. partitioningSubdivisions: number;
  90166. partitioningBBoxRatio: number;
  90167. facetDataEnabled: boolean;
  90168. facetParameters: any;
  90169. bbSize: Vector3;
  90170. subDiv: {
  90171. max: number;
  90172. X: number;
  90173. Y: number;
  90174. Z: number;
  90175. };
  90176. facetDepthSort: boolean;
  90177. facetDepthSortEnabled: boolean;
  90178. depthSortedIndices: IndicesArray;
  90179. depthSortedFacets: {
  90180. ind: number;
  90181. sqDistance: number;
  90182. }[];
  90183. facetDepthSortFunction: (f1: {
  90184. ind: number;
  90185. sqDistance: number;
  90186. }, f2: {
  90187. ind: number;
  90188. sqDistance: number;
  90189. }) => number;
  90190. facetDepthSortFrom: Vector3;
  90191. facetDepthSortOrigin: Vector3;
  90192. invertedMatrix: Matrix;
  90193. }
  90194. /**
  90195. * @hidden
  90196. **/
  90197. class _InternalAbstractMeshDataInfo {
  90198. _hasVertexAlpha: boolean;
  90199. _useVertexColors: boolean;
  90200. _numBoneInfluencers: number;
  90201. _applyFog: boolean;
  90202. _receiveShadows: boolean;
  90203. _facetData: _FacetDataStorage;
  90204. _visibility: number;
  90205. _skeleton: Nullable<Skeleton>;
  90206. _layerMask: number;
  90207. _computeBonesUsingShaders: boolean;
  90208. _isActive: boolean;
  90209. _onlyForInstances: boolean;
  90210. _isActiveIntermediate: boolean;
  90211. _onlyForInstancesIntermediate: boolean;
  90212. }
  90213. /**
  90214. * Class used to store all common mesh properties
  90215. */
  90216. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90217. /** No occlusion */
  90218. static OCCLUSION_TYPE_NONE: number;
  90219. /** Occlusion set to optimisitic */
  90220. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90221. /** Occlusion set to strict */
  90222. static OCCLUSION_TYPE_STRICT: number;
  90223. /** Use an accurante occlusion algorithm */
  90224. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90225. /** Use a conservative occlusion algorithm */
  90226. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90227. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90228. * Test order :
  90229. * Is the bounding sphere outside the frustum ?
  90230. * If not, are the bounding box vertices outside the frustum ?
  90231. * It not, then the cullable object is in the frustum.
  90232. */
  90233. static readonly CULLINGSTRATEGY_STANDARD: number;
  90234. /** Culling strategy : Bounding Sphere Only.
  90235. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90236. * It's also less accurate than the standard because some not visible objects can still be selected.
  90237. * Test : is the bounding sphere outside the frustum ?
  90238. * If not, then the cullable object is in the frustum.
  90239. */
  90240. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90241. /** Culling strategy : Optimistic Inclusion.
  90242. * This in an inclusion test first, then the standard exclusion test.
  90243. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90244. * 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.
  90245. * Anyway, it's as accurate as the standard strategy.
  90246. * Test :
  90247. * Is the cullable object bounding sphere center in the frustum ?
  90248. * If not, apply the default culling strategy.
  90249. */
  90250. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90251. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90252. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90253. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90254. * 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.
  90255. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90256. * Test :
  90257. * Is the cullable object bounding sphere center in the frustum ?
  90258. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90259. */
  90260. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90261. /**
  90262. * No billboard
  90263. */
  90264. static readonly BILLBOARDMODE_NONE: number;
  90265. /** Billboard on X axis */
  90266. static readonly BILLBOARDMODE_X: number;
  90267. /** Billboard on Y axis */
  90268. static readonly BILLBOARDMODE_Y: number;
  90269. /** Billboard on Z axis */
  90270. static readonly BILLBOARDMODE_Z: number;
  90271. /** Billboard on all axes */
  90272. static readonly BILLBOARDMODE_ALL: number;
  90273. /** Billboard on using position instead of orientation */
  90274. static readonly BILLBOARDMODE_USE_POSITION: number;
  90275. /** @hidden */
  90276. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90277. /**
  90278. * The culling strategy to use to check whether the mesh must be rendered or not.
  90279. * This value can be changed at any time and will be used on the next render mesh selection.
  90280. * The possible values are :
  90281. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90282. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90283. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90284. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90285. * Please read each static variable documentation to get details about the culling process.
  90286. * */
  90287. cullingStrategy: number;
  90288. /**
  90289. * Gets the number of facets in the mesh
  90290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90291. */
  90292. readonly facetNb: number;
  90293. /**
  90294. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90296. */
  90297. partitioningSubdivisions: number;
  90298. /**
  90299. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90300. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90302. */
  90303. partitioningBBoxRatio: number;
  90304. /**
  90305. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90306. * Works only for updatable meshes.
  90307. * Doesn't work with multi-materials
  90308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90309. */
  90310. mustDepthSortFacets: boolean;
  90311. /**
  90312. * The location (Vector3) where the facet depth sort must be computed from.
  90313. * By default, the active camera position.
  90314. * Used only when facet depth sort is enabled
  90315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90316. */
  90317. facetDepthSortFrom: Vector3;
  90318. /**
  90319. * gets a boolean indicating if facetData is enabled
  90320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90321. */
  90322. readonly isFacetDataEnabled: boolean;
  90323. /** @hidden */
  90324. _updateNonUniformScalingState(value: boolean): boolean;
  90325. /**
  90326. * An event triggered when this mesh collides with another one
  90327. */
  90328. onCollideObservable: Observable<AbstractMesh>;
  90329. /** Set a function to call when this mesh collides with another one */
  90330. onCollide: () => void;
  90331. /**
  90332. * An event triggered when the collision's position changes
  90333. */
  90334. onCollisionPositionChangeObservable: Observable<Vector3>;
  90335. /** Set a function to call when the collision's position changes */
  90336. onCollisionPositionChange: () => void;
  90337. /**
  90338. * An event triggered when material is changed
  90339. */
  90340. onMaterialChangedObservable: Observable<AbstractMesh>;
  90341. /**
  90342. * Gets or sets the orientation for POV movement & rotation
  90343. */
  90344. definedFacingForward: boolean;
  90345. /** @hidden */
  90346. _occlusionQuery: Nullable<WebGLQuery>;
  90347. /** @hidden */
  90348. _renderingGroup: Nullable<RenderingGroup>;
  90349. /**
  90350. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90351. */
  90352. /**
  90353. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90354. */
  90355. visibility: number;
  90356. /** Gets or sets the alpha index used to sort transparent meshes
  90357. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90358. */
  90359. alphaIndex: number;
  90360. /**
  90361. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90362. */
  90363. isVisible: boolean;
  90364. /**
  90365. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90366. */
  90367. isPickable: boolean;
  90368. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90369. showSubMeshesBoundingBox: boolean;
  90370. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90371. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90372. */
  90373. isBlocker: boolean;
  90374. /**
  90375. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90376. */
  90377. enablePointerMoveEvents: boolean;
  90378. /**
  90379. * Specifies the rendering group id for this mesh (0 by default)
  90380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90381. */
  90382. renderingGroupId: number;
  90383. private _material;
  90384. /** Gets or sets current material */
  90385. material: Nullable<Material>;
  90386. /**
  90387. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90388. * @see http://doc.babylonjs.com/babylon101/shadows
  90389. */
  90390. receiveShadows: boolean;
  90391. /** Defines color to use when rendering outline */
  90392. outlineColor: Color3;
  90393. /** Define width to use when rendering outline */
  90394. outlineWidth: number;
  90395. /** Defines color to use when rendering overlay */
  90396. overlayColor: Color3;
  90397. /** Defines alpha to use when rendering overlay */
  90398. overlayAlpha: number;
  90399. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90400. hasVertexAlpha: boolean;
  90401. /** 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) */
  90402. useVertexColors: boolean;
  90403. /**
  90404. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90405. */
  90406. computeBonesUsingShaders: boolean;
  90407. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90408. numBoneInfluencers: number;
  90409. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90410. applyFog: boolean;
  90411. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90412. useOctreeForRenderingSelection: boolean;
  90413. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90414. useOctreeForPicking: boolean;
  90415. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90416. useOctreeForCollisions: boolean;
  90417. /**
  90418. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90419. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90420. */
  90421. layerMask: number;
  90422. /**
  90423. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90424. */
  90425. alwaysSelectAsActiveMesh: boolean;
  90426. /**
  90427. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90428. */
  90429. doNotSyncBoundingInfo: boolean;
  90430. /**
  90431. * Gets or sets the current action manager
  90432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90433. */
  90434. actionManager: Nullable<AbstractActionManager>;
  90435. private _meshCollisionData;
  90436. /**
  90437. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90439. */
  90440. ellipsoid: Vector3;
  90441. /**
  90442. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90444. */
  90445. ellipsoidOffset: Vector3;
  90446. /**
  90447. * Gets or sets a collision mask used to mask collisions (default is -1).
  90448. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90449. */
  90450. collisionMask: number;
  90451. /**
  90452. * Gets or sets the current collision group mask (-1 by default).
  90453. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90454. */
  90455. collisionGroup: number;
  90456. /**
  90457. * Defines edge width used when edgesRenderer is enabled
  90458. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90459. */
  90460. edgesWidth: number;
  90461. /**
  90462. * Defines edge color used when edgesRenderer is enabled
  90463. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90464. */
  90465. edgesColor: Color4;
  90466. /** @hidden */
  90467. _edgesRenderer: Nullable<IEdgesRenderer>;
  90468. /** @hidden */
  90469. _masterMesh: Nullable<AbstractMesh>;
  90470. /** @hidden */
  90471. _boundingInfo: Nullable<BoundingInfo>;
  90472. /** @hidden */
  90473. _renderId: number;
  90474. /**
  90475. * Gets or sets the list of subMeshes
  90476. * @see http://doc.babylonjs.com/how_to/multi_materials
  90477. */
  90478. subMeshes: SubMesh[];
  90479. /** @hidden */
  90480. _intersectionsInProgress: AbstractMesh[];
  90481. /** @hidden */
  90482. _unIndexed: boolean;
  90483. /** @hidden */
  90484. _lightSources: Light[];
  90485. /** Gets the list of lights affecting that mesh */
  90486. readonly lightSources: Light[];
  90487. /** @hidden */
  90488. readonly _positions: Nullable<Vector3[]>;
  90489. /** @hidden */
  90490. _waitingData: {
  90491. lods: Nullable<any>;
  90492. actions: Nullable<any>;
  90493. freezeWorldMatrix: Nullable<boolean>;
  90494. };
  90495. /** @hidden */
  90496. _bonesTransformMatrices: Nullable<Float32Array>;
  90497. /** @hidden */
  90498. _transformMatrixTexture: Nullable<RawTexture>;
  90499. /**
  90500. * Gets or sets a skeleton to apply skining transformations
  90501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90502. */
  90503. skeleton: Nullable<Skeleton>;
  90504. /**
  90505. * An event triggered when the mesh is rebuilt.
  90506. */
  90507. onRebuildObservable: Observable<AbstractMesh>;
  90508. /**
  90509. * Creates a new AbstractMesh
  90510. * @param name defines the name of the mesh
  90511. * @param scene defines the hosting scene
  90512. */
  90513. constructor(name: string, scene?: Nullable<Scene>);
  90514. /**
  90515. * Returns the string "AbstractMesh"
  90516. * @returns "AbstractMesh"
  90517. */
  90518. getClassName(): string;
  90519. /**
  90520. * Gets a string representation of the current mesh
  90521. * @param fullDetails defines a boolean indicating if full details must be included
  90522. * @returns a string representation of the current mesh
  90523. */
  90524. toString(fullDetails?: boolean): string;
  90525. /**
  90526. * @hidden
  90527. */
  90528. protected _getEffectiveParent(): Nullable<Node>;
  90529. /** @hidden */
  90530. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90531. /** @hidden */
  90532. _rebuild(): void;
  90533. /** @hidden */
  90534. _resyncLightSources(): void;
  90535. /** @hidden */
  90536. _resyncLighSource(light: Light): void;
  90537. /** @hidden */
  90538. _unBindEffect(): void;
  90539. /** @hidden */
  90540. _removeLightSource(light: Light): void;
  90541. private _markSubMeshesAsDirty;
  90542. /** @hidden */
  90543. _markSubMeshesAsLightDirty(): void;
  90544. /** @hidden */
  90545. _markSubMeshesAsAttributesDirty(): void;
  90546. /** @hidden */
  90547. _markSubMeshesAsMiscDirty(): void;
  90548. /**
  90549. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90550. */
  90551. scaling: Vector3;
  90552. /**
  90553. * Returns true if the mesh is blocked. Implemented by child classes
  90554. */
  90555. readonly isBlocked: boolean;
  90556. /**
  90557. * Returns the mesh itself by default. Implemented by child classes
  90558. * @param camera defines the camera to use to pick the right LOD level
  90559. * @returns the currentAbstractMesh
  90560. */
  90561. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90562. /**
  90563. * Returns 0 by default. Implemented by child classes
  90564. * @returns an integer
  90565. */
  90566. getTotalVertices(): number;
  90567. /**
  90568. * Returns a positive integer : the total number of indices in this mesh geometry.
  90569. * @returns the numner of indices or zero if the mesh has no geometry.
  90570. */
  90571. getTotalIndices(): number;
  90572. /**
  90573. * Returns null by default. Implemented by child classes
  90574. * @returns null
  90575. */
  90576. getIndices(): Nullable<IndicesArray>;
  90577. /**
  90578. * Returns the array of the requested vertex data kind. Implemented by child classes
  90579. * @param kind defines the vertex data kind to use
  90580. * @returns null
  90581. */
  90582. getVerticesData(kind: string): Nullable<FloatArray>;
  90583. /**
  90584. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90585. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90586. * Note that a new underlying VertexBuffer object is created each call.
  90587. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90588. * @param kind defines vertex data kind:
  90589. * * VertexBuffer.PositionKind
  90590. * * VertexBuffer.UVKind
  90591. * * VertexBuffer.UV2Kind
  90592. * * VertexBuffer.UV3Kind
  90593. * * VertexBuffer.UV4Kind
  90594. * * VertexBuffer.UV5Kind
  90595. * * VertexBuffer.UV6Kind
  90596. * * VertexBuffer.ColorKind
  90597. * * VertexBuffer.MatricesIndicesKind
  90598. * * VertexBuffer.MatricesIndicesExtraKind
  90599. * * VertexBuffer.MatricesWeightsKind
  90600. * * VertexBuffer.MatricesWeightsExtraKind
  90601. * @param data defines the data source
  90602. * @param updatable defines if the data must be flagged as updatable (or static)
  90603. * @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
  90604. * @returns the current mesh
  90605. */
  90606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90607. /**
  90608. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90609. * If the mesh has no geometry, it is simply returned as it is.
  90610. * @param kind defines vertex data kind:
  90611. * * VertexBuffer.PositionKind
  90612. * * VertexBuffer.UVKind
  90613. * * VertexBuffer.UV2Kind
  90614. * * VertexBuffer.UV3Kind
  90615. * * VertexBuffer.UV4Kind
  90616. * * VertexBuffer.UV5Kind
  90617. * * VertexBuffer.UV6Kind
  90618. * * VertexBuffer.ColorKind
  90619. * * VertexBuffer.MatricesIndicesKind
  90620. * * VertexBuffer.MatricesIndicesExtraKind
  90621. * * VertexBuffer.MatricesWeightsKind
  90622. * * VertexBuffer.MatricesWeightsExtraKind
  90623. * @param data defines the data source
  90624. * @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
  90625. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90626. * @returns the current mesh
  90627. */
  90628. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90629. /**
  90630. * Sets the mesh indices,
  90631. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90632. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90633. * @param totalVertices Defines the total number of vertices
  90634. * @returns the current mesh
  90635. */
  90636. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90637. /**
  90638. * Gets a boolean indicating if specific vertex data is present
  90639. * @param kind defines the vertex data kind to use
  90640. * @returns true is data kind is present
  90641. */
  90642. isVerticesDataPresent(kind: string): boolean;
  90643. /**
  90644. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90645. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90646. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90647. * @returns a BoundingInfo
  90648. */
  90649. getBoundingInfo(): BoundingInfo;
  90650. /**
  90651. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90652. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90653. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90654. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90655. * @returns the current mesh
  90656. */
  90657. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90658. /**
  90659. * Overwrite the current bounding info
  90660. * @param boundingInfo defines the new bounding info
  90661. * @returns the current mesh
  90662. */
  90663. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90664. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90665. readonly useBones: boolean;
  90666. /** @hidden */
  90667. _preActivate(): void;
  90668. /** @hidden */
  90669. _preActivateForIntermediateRendering(renderId: number): void;
  90670. /** @hidden */
  90671. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90672. /** @hidden */
  90673. _postActivate(): void;
  90674. /** @hidden */
  90675. _freeze(): void;
  90676. /** @hidden */
  90677. _unFreeze(): void;
  90678. /**
  90679. * Gets the current world matrix
  90680. * @returns a Matrix
  90681. */
  90682. getWorldMatrix(): Matrix;
  90683. /** @hidden */
  90684. _getWorldMatrixDeterminant(): number;
  90685. /**
  90686. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90687. */
  90688. readonly isAnInstance: boolean;
  90689. /**
  90690. * Gets a boolean indicating if this mesh has instances
  90691. */
  90692. readonly hasInstances: boolean;
  90693. /**
  90694. * Perform relative position change from the point of view of behind the front of the mesh.
  90695. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90696. * Supports definition of mesh facing forward or backward
  90697. * @param amountRight defines the distance on the right axis
  90698. * @param amountUp defines the distance on the up axis
  90699. * @param amountForward defines the distance on the forward axis
  90700. * @returns the current mesh
  90701. */
  90702. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90703. /**
  90704. * Calculate relative position change from the point of view of behind the front of the mesh.
  90705. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90706. * Supports definition of mesh facing forward or backward
  90707. * @param amountRight defines the distance on the right axis
  90708. * @param amountUp defines the distance on the up axis
  90709. * @param amountForward defines the distance on the forward axis
  90710. * @returns the new displacement vector
  90711. */
  90712. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90713. /**
  90714. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90715. * Supports definition of mesh facing forward or backward
  90716. * @param flipBack defines the flip
  90717. * @param twirlClockwise defines the twirl
  90718. * @param tiltRight defines the tilt
  90719. * @returns the current mesh
  90720. */
  90721. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90722. /**
  90723. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90724. * Supports definition of mesh facing forward or backward.
  90725. * @param flipBack defines the flip
  90726. * @param twirlClockwise defines the twirl
  90727. * @param tiltRight defines the tilt
  90728. * @returns the new rotation vector
  90729. */
  90730. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90731. /**
  90732. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90733. * This means the mesh underlying bounding box and sphere are recomputed.
  90734. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90735. * @returns the current mesh
  90736. */
  90737. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90738. /** @hidden */
  90739. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90740. /** @hidden */
  90741. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90742. /** @hidden */
  90743. _updateBoundingInfo(): AbstractMesh;
  90744. /** @hidden */
  90745. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90746. /** @hidden */
  90747. protected _afterComputeWorldMatrix(): void;
  90748. /** @hidden */
  90749. readonly _effectiveMesh: AbstractMesh;
  90750. /**
  90751. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90752. * A mesh is in the frustum if its bounding box intersects the frustum
  90753. * @param frustumPlanes defines the frustum to test
  90754. * @returns true if the mesh is in the frustum planes
  90755. */
  90756. isInFrustum(frustumPlanes: Plane[]): boolean;
  90757. /**
  90758. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90759. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90760. * @param frustumPlanes defines the frustum to test
  90761. * @returns true if the mesh is completely in the frustum planes
  90762. */
  90763. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90764. /**
  90765. * True if the mesh intersects another mesh or a SolidParticle object
  90766. * @param mesh defines a target mesh or SolidParticle to test
  90767. * @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)
  90768. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90769. * @returns true if there is an intersection
  90770. */
  90771. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90772. /**
  90773. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90774. * @param point defines the point to test
  90775. * @returns true if there is an intersection
  90776. */
  90777. intersectsPoint(point: Vector3): boolean;
  90778. /**
  90779. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90781. */
  90782. checkCollisions: boolean;
  90783. /**
  90784. * Gets Collider object used to compute collisions (not physics)
  90785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90786. */
  90787. readonly collider: Nullable<Collider>;
  90788. /**
  90789. * Move the mesh using collision engine
  90790. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90791. * @param displacement defines the requested displacement vector
  90792. * @returns the current mesh
  90793. */
  90794. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90795. private _onCollisionPositionChange;
  90796. /** @hidden */
  90797. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90798. /** @hidden */
  90799. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90800. /** @hidden */
  90801. _checkCollision(collider: Collider): AbstractMesh;
  90802. /** @hidden */
  90803. _generatePointsArray(): boolean;
  90804. /**
  90805. * Checks if the passed Ray intersects with the mesh
  90806. * @param ray defines the ray to use
  90807. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90808. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90809. * @returns the picking info
  90810. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90811. */
  90812. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90813. /**
  90814. * Clones the current mesh
  90815. * @param name defines the mesh name
  90816. * @param newParent defines the new mesh parent
  90817. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90818. * @returns the new mesh
  90819. */
  90820. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90821. /**
  90822. * Disposes all the submeshes of the current meshnp
  90823. * @returns the current mesh
  90824. */
  90825. releaseSubMeshes(): AbstractMesh;
  90826. /**
  90827. * Releases resources associated with this abstract mesh.
  90828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90830. */
  90831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90832. /**
  90833. * Adds the passed mesh as a child to the current mesh
  90834. * @param mesh defines the child mesh
  90835. * @returns the current mesh
  90836. */
  90837. addChild(mesh: AbstractMesh): AbstractMesh;
  90838. /**
  90839. * Removes the passed mesh from the current mesh children list
  90840. * @param mesh defines the child mesh
  90841. * @returns the current mesh
  90842. */
  90843. removeChild(mesh: AbstractMesh): AbstractMesh;
  90844. /** @hidden */
  90845. private _initFacetData;
  90846. /**
  90847. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90848. * This method can be called within the render loop.
  90849. * 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
  90850. * @returns the current mesh
  90851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90852. */
  90853. updateFacetData(): AbstractMesh;
  90854. /**
  90855. * Returns the facetLocalNormals array.
  90856. * The normals are expressed in the mesh local spac
  90857. * @returns an array of Vector3
  90858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90859. */
  90860. getFacetLocalNormals(): Vector3[];
  90861. /**
  90862. * Returns the facetLocalPositions array.
  90863. * The facet positions are expressed in the mesh local space
  90864. * @returns an array of Vector3
  90865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90866. */
  90867. getFacetLocalPositions(): Vector3[];
  90868. /**
  90869. * Returns the facetLocalPartioning array
  90870. * @returns an array of array of numbers
  90871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90872. */
  90873. getFacetLocalPartitioning(): number[][];
  90874. /**
  90875. * Returns the i-th facet position in the world system.
  90876. * This method allocates a new Vector3 per call
  90877. * @param i defines the facet index
  90878. * @returns a new Vector3
  90879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90880. */
  90881. getFacetPosition(i: number): Vector3;
  90882. /**
  90883. * Sets the reference Vector3 with the i-th facet position in the world system
  90884. * @param i defines the facet index
  90885. * @param ref defines the target vector
  90886. * @returns the current mesh
  90887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90888. */
  90889. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90890. /**
  90891. * Returns the i-th facet normal in the world system.
  90892. * This method allocates a new Vector3 per call
  90893. * @param i defines the facet index
  90894. * @returns a new Vector3
  90895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90896. */
  90897. getFacetNormal(i: number): Vector3;
  90898. /**
  90899. * Sets the reference Vector3 with the i-th facet normal in the world system
  90900. * @param i defines the facet index
  90901. * @param ref defines the target vector
  90902. * @returns the current mesh
  90903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90904. */
  90905. getFacetNormalToRef(i: number, ref: Vector3): this;
  90906. /**
  90907. * 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)
  90908. * @param x defines x coordinate
  90909. * @param y defines y coordinate
  90910. * @param z defines z coordinate
  90911. * @returns the array of facet indexes
  90912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90913. */
  90914. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90915. /**
  90916. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90917. * @param projected sets as the (x,y,z) world projection on the facet
  90918. * @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
  90919. * @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
  90920. * @param x defines x coordinate
  90921. * @param y defines y coordinate
  90922. * @param z defines z coordinate
  90923. * @returns the face index if found (or null instead)
  90924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90925. */
  90926. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90927. /**
  90928. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90929. * @param projected sets as the (x,y,z) local projection on the facet
  90930. * @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
  90931. * @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
  90932. * @param x defines x coordinate
  90933. * @param y defines y coordinate
  90934. * @param z defines z coordinate
  90935. * @returns the face index if found (or null instead)
  90936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90937. */
  90938. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90939. /**
  90940. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90941. * @returns the parameters
  90942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90943. */
  90944. getFacetDataParameters(): any;
  90945. /**
  90946. * Disables the feature FacetData and frees the related memory
  90947. * @returns the current mesh
  90948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90949. */
  90950. disableFacetData(): AbstractMesh;
  90951. /**
  90952. * Updates the AbstractMesh indices array
  90953. * @param indices defines the data source
  90954. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90955. * @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)
  90956. * @returns the current mesh
  90957. */
  90958. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90959. /**
  90960. * Creates new normals data for the mesh
  90961. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90962. * @returns the current mesh
  90963. */
  90964. createNormals(updatable: boolean): AbstractMesh;
  90965. /**
  90966. * Align the mesh with a normal
  90967. * @param normal defines the normal to use
  90968. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90969. * @returns the current mesh
  90970. */
  90971. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90972. /** @hidden */
  90973. _checkOcclusionQuery(): boolean;
  90974. /**
  90975. * Disables the mesh edge rendering mode
  90976. * @returns the currentAbstractMesh
  90977. */
  90978. disableEdgesRendering(): AbstractMesh;
  90979. /**
  90980. * Enables the edge rendering mode on the mesh.
  90981. * This mode makes the mesh edges visible
  90982. * @param epsilon defines the maximal distance between two angles to detect a face
  90983. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90984. * @returns the currentAbstractMesh
  90985. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90986. */
  90987. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90988. }
  90989. }
  90990. declare module BABYLON {
  90991. /**
  90992. * Interface used to define ActionEvent
  90993. */
  90994. export interface IActionEvent {
  90995. /** The mesh or sprite that triggered the action */
  90996. source: any;
  90997. /** The X mouse cursor position at the time of the event */
  90998. pointerX: number;
  90999. /** The Y mouse cursor position at the time of the event */
  91000. pointerY: number;
  91001. /** The mesh that is currently pointed at (can be null) */
  91002. meshUnderPointer: Nullable<AbstractMesh>;
  91003. /** the original (browser) event that triggered the ActionEvent */
  91004. sourceEvent?: any;
  91005. /** additional data for the event */
  91006. additionalData?: any;
  91007. }
  91008. /**
  91009. * ActionEvent is the event being sent when an action is triggered.
  91010. */
  91011. export class ActionEvent implements IActionEvent {
  91012. /** The mesh or sprite that triggered the action */
  91013. source: any;
  91014. /** The X mouse cursor position at the time of the event */
  91015. pointerX: number;
  91016. /** The Y mouse cursor position at the time of the event */
  91017. pointerY: number;
  91018. /** The mesh that is currently pointed at (can be null) */
  91019. meshUnderPointer: Nullable<AbstractMesh>;
  91020. /** the original (browser) event that triggered the ActionEvent */
  91021. sourceEvent?: any;
  91022. /** additional data for the event */
  91023. additionalData?: any;
  91024. /**
  91025. * Creates a new ActionEvent
  91026. * @param source The mesh or sprite that triggered the action
  91027. * @param pointerX The X mouse cursor position at the time of the event
  91028. * @param pointerY The Y mouse cursor position at the time of the event
  91029. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91030. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91031. * @param additionalData additional data for the event
  91032. */
  91033. constructor(
  91034. /** The mesh or sprite that triggered the action */
  91035. source: any,
  91036. /** The X mouse cursor position at the time of the event */
  91037. pointerX: number,
  91038. /** The Y mouse cursor position at the time of the event */
  91039. pointerY: number,
  91040. /** The mesh that is currently pointed at (can be null) */
  91041. meshUnderPointer: Nullable<AbstractMesh>,
  91042. /** the original (browser) event that triggered the ActionEvent */
  91043. sourceEvent?: any,
  91044. /** additional data for the event */
  91045. additionalData?: any);
  91046. /**
  91047. * Helper function to auto-create an ActionEvent from a source mesh.
  91048. * @param source The source mesh that triggered the event
  91049. * @param evt The original (browser) event
  91050. * @param additionalData additional data for the event
  91051. * @returns the new ActionEvent
  91052. */
  91053. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91054. /**
  91055. * Helper function to auto-create an ActionEvent from a source sprite
  91056. * @param source The source sprite that triggered the event
  91057. * @param scene Scene associated with the sprite
  91058. * @param evt The original (browser) event
  91059. * @param additionalData additional data for the event
  91060. * @returns the new ActionEvent
  91061. */
  91062. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91063. /**
  91064. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91065. * @param scene the scene where the event occurred
  91066. * @param evt The original (browser) event
  91067. * @returns the new ActionEvent
  91068. */
  91069. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91070. /**
  91071. * Helper function to auto-create an ActionEvent from a primitive
  91072. * @param prim defines the target primitive
  91073. * @param pointerPos defines the pointer position
  91074. * @param evt The original (browser) event
  91075. * @param additionalData additional data for the event
  91076. * @returns the new ActionEvent
  91077. */
  91078. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91079. }
  91080. }
  91081. declare module BABYLON {
  91082. /**
  91083. * Abstract class used to decouple action Manager from scene and meshes.
  91084. * Do not instantiate.
  91085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91086. */
  91087. export abstract class AbstractActionManager implements IDisposable {
  91088. /** Gets the list of active triggers */
  91089. static Triggers: {
  91090. [key: string]: number;
  91091. };
  91092. /** Gets the cursor to use when hovering items */
  91093. hoverCursor: string;
  91094. /** Gets the list of actions */
  91095. actions: IAction[];
  91096. /**
  91097. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91098. */
  91099. isRecursive: boolean;
  91100. /**
  91101. * Releases all associated resources
  91102. */
  91103. abstract dispose(): void;
  91104. /**
  91105. * Does this action manager has pointer triggers
  91106. */
  91107. abstract readonly hasPointerTriggers: boolean;
  91108. /**
  91109. * Does this action manager has pick triggers
  91110. */
  91111. abstract readonly hasPickTriggers: boolean;
  91112. /**
  91113. * Process a specific trigger
  91114. * @param trigger defines the trigger to process
  91115. * @param evt defines the event details to be processed
  91116. */
  91117. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91118. /**
  91119. * Does this action manager handles actions of any of the given triggers
  91120. * @param triggers defines the triggers to be tested
  91121. * @return a boolean indicating whether one (or more) of the triggers is handled
  91122. */
  91123. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91124. /**
  91125. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91126. * speed.
  91127. * @param triggerA defines the trigger to be tested
  91128. * @param triggerB defines the trigger to be tested
  91129. * @return a boolean indicating whether one (or more) of the triggers is handled
  91130. */
  91131. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91132. /**
  91133. * Does this action manager handles actions of a given trigger
  91134. * @param trigger defines the trigger to be tested
  91135. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91136. * @return whether the trigger is handled
  91137. */
  91138. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91139. /**
  91140. * Serialize this manager to a JSON object
  91141. * @param name defines the property name to store this manager
  91142. * @returns a JSON representation of this manager
  91143. */
  91144. abstract serialize(name: string): any;
  91145. /**
  91146. * Registers an action to this action manager
  91147. * @param action defines the action to be registered
  91148. * @return the action amended (prepared) after registration
  91149. */
  91150. abstract registerAction(action: IAction): Nullable<IAction>;
  91151. /**
  91152. * Unregisters an action to this action manager
  91153. * @param action defines the action to be unregistered
  91154. * @return a boolean indicating whether the action has been unregistered
  91155. */
  91156. abstract unregisterAction(action: IAction): Boolean;
  91157. /**
  91158. * Does exist one action manager with at least one trigger
  91159. **/
  91160. static readonly HasTriggers: boolean;
  91161. /**
  91162. * Does exist one action manager with at least one pick trigger
  91163. **/
  91164. static readonly HasPickTriggers: boolean;
  91165. /**
  91166. * Does exist one action manager that handles actions of a given trigger
  91167. * @param trigger defines the trigger to be tested
  91168. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91169. **/
  91170. static HasSpecificTrigger(trigger: number): boolean;
  91171. }
  91172. }
  91173. declare module BABYLON {
  91174. /**
  91175. * Defines how a node can be built from a string name.
  91176. */
  91177. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91178. /**
  91179. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91180. */
  91181. export class Node implements IBehaviorAware<Node> {
  91182. /** @hidden */
  91183. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91184. private static _NodeConstructors;
  91185. /**
  91186. * Add a new node constructor
  91187. * @param type defines the type name of the node to construct
  91188. * @param constructorFunc defines the constructor function
  91189. */
  91190. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91191. /**
  91192. * Returns a node constructor based on type name
  91193. * @param type defines the type name
  91194. * @param name defines the new node name
  91195. * @param scene defines the hosting scene
  91196. * @param options defines optional options to transmit to constructors
  91197. * @returns the new constructor or null
  91198. */
  91199. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91200. /**
  91201. * Gets or sets the name of the node
  91202. */
  91203. name: string;
  91204. /**
  91205. * Gets or sets the id of the node
  91206. */
  91207. id: string;
  91208. /**
  91209. * Gets or sets the unique id of the node
  91210. */
  91211. uniqueId: number;
  91212. /**
  91213. * Gets or sets a string used to store user defined state for the node
  91214. */
  91215. state: string;
  91216. /**
  91217. * Gets or sets an object used to store user defined information for the node
  91218. */
  91219. metadata: any;
  91220. /**
  91221. * For internal use only. Please do not use.
  91222. */
  91223. reservedDataStore: any;
  91224. /**
  91225. * List of inspectable custom properties (used by the Inspector)
  91226. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91227. */
  91228. inspectableCustomProperties: IInspectable[];
  91229. /**
  91230. * Gets or sets a boolean used to define if the node must be serialized
  91231. */
  91232. doNotSerialize: boolean;
  91233. /** @hidden */
  91234. _isDisposed: boolean;
  91235. /**
  91236. * Gets a list of Animations associated with the node
  91237. */
  91238. animations: Animation[];
  91239. protected _ranges: {
  91240. [name: string]: Nullable<AnimationRange>;
  91241. };
  91242. /**
  91243. * Callback raised when the node is ready to be used
  91244. */
  91245. onReady: Nullable<(node: Node) => void>;
  91246. private _isEnabled;
  91247. private _isParentEnabled;
  91248. private _isReady;
  91249. /** @hidden */
  91250. _currentRenderId: number;
  91251. private _parentUpdateId;
  91252. /** @hidden */
  91253. _childUpdateId: number;
  91254. /** @hidden */
  91255. _waitingParentId: Nullable<string>;
  91256. /** @hidden */
  91257. _scene: Scene;
  91258. /** @hidden */
  91259. _cache: any;
  91260. private _parentNode;
  91261. private _children;
  91262. /** @hidden */
  91263. _worldMatrix: Matrix;
  91264. /** @hidden */
  91265. _worldMatrixDeterminant: number;
  91266. /** @hidden */
  91267. _worldMatrixDeterminantIsDirty: boolean;
  91268. /** @hidden */
  91269. private _sceneRootNodesIndex;
  91270. /**
  91271. * Gets a boolean indicating if the node has been disposed
  91272. * @returns true if the node was disposed
  91273. */
  91274. isDisposed(): boolean;
  91275. /**
  91276. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91277. * @see https://doc.babylonjs.com/how_to/parenting
  91278. */
  91279. parent: Nullable<Node>;
  91280. private addToSceneRootNodes;
  91281. private removeFromSceneRootNodes;
  91282. private _animationPropertiesOverride;
  91283. /**
  91284. * Gets or sets the animation properties override
  91285. */
  91286. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91287. /**
  91288. * Gets a string idenfifying the name of the class
  91289. * @returns "Node" string
  91290. */
  91291. getClassName(): string;
  91292. /** @hidden */
  91293. readonly _isNode: boolean;
  91294. /**
  91295. * An event triggered when the mesh is disposed
  91296. */
  91297. onDisposeObservable: Observable<Node>;
  91298. private _onDisposeObserver;
  91299. /**
  91300. * Sets a callback that will be raised when the node will be disposed
  91301. */
  91302. onDispose: () => void;
  91303. /**
  91304. * Creates a new Node
  91305. * @param name the name and id to be given to this node
  91306. * @param scene the scene this node will be added to
  91307. * @param addToRootNodes the node will be added to scene.rootNodes
  91308. */
  91309. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91310. /**
  91311. * Gets the scene of the node
  91312. * @returns a scene
  91313. */
  91314. getScene(): Scene;
  91315. /**
  91316. * Gets the engine of the node
  91317. * @returns a Engine
  91318. */
  91319. getEngine(): Engine;
  91320. private _behaviors;
  91321. /**
  91322. * Attach a behavior to the node
  91323. * @see http://doc.babylonjs.com/features/behaviour
  91324. * @param behavior defines the behavior to attach
  91325. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91326. * @returns the current Node
  91327. */
  91328. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91329. /**
  91330. * Remove an attached behavior
  91331. * @see http://doc.babylonjs.com/features/behaviour
  91332. * @param behavior defines the behavior to attach
  91333. * @returns the current Node
  91334. */
  91335. removeBehavior(behavior: Behavior<Node>): Node;
  91336. /**
  91337. * Gets the list of attached behaviors
  91338. * @see http://doc.babylonjs.com/features/behaviour
  91339. */
  91340. readonly behaviors: Behavior<Node>[];
  91341. /**
  91342. * Gets an attached behavior by name
  91343. * @param name defines the name of the behavior to look for
  91344. * @see http://doc.babylonjs.com/features/behaviour
  91345. * @returns null if behavior was not found else the requested behavior
  91346. */
  91347. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91348. /**
  91349. * Returns the latest update of the World matrix
  91350. * @returns a Matrix
  91351. */
  91352. getWorldMatrix(): Matrix;
  91353. /** @hidden */
  91354. _getWorldMatrixDeterminant(): number;
  91355. /**
  91356. * Returns directly the latest state of the mesh World matrix.
  91357. * A Matrix is returned.
  91358. */
  91359. readonly worldMatrixFromCache: Matrix;
  91360. /** @hidden */
  91361. _initCache(): void;
  91362. /** @hidden */
  91363. updateCache(force?: boolean): void;
  91364. /** @hidden */
  91365. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91366. /** @hidden */
  91367. _updateCache(ignoreParentClass?: boolean): void;
  91368. /** @hidden */
  91369. _isSynchronized(): boolean;
  91370. /** @hidden */
  91371. _markSyncedWithParent(): void;
  91372. /** @hidden */
  91373. isSynchronizedWithParent(): boolean;
  91374. /** @hidden */
  91375. isSynchronized(): boolean;
  91376. /**
  91377. * Is this node ready to be used/rendered
  91378. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91379. * @return true if the node is ready
  91380. */
  91381. isReady(completeCheck?: boolean): boolean;
  91382. /**
  91383. * Is this node enabled?
  91384. * 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
  91385. * @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
  91386. * @return whether this node (and its parent) is enabled
  91387. */
  91388. isEnabled(checkAncestors?: boolean): boolean;
  91389. /** @hidden */
  91390. protected _syncParentEnabledState(): void;
  91391. /**
  91392. * Set the enabled state of this node
  91393. * @param value defines the new enabled state
  91394. */
  91395. setEnabled(value: boolean): void;
  91396. /**
  91397. * Is this node a descendant of the given node?
  91398. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91399. * @param ancestor defines the parent node to inspect
  91400. * @returns a boolean indicating if this node is a descendant of the given node
  91401. */
  91402. isDescendantOf(ancestor: Node): boolean;
  91403. /** @hidden */
  91404. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91405. /**
  91406. * Will return all nodes that have this node as ascendant
  91407. * @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
  91408. * @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
  91409. * @return all children nodes of all types
  91410. */
  91411. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91412. /**
  91413. * Get all child-meshes of this node
  91414. * @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)
  91415. * @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
  91416. * @returns an array of AbstractMesh
  91417. */
  91418. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91419. /**
  91420. * Get all direct children of this node
  91421. * @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
  91422. * @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)
  91423. * @returns an array of Node
  91424. */
  91425. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91426. /** @hidden */
  91427. _setReady(state: boolean): void;
  91428. /**
  91429. * Get an animation by name
  91430. * @param name defines the name of the animation to look for
  91431. * @returns null if not found else the requested animation
  91432. */
  91433. getAnimationByName(name: string): Nullable<Animation>;
  91434. /**
  91435. * Creates an animation range for this node
  91436. * @param name defines the name of the range
  91437. * @param from defines the starting key
  91438. * @param to defines the end key
  91439. */
  91440. createAnimationRange(name: string, from: number, to: number): void;
  91441. /**
  91442. * Delete a specific animation range
  91443. * @param name defines the name of the range to delete
  91444. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91445. */
  91446. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91447. /**
  91448. * Get an animation range by name
  91449. * @param name defines the name of the animation range to look for
  91450. * @returns null if not found else the requested animation range
  91451. */
  91452. getAnimationRange(name: string): Nullable<AnimationRange>;
  91453. /**
  91454. * Gets the list of all animation ranges defined on this node
  91455. * @returns an array
  91456. */
  91457. getAnimationRanges(): Nullable<AnimationRange>[];
  91458. /**
  91459. * Will start the animation sequence
  91460. * @param name defines the range frames for animation sequence
  91461. * @param loop defines if the animation should loop (false by default)
  91462. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91463. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91464. * @returns the object created for this animation. If range does not exist, it will return null
  91465. */
  91466. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91467. /**
  91468. * Serialize animation ranges into a JSON compatible object
  91469. * @returns serialization object
  91470. */
  91471. serializeAnimationRanges(): any;
  91472. /**
  91473. * Computes the world matrix of the node
  91474. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91475. * @returns the world matrix
  91476. */
  91477. computeWorldMatrix(force?: boolean): Matrix;
  91478. /**
  91479. * Releases resources associated with this node.
  91480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91482. */
  91483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91484. /**
  91485. * Parse animation range data from a serialization object and store them into a given node
  91486. * @param node defines where to store the animation ranges
  91487. * @param parsedNode defines the serialization object to read data from
  91488. * @param scene defines the hosting scene
  91489. */
  91490. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91491. /**
  91492. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91493. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91494. * @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
  91495. * @returns the new bounding vectors
  91496. */
  91497. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91498. min: Vector3;
  91499. max: Vector3;
  91500. };
  91501. }
  91502. }
  91503. declare module BABYLON {
  91504. /**
  91505. * @hidden
  91506. */
  91507. export class _IAnimationState {
  91508. key: number;
  91509. repeatCount: number;
  91510. workValue?: any;
  91511. loopMode?: number;
  91512. offsetValue?: any;
  91513. highLimitValue?: any;
  91514. }
  91515. /**
  91516. * Class used to store any kind of animation
  91517. */
  91518. export class Animation {
  91519. /**Name of the animation */
  91520. name: string;
  91521. /**Property to animate */
  91522. targetProperty: string;
  91523. /**The frames per second of the animation */
  91524. framePerSecond: number;
  91525. /**The data type of the animation */
  91526. dataType: number;
  91527. /**The loop mode of the animation */
  91528. loopMode?: number | undefined;
  91529. /**Specifies if blending should be enabled */
  91530. enableBlending?: boolean | undefined;
  91531. /**
  91532. * Use matrix interpolation instead of using direct key value when animating matrices
  91533. */
  91534. static AllowMatricesInterpolation: boolean;
  91535. /**
  91536. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91537. */
  91538. static AllowMatrixDecomposeForInterpolation: boolean;
  91539. /**
  91540. * Stores the key frames of the animation
  91541. */
  91542. private _keys;
  91543. /**
  91544. * Stores the easing function of the animation
  91545. */
  91546. private _easingFunction;
  91547. /**
  91548. * @hidden Internal use only
  91549. */
  91550. _runtimeAnimations: RuntimeAnimation[];
  91551. /**
  91552. * The set of event that will be linked to this animation
  91553. */
  91554. private _events;
  91555. /**
  91556. * Stores an array of target property paths
  91557. */
  91558. targetPropertyPath: string[];
  91559. /**
  91560. * Stores the blending speed of the animation
  91561. */
  91562. blendingSpeed: number;
  91563. /**
  91564. * Stores the animation ranges for the animation
  91565. */
  91566. private _ranges;
  91567. /**
  91568. * @hidden Internal use
  91569. */
  91570. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91571. /**
  91572. * Sets up an animation
  91573. * @param property The property to animate
  91574. * @param animationType The animation type to apply
  91575. * @param framePerSecond The frames per second of the animation
  91576. * @param easingFunction The easing function used in the animation
  91577. * @returns The created animation
  91578. */
  91579. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91580. /**
  91581. * Create and start an animation on a node
  91582. * @param name defines the name of the global animation that will be run on all nodes
  91583. * @param node defines the root node where the animation will take place
  91584. * @param targetProperty defines property to animate
  91585. * @param framePerSecond defines the number of frame per second yo use
  91586. * @param totalFrame defines the number of frames in total
  91587. * @param from defines the initial value
  91588. * @param to defines the final value
  91589. * @param loopMode defines which loop mode you want to use (off by default)
  91590. * @param easingFunction defines the easing function to use (linear by default)
  91591. * @param onAnimationEnd defines the callback to call when animation end
  91592. * @returns the animatable created for this animation
  91593. */
  91594. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91595. /**
  91596. * Create and start an animation on a node and its descendants
  91597. * @param name defines the name of the global animation that will be run on all nodes
  91598. * @param node defines the root node where the animation will take place
  91599. * @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
  91600. * @param targetProperty defines property to animate
  91601. * @param framePerSecond defines the number of frame per second to use
  91602. * @param totalFrame defines the number of frames in total
  91603. * @param from defines the initial value
  91604. * @param to defines the final value
  91605. * @param loopMode defines which loop mode you want to use (off by default)
  91606. * @param easingFunction defines the easing function to use (linear by default)
  91607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91608. * @returns the list of animatables created for all nodes
  91609. * @example https://www.babylonjs-playground.com/#MH0VLI
  91610. */
  91611. 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[]>;
  91612. /**
  91613. * Creates a new animation, merges it with the existing animations and starts it
  91614. * @param name Name of the animation
  91615. * @param node Node which contains the scene that begins the animations
  91616. * @param targetProperty Specifies which property to animate
  91617. * @param framePerSecond The frames per second of the animation
  91618. * @param totalFrame The total number of frames
  91619. * @param from The frame at the beginning of the animation
  91620. * @param to The frame at the end of the animation
  91621. * @param loopMode Specifies the loop mode of the animation
  91622. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91623. * @param onAnimationEnd Callback to run once the animation is complete
  91624. * @returns Nullable animation
  91625. */
  91626. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91627. /**
  91628. * Transition property of an host to the target Value
  91629. * @param property The property to transition
  91630. * @param targetValue The target Value of the property
  91631. * @param host The object where the property to animate belongs
  91632. * @param scene Scene used to run the animation
  91633. * @param frameRate Framerate (in frame/s) to use
  91634. * @param transition The transition type we want to use
  91635. * @param duration The duration of the animation, in milliseconds
  91636. * @param onAnimationEnd Callback trigger at the end of the animation
  91637. * @returns Nullable animation
  91638. */
  91639. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91640. /**
  91641. * Return the array of runtime animations currently using this animation
  91642. */
  91643. readonly runtimeAnimations: RuntimeAnimation[];
  91644. /**
  91645. * Specifies if any of the runtime animations are currently running
  91646. */
  91647. readonly hasRunningRuntimeAnimations: boolean;
  91648. /**
  91649. * Initializes the animation
  91650. * @param name Name of the animation
  91651. * @param targetProperty Property to animate
  91652. * @param framePerSecond The frames per second of the animation
  91653. * @param dataType The data type of the animation
  91654. * @param loopMode The loop mode of the animation
  91655. * @param enableBlending Specifies if blending should be enabled
  91656. */
  91657. constructor(
  91658. /**Name of the animation */
  91659. name: string,
  91660. /**Property to animate */
  91661. targetProperty: string,
  91662. /**The frames per second of the animation */
  91663. framePerSecond: number,
  91664. /**The data type of the animation */
  91665. dataType: number,
  91666. /**The loop mode of the animation */
  91667. loopMode?: number | undefined,
  91668. /**Specifies if blending should be enabled */
  91669. enableBlending?: boolean | undefined);
  91670. /**
  91671. * Converts the animation to a string
  91672. * @param fullDetails support for multiple levels of logging within scene loading
  91673. * @returns String form of the animation
  91674. */
  91675. toString(fullDetails?: boolean): string;
  91676. /**
  91677. * Add an event to this animation
  91678. * @param event Event to add
  91679. */
  91680. addEvent(event: AnimationEvent): void;
  91681. /**
  91682. * Remove all events found at the given frame
  91683. * @param frame The frame to remove events from
  91684. */
  91685. removeEvents(frame: number): void;
  91686. /**
  91687. * Retrieves all the events from the animation
  91688. * @returns Events from the animation
  91689. */
  91690. getEvents(): AnimationEvent[];
  91691. /**
  91692. * Creates an animation range
  91693. * @param name Name of the animation range
  91694. * @param from Starting frame of the animation range
  91695. * @param to Ending frame of the animation
  91696. */
  91697. createRange(name: string, from: number, to: number): void;
  91698. /**
  91699. * Deletes an animation range by name
  91700. * @param name Name of the animation range to delete
  91701. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91702. */
  91703. deleteRange(name: string, deleteFrames?: boolean): void;
  91704. /**
  91705. * Gets the animation range by name, or null if not defined
  91706. * @param name Name of the animation range
  91707. * @returns Nullable animation range
  91708. */
  91709. getRange(name: string): Nullable<AnimationRange>;
  91710. /**
  91711. * Gets the key frames from the animation
  91712. * @returns The key frames of the animation
  91713. */
  91714. getKeys(): Array<IAnimationKey>;
  91715. /**
  91716. * Gets the highest frame rate of the animation
  91717. * @returns Highest frame rate of the animation
  91718. */
  91719. getHighestFrame(): number;
  91720. /**
  91721. * Gets the easing function of the animation
  91722. * @returns Easing function of the animation
  91723. */
  91724. getEasingFunction(): IEasingFunction;
  91725. /**
  91726. * Sets the easing function of the animation
  91727. * @param easingFunction A custom mathematical formula for animation
  91728. */
  91729. setEasingFunction(easingFunction: EasingFunction): void;
  91730. /**
  91731. * Interpolates a scalar linearly
  91732. * @param startValue Start value of the animation curve
  91733. * @param endValue End value of the animation curve
  91734. * @param gradient Scalar amount to interpolate
  91735. * @returns Interpolated scalar value
  91736. */
  91737. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91738. /**
  91739. * Interpolates a scalar cubically
  91740. * @param startValue Start value of the animation curve
  91741. * @param outTangent End tangent of the animation
  91742. * @param endValue End value of the animation curve
  91743. * @param inTangent Start tangent of the animation curve
  91744. * @param gradient Scalar amount to interpolate
  91745. * @returns Interpolated scalar value
  91746. */
  91747. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91748. /**
  91749. * Interpolates a quaternion using a spherical linear interpolation
  91750. * @param startValue Start value of the animation curve
  91751. * @param endValue End value of the animation curve
  91752. * @param gradient Scalar amount to interpolate
  91753. * @returns Interpolated quaternion value
  91754. */
  91755. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91756. /**
  91757. * Interpolates a quaternion cubically
  91758. * @param startValue Start value of the animation curve
  91759. * @param outTangent End tangent of the animation curve
  91760. * @param endValue End value of the animation curve
  91761. * @param inTangent Start tangent of the animation curve
  91762. * @param gradient Scalar amount to interpolate
  91763. * @returns Interpolated quaternion value
  91764. */
  91765. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91766. /**
  91767. * Interpolates a Vector3 linearl
  91768. * @param startValue Start value of the animation curve
  91769. * @param endValue End value of the animation curve
  91770. * @param gradient Scalar amount to interpolate
  91771. * @returns Interpolated scalar value
  91772. */
  91773. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91774. /**
  91775. * Interpolates a Vector3 cubically
  91776. * @param startValue Start value of the animation curve
  91777. * @param outTangent End tangent of the animation
  91778. * @param endValue End value of the animation curve
  91779. * @param inTangent Start tangent of the animation curve
  91780. * @param gradient Scalar amount to interpolate
  91781. * @returns InterpolatedVector3 value
  91782. */
  91783. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91784. /**
  91785. * Interpolates a Vector2 linearly
  91786. * @param startValue Start value of the animation curve
  91787. * @param endValue End value of the animation curve
  91788. * @param gradient Scalar amount to interpolate
  91789. * @returns Interpolated Vector2 value
  91790. */
  91791. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91792. /**
  91793. * Interpolates a Vector2 cubically
  91794. * @param startValue Start value of the animation curve
  91795. * @param outTangent End tangent of the animation
  91796. * @param endValue End value of the animation curve
  91797. * @param inTangent Start tangent of the animation curve
  91798. * @param gradient Scalar amount to interpolate
  91799. * @returns Interpolated Vector2 value
  91800. */
  91801. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91802. /**
  91803. * Interpolates a size linearly
  91804. * @param startValue Start value of the animation curve
  91805. * @param endValue End value of the animation curve
  91806. * @param gradient Scalar amount to interpolate
  91807. * @returns Interpolated Size value
  91808. */
  91809. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91810. /**
  91811. * Interpolates a Color3 linearly
  91812. * @param startValue Start value of the animation curve
  91813. * @param endValue End value of the animation curve
  91814. * @param gradient Scalar amount to interpolate
  91815. * @returns Interpolated Color3 value
  91816. */
  91817. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91818. /**
  91819. * @hidden Internal use only
  91820. */
  91821. _getKeyValue(value: any): any;
  91822. /**
  91823. * @hidden Internal use only
  91824. */
  91825. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91826. /**
  91827. * Defines the function to use to interpolate matrices
  91828. * @param startValue defines the start matrix
  91829. * @param endValue defines the end matrix
  91830. * @param gradient defines the gradient between both matrices
  91831. * @param result defines an optional target matrix where to store the interpolation
  91832. * @returns the interpolated matrix
  91833. */
  91834. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91835. /**
  91836. * Makes a copy of the animation
  91837. * @returns Cloned animation
  91838. */
  91839. clone(): Animation;
  91840. /**
  91841. * Sets the key frames of the animation
  91842. * @param values The animation key frames to set
  91843. */
  91844. setKeys(values: Array<IAnimationKey>): void;
  91845. /**
  91846. * Serializes the animation to an object
  91847. * @returns Serialized object
  91848. */
  91849. serialize(): any;
  91850. /**
  91851. * Float animation type
  91852. */
  91853. private static _ANIMATIONTYPE_FLOAT;
  91854. /**
  91855. * Vector3 animation type
  91856. */
  91857. private static _ANIMATIONTYPE_VECTOR3;
  91858. /**
  91859. * Quaternion animation type
  91860. */
  91861. private static _ANIMATIONTYPE_QUATERNION;
  91862. /**
  91863. * Matrix animation type
  91864. */
  91865. private static _ANIMATIONTYPE_MATRIX;
  91866. /**
  91867. * Color3 animation type
  91868. */
  91869. private static _ANIMATIONTYPE_COLOR3;
  91870. /**
  91871. * Vector2 animation type
  91872. */
  91873. private static _ANIMATIONTYPE_VECTOR2;
  91874. /**
  91875. * Size animation type
  91876. */
  91877. private static _ANIMATIONTYPE_SIZE;
  91878. /**
  91879. * Relative Loop Mode
  91880. */
  91881. private static _ANIMATIONLOOPMODE_RELATIVE;
  91882. /**
  91883. * Cycle Loop Mode
  91884. */
  91885. private static _ANIMATIONLOOPMODE_CYCLE;
  91886. /**
  91887. * Constant Loop Mode
  91888. */
  91889. private static _ANIMATIONLOOPMODE_CONSTANT;
  91890. /**
  91891. * Get the float animation type
  91892. */
  91893. static readonly ANIMATIONTYPE_FLOAT: number;
  91894. /**
  91895. * Get the Vector3 animation type
  91896. */
  91897. static readonly ANIMATIONTYPE_VECTOR3: number;
  91898. /**
  91899. * Get the Vector2 animation type
  91900. */
  91901. static readonly ANIMATIONTYPE_VECTOR2: number;
  91902. /**
  91903. * Get the Size animation type
  91904. */
  91905. static readonly ANIMATIONTYPE_SIZE: number;
  91906. /**
  91907. * Get the Quaternion animation type
  91908. */
  91909. static readonly ANIMATIONTYPE_QUATERNION: number;
  91910. /**
  91911. * Get the Matrix animation type
  91912. */
  91913. static readonly ANIMATIONTYPE_MATRIX: number;
  91914. /**
  91915. * Get the Color3 animation type
  91916. */
  91917. static readonly ANIMATIONTYPE_COLOR3: number;
  91918. /**
  91919. * Get the Relative Loop Mode
  91920. */
  91921. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91922. /**
  91923. * Get the Cycle Loop Mode
  91924. */
  91925. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91926. /**
  91927. * Get the Constant Loop Mode
  91928. */
  91929. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91930. /** @hidden */
  91931. static _UniversalLerp(left: any, right: any, amount: number): any;
  91932. /**
  91933. * Parses an animation object and creates an animation
  91934. * @param parsedAnimation Parsed animation object
  91935. * @returns Animation object
  91936. */
  91937. static Parse(parsedAnimation: any): Animation;
  91938. /**
  91939. * Appends the serialized animations from the source animations
  91940. * @param source Source containing the animations
  91941. * @param destination Target to store the animations
  91942. */
  91943. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91944. }
  91945. }
  91946. declare module BABYLON {
  91947. /**
  91948. * Interface containing an array of animations
  91949. */
  91950. export interface IAnimatable {
  91951. /**
  91952. * Array of animations
  91953. */
  91954. animations: Nullable<Array<Animation>>;
  91955. }
  91956. }
  91957. declare module BABYLON {
  91958. /**
  91959. * This represents all the required information to add a fresnel effect on a material:
  91960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91961. */
  91962. export class FresnelParameters {
  91963. private _isEnabled;
  91964. /**
  91965. * Define if the fresnel effect is enable or not.
  91966. */
  91967. isEnabled: boolean;
  91968. /**
  91969. * Define the color used on edges (grazing angle)
  91970. */
  91971. leftColor: Color3;
  91972. /**
  91973. * Define the color used on center
  91974. */
  91975. rightColor: Color3;
  91976. /**
  91977. * Define bias applied to computed fresnel term
  91978. */
  91979. bias: number;
  91980. /**
  91981. * Defined the power exponent applied to fresnel term
  91982. */
  91983. power: number;
  91984. /**
  91985. * Clones the current fresnel and its valuues
  91986. * @returns a clone fresnel configuration
  91987. */
  91988. clone(): FresnelParameters;
  91989. /**
  91990. * Serializes the current fresnel parameters to a JSON representation.
  91991. * @return the JSON serialization
  91992. */
  91993. serialize(): any;
  91994. /**
  91995. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91996. * @param parsedFresnelParameters Define the JSON representation
  91997. * @returns the parsed parameters
  91998. */
  91999. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92000. }
  92001. }
  92002. declare module BABYLON {
  92003. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92004. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92005. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92006. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92007. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92008. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92009. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92010. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92011. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92012. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92013. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92014. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92015. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92016. /**
  92017. * Decorator used to define property that can be serialized as reference to a camera
  92018. * @param sourceName defines the name of the property to decorate
  92019. */
  92020. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92021. /**
  92022. * Class used to help serialization objects
  92023. */
  92024. export class SerializationHelper {
  92025. /** @hidden */
  92026. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92027. /** @hidden */
  92028. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92029. /** @hidden */
  92030. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92031. /** @hidden */
  92032. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92033. /**
  92034. * Appends the serialized animations from the source animations
  92035. * @param source Source containing the animations
  92036. * @param destination Target to store the animations
  92037. */
  92038. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92039. /**
  92040. * Static function used to serialized a specific entity
  92041. * @param entity defines the entity to serialize
  92042. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92043. * @returns a JSON compatible object representing the serialization of the entity
  92044. */
  92045. static Serialize<T>(entity: T, serializationObject?: any): any;
  92046. /**
  92047. * Creates a new entity from a serialization data object
  92048. * @param creationFunction defines a function used to instanciated the new entity
  92049. * @param source defines the source serialization data
  92050. * @param scene defines the hosting scene
  92051. * @param rootUrl defines the root url for resources
  92052. * @returns a new entity
  92053. */
  92054. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92055. /**
  92056. * Clones an object
  92057. * @param creationFunction defines the function used to instanciate the new object
  92058. * @param source defines the source object
  92059. * @returns the cloned object
  92060. */
  92061. static Clone<T>(creationFunction: () => T, source: T): T;
  92062. /**
  92063. * Instanciates a new object based on a source one (some data will be shared between both object)
  92064. * @param creationFunction defines the function used to instanciate the new object
  92065. * @param source defines the source object
  92066. * @returns the new object
  92067. */
  92068. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92069. }
  92070. }
  92071. declare module BABYLON {
  92072. /**
  92073. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92074. */
  92075. export interface CubeMapInfo {
  92076. /**
  92077. * The pixel array for the front face.
  92078. * This is stored in format, left to right, up to down format.
  92079. */
  92080. front: Nullable<ArrayBufferView>;
  92081. /**
  92082. * The pixel array for the back face.
  92083. * This is stored in format, left to right, up to down format.
  92084. */
  92085. back: Nullable<ArrayBufferView>;
  92086. /**
  92087. * The pixel array for the left face.
  92088. * This is stored in format, left to right, up to down format.
  92089. */
  92090. left: Nullable<ArrayBufferView>;
  92091. /**
  92092. * The pixel array for the right face.
  92093. * This is stored in format, left to right, up to down format.
  92094. */
  92095. right: Nullable<ArrayBufferView>;
  92096. /**
  92097. * The pixel array for the up face.
  92098. * This is stored in format, left to right, up to down format.
  92099. */
  92100. up: Nullable<ArrayBufferView>;
  92101. /**
  92102. * The pixel array for the down face.
  92103. * This is stored in format, left to right, up to down format.
  92104. */
  92105. down: Nullable<ArrayBufferView>;
  92106. /**
  92107. * The size of the cubemap stored.
  92108. *
  92109. * Each faces will be size * size pixels.
  92110. */
  92111. size: number;
  92112. /**
  92113. * The format of the texture.
  92114. *
  92115. * RGBA, RGB.
  92116. */
  92117. format: number;
  92118. /**
  92119. * The type of the texture data.
  92120. *
  92121. * UNSIGNED_INT, FLOAT.
  92122. */
  92123. type: number;
  92124. /**
  92125. * Specifies whether the texture is in gamma space.
  92126. */
  92127. gammaSpace: boolean;
  92128. }
  92129. /**
  92130. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92131. */
  92132. export class PanoramaToCubeMapTools {
  92133. private static FACE_FRONT;
  92134. private static FACE_BACK;
  92135. private static FACE_RIGHT;
  92136. private static FACE_LEFT;
  92137. private static FACE_DOWN;
  92138. private static FACE_UP;
  92139. /**
  92140. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92141. *
  92142. * @param float32Array The source data.
  92143. * @param inputWidth The width of the input panorama.
  92144. * @param inputHeight The height of the input panorama.
  92145. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92146. * @return The cubemap data
  92147. */
  92148. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92149. private static CreateCubemapTexture;
  92150. private static CalcProjectionSpherical;
  92151. }
  92152. }
  92153. declare module BABYLON {
  92154. /**
  92155. * Helper class dealing with the extraction of spherical polynomial dataArray
  92156. * from a cube map.
  92157. */
  92158. export class CubeMapToSphericalPolynomialTools {
  92159. private static FileFaces;
  92160. /**
  92161. * Converts a texture to the according Spherical Polynomial data.
  92162. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92163. *
  92164. * @param texture The texture to extract the information from.
  92165. * @return The Spherical Polynomial data.
  92166. */
  92167. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92168. /**
  92169. * Converts a cubemap to the according Spherical Polynomial data.
  92170. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92171. *
  92172. * @param cubeInfo The Cube map to extract the information from.
  92173. * @return The Spherical Polynomial data.
  92174. */
  92175. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92176. }
  92177. }
  92178. declare module BABYLON {
  92179. /**
  92180. * Class used to manipulate GUIDs
  92181. */
  92182. export class GUID {
  92183. /**
  92184. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92185. * Be aware Math.random() could cause collisions, but:
  92186. * "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"
  92187. * @returns a pseudo random id
  92188. */
  92189. static RandomId(): string;
  92190. }
  92191. }
  92192. declare module BABYLON {
  92193. /**
  92194. * Base class of all the textures in babylon.
  92195. * It groups all the common properties the materials, post process, lights... might need
  92196. * in order to make a correct use of the texture.
  92197. */
  92198. export class BaseTexture implements IAnimatable {
  92199. /**
  92200. * Default anisotropic filtering level for the application.
  92201. * It is set to 4 as a good tradeoff between perf and quality.
  92202. */
  92203. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92204. /**
  92205. * Gets or sets the unique id of the texture
  92206. */
  92207. uniqueId: number;
  92208. /**
  92209. * Define the name of the texture.
  92210. */
  92211. name: string;
  92212. /**
  92213. * Gets or sets an object used to store user defined information.
  92214. */
  92215. metadata: any;
  92216. /**
  92217. * For internal use only. Please do not use.
  92218. */
  92219. reservedDataStore: any;
  92220. private _hasAlpha;
  92221. /**
  92222. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92223. */
  92224. hasAlpha: boolean;
  92225. /**
  92226. * Defines if the alpha value should be determined via the rgb values.
  92227. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92228. */
  92229. getAlphaFromRGB: boolean;
  92230. /**
  92231. * Intensity or strength of the texture.
  92232. * It is commonly used by materials to fine tune the intensity of the texture
  92233. */
  92234. level: number;
  92235. /**
  92236. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92237. * This is part of the texture as textures usually maps to one uv set.
  92238. */
  92239. coordinatesIndex: number;
  92240. private _coordinatesMode;
  92241. /**
  92242. * How a texture is mapped.
  92243. *
  92244. * | Value | Type | Description |
  92245. * | ----- | ----------------------------------- | ----------- |
  92246. * | 0 | EXPLICIT_MODE | |
  92247. * | 1 | SPHERICAL_MODE | |
  92248. * | 2 | PLANAR_MODE | |
  92249. * | 3 | CUBIC_MODE | |
  92250. * | 4 | PROJECTION_MODE | |
  92251. * | 5 | SKYBOX_MODE | |
  92252. * | 6 | INVCUBIC_MODE | |
  92253. * | 7 | EQUIRECTANGULAR_MODE | |
  92254. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92255. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92256. */
  92257. coordinatesMode: number;
  92258. /**
  92259. * | Value | Type | Description |
  92260. * | ----- | ------------------ | ----------- |
  92261. * | 0 | CLAMP_ADDRESSMODE | |
  92262. * | 1 | WRAP_ADDRESSMODE | |
  92263. * | 2 | MIRROR_ADDRESSMODE | |
  92264. */
  92265. wrapU: number;
  92266. /**
  92267. * | Value | Type | Description |
  92268. * | ----- | ------------------ | ----------- |
  92269. * | 0 | CLAMP_ADDRESSMODE | |
  92270. * | 1 | WRAP_ADDRESSMODE | |
  92271. * | 2 | MIRROR_ADDRESSMODE | |
  92272. */
  92273. wrapV: number;
  92274. /**
  92275. * | Value | Type | Description |
  92276. * | ----- | ------------------ | ----------- |
  92277. * | 0 | CLAMP_ADDRESSMODE | |
  92278. * | 1 | WRAP_ADDRESSMODE | |
  92279. * | 2 | MIRROR_ADDRESSMODE | |
  92280. */
  92281. wrapR: number;
  92282. /**
  92283. * With compliant hardware and browser (supporting anisotropic filtering)
  92284. * this defines the level of anisotropic filtering in the texture.
  92285. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92286. */
  92287. anisotropicFilteringLevel: number;
  92288. /**
  92289. * Define if the texture is a cube texture or if false a 2d texture.
  92290. */
  92291. isCube: boolean;
  92292. /**
  92293. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92294. */
  92295. is3D: boolean;
  92296. /**
  92297. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92298. * HDR texture are usually stored in linear space.
  92299. * This only impacts the PBR and Background materials
  92300. */
  92301. gammaSpace: boolean;
  92302. /**
  92303. * Gets whether or not the texture contains RGBD data.
  92304. */
  92305. readonly isRGBD: boolean;
  92306. /**
  92307. * Is Z inverted in the texture (useful in a cube texture).
  92308. */
  92309. invertZ: boolean;
  92310. /**
  92311. * Are mip maps generated for this texture or not.
  92312. */
  92313. readonly noMipmap: boolean;
  92314. /**
  92315. * @hidden
  92316. */
  92317. lodLevelInAlpha: boolean;
  92318. /**
  92319. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92320. */
  92321. lodGenerationOffset: number;
  92322. /**
  92323. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92324. */
  92325. lodGenerationScale: number;
  92326. /**
  92327. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92328. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92329. * average roughness values.
  92330. */
  92331. linearSpecularLOD: boolean;
  92332. /**
  92333. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92334. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92335. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92336. */
  92337. irradianceTexture: Nullable<BaseTexture>;
  92338. /**
  92339. * Define if the texture is a render target.
  92340. */
  92341. isRenderTarget: boolean;
  92342. /**
  92343. * Define the unique id of the texture in the scene.
  92344. */
  92345. readonly uid: string;
  92346. /**
  92347. * Return a string representation of the texture.
  92348. * @returns the texture as a string
  92349. */
  92350. toString(): string;
  92351. /**
  92352. * Get the class name of the texture.
  92353. * @returns "BaseTexture"
  92354. */
  92355. getClassName(): string;
  92356. /**
  92357. * Define the list of animation attached to the texture.
  92358. */
  92359. animations: Animation[];
  92360. /**
  92361. * An event triggered when the texture is disposed.
  92362. */
  92363. onDisposeObservable: Observable<BaseTexture>;
  92364. private _onDisposeObserver;
  92365. /**
  92366. * Callback triggered when the texture has been disposed.
  92367. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92368. */
  92369. onDispose: () => void;
  92370. /**
  92371. * Define the current state of the loading sequence when in delayed load mode.
  92372. */
  92373. delayLoadState: number;
  92374. private _scene;
  92375. /** @hidden */
  92376. _texture: Nullable<InternalTexture>;
  92377. private _uid;
  92378. /**
  92379. * Define if the texture is preventinga material to render or not.
  92380. * If not and the texture is not ready, the engine will use a default black texture instead.
  92381. */
  92382. readonly isBlocking: boolean;
  92383. /**
  92384. * Instantiates a new BaseTexture.
  92385. * Base class of all the textures in babylon.
  92386. * It groups all the common properties the materials, post process, lights... might need
  92387. * in order to make a correct use of the texture.
  92388. * @param scene Define the scene the texture blongs to
  92389. */
  92390. constructor(scene: Nullable<Scene>);
  92391. /**
  92392. * Get the scene the texture belongs to.
  92393. * @returns the scene or null if undefined
  92394. */
  92395. getScene(): Nullable<Scene>;
  92396. /**
  92397. * Get the texture transform matrix used to offset tile the texture for istance.
  92398. * @returns the transformation matrix
  92399. */
  92400. getTextureMatrix(): Matrix;
  92401. /**
  92402. * Get the texture reflection matrix used to rotate/transform the reflection.
  92403. * @returns the reflection matrix
  92404. */
  92405. getReflectionTextureMatrix(): Matrix;
  92406. /**
  92407. * Get the underlying lower level texture from Babylon.
  92408. * @returns the insternal texture
  92409. */
  92410. getInternalTexture(): Nullable<InternalTexture>;
  92411. /**
  92412. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92413. * @returns true if ready or not blocking
  92414. */
  92415. isReadyOrNotBlocking(): boolean;
  92416. /**
  92417. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92418. * @returns true if fully ready
  92419. */
  92420. isReady(): boolean;
  92421. private _cachedSize;
  92422. /**
  92423. * Get the size of the texture.
  92424. * @returns the texture size.
  92425. */
  92426. getSize(): ISize;
  92427. /**
  92428. * Get the base size of the texture.
  92429. * It can be different from the size if the texture has been resized for POT for instance
  92430. * @returns the base size
  92431. */
  92432. getBaseSize(): ISize;
  92433. /**
  92434. * Update the sampling mode of the texture.
  92435. * Default is Trilinear mode.
  92436. *
  92437. * | Value | Type | Description |
  92438. * | ----- | ------------------ | ----------- |
  92439. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92440. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92441. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92442. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92443. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92444. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92445. * | 7 | NEAREST_LINEAR | |
  92446. * | 8 | NEAREST_NEAREST | |
  92447. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92448. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92449. * | 11 | LINEAR_LINEAR | |
  92450. * | 12 | LINEAR_NEAREST | |
  92451. *
  92452. * > _mag_: magnification filter (close to the viewer)
  92453. * > _min_: minification filter (far from the viewer)
  92454. * > _mip_: filter used between mip map levels
  92455. *@param samplingMode Define the new sampling mode of the texture
  92456. */
  92457. updateSamplingMode(samplingMode: number): void;
  92458. /**
  92459. * Scales the texture if is `canRescale()`
  92460. * @param ratio the resize factor we want to use to rescale
  92461. */
  92462. scale(ratio: number): void;
  92463. /**
  92464. * Get if the texture can rescale.
  92465. */
  92466. readonly canRescale: boolean;
  92467. /** @hidden */
  92468. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92469. /** @hidden */
  92470. _rebuild(): void;
  92471. /**
  92472. * Triggers the load sequence in delayed load mode.
  92473. */
  92474. delayLoad(): void;
  92475. /**
  92476. * Clones the texture.
  92477. * @returns the cloned texture
  92478. */
  92479. clone(): Nullable<BaseTexture>;
  92480. /**
  92481. * Get the texture underlying type (INT, FLOAT...)
  92482. */
  92483. readonly textureType: number;
  92484. /**
  92485. * Get the texture underlying format (RGB, RGBA...)
  92486. */
  92487. readonly textureFormat: number;
  92488. /**
  92489. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92490. * This will returns an RGBA array buffer containing either in values (0-255) or
  92491. * float values (0-1) depending of the underlying buffer type.
  92492. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92493. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92494. * @param buffer defines a user defined buffer to fill with data (can be null)
  92495. * @returns The Array buffer containing the pixels data.
  92496. */
  92497. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92498. /**
  92499. * Release and destroy the underlying lower level texture aka internalTexture.
  92500. */
  92501. releaseInternalTexture(): void;
  92502. /**
  92503. * Get the polynomial representation of the texture data.
  92504. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92505. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92506. */
  92507. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92508. /** @hidden */
  92509. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92510. /** @hidden */
  92511. readonly _lodTextureMid: Nullable<BaseTexture>;
  92512. /** @hidden */
  92513. readonly _lodTextureLow: Nullable<BaseTexture>;
  92514. /**
  92515. * Dispose the texture and release its associated resources.
  92516. */
  92517. dispose(): void;
  92518. /**
  92519. * Serialize the texture into a JSON representation that can be parsed later on.
  92520. * @returns the JSON representation of the texture
  92521. */
  92522. serialize(): any;
  92523. /**
  92524. * Helper function to be called back once a list of texture contains only ready textures.
  92525. * @param textures Define the list of textures to wait for
  92526. * @param callback Define the callback triggered once the entire list will be ready
  92527. */
  92528. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92529. }
  92530. }
  92531. declare module BABYLON {
  92532. /**
  92533. * Class used to store data associated with WebGL texture data for the engine
  92534. * This class should not be used directly
  92535. */
  92536. export class InternalTexture {
  92537. /** @hidden */
  92538. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92539. /**
  92540. * The source of the texture data is unknown
  92541. */
  92542. static DATASOURCE_UNKNOWN: number;
  92543. /**
  92544. * Texture data comes from an URL
  92545. */
  92546. static DATASOURCE_URL: number;
  92547. /**
  92548. * Texture data is only used for temporary storage
  92549. */
  92550. static DATASOURCE_TEMP: number;
  92551. /**
  92552. * Texture data comes from raw data (ArrayBuffer)
  92553. */
  92554. static DATASOURCE_RAW: number;
  92555. /**
  92556. * Texture content is dynamic (video or dynamic texture)
  92557. */
  92558. static DATASOURCE_DYNAMIC: number;
  92559. /**
  92560. * Texture content is generated by rendering to it
  92561. */
  92562. static DATASOURCE_RENDERTARGET: number;
  92563. /**
  92564. * Texture content is part of a multi render target process
  92565. */
  92566. static DATASOURCE_MULTIRENDERTARGET: number;
  92567. /**
  92568. * Texture data comes from a cube data file
  92569. */
  92570. static DATASOURCE_CUBE: number;
  92571. /**
  92572. * Texture data comes from a raw cube data
  92573. */
  92574. static DATASOURCE_CUBERAW: number;
  92575. /**
  92576. * Texture data come from a prefiltered cube data file
  92577. */
  92578. static DATASOURCE_CUBEPREFILTERED: number;
  92579. /**
  92580. * Texture content is raw 3D data
  92581. */
  92582. static DATASOURCE_RAW3D: number;
  92583. /**
  92584. * Texture content is a depth texture
  92585. */
  92586. static DATASOURCE_DEPTHTEXTURE: number;
  92587. /**
  92588. * Texture data comes from a raw cube data encoded with RGBD
  92589. */
  92590. static DATASOURCE_CUBERAW_RGBD: number;
  92591. /**
  92592. * Defines if the texture is ready
  92593. */
  92594. isReady: boolean;
  92595. /**
  92596. * Defines if the texture is a cube texture
  92597. */
  92598. isCube: boolean;
  92599. /**
  92600. * Defines if the texture contains 3D data
  92601. */
  92602. is3D: boolean;
  92603. /**
  92604. * Defines if the texture contains multiview data
  92605. */
  92606. isMultiview: boolean;
  92607. /**
  92608. * Gets the URL used to load this texture
  92609. */
  92610. url: string;
  92611. /**
  92612. * Gets the sampling mode of the texture
  92613. */
  92614. samplingMode: number;
  92615. /**
  92616. * Gets a boolean indicating if the texture needs mipmaps generation
  92617. */
  92618. generateMipMaps: boolean;
  92619. /**
  92620. * Gets the number of samples used by the texture (WebGL2+ only)
  92621. */
  92622. samples: number;
  92623. /**
  92624. * Gets the type of the texture (int, float...)
  92625. */
  92626. type: number;
  92627. /**
  92628. * Gets the format of the texture (RGB, RGBA...)
  92629. */
  92630. format: number;
  92631. /**
  92632. * Observable called when the texture is loaded
  92633. */
  92634. onLoadedObservable: Observable<InternalTexture>;
  92635. /**
  92636. * Gets the width of the texture
  92637. */
  92638. width: number;
  92639. /**
  92640. * Gets the height of the texture
  92641. */
  92642. height: number;
  92643. /**
  92644. * Gets the depth of the texture
  92645. */
  92646. depth: number;
  92647. /**
  92648. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92649. */
  92650. baseWidth: number;
  92651. /**
  92652. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92653. */
  92654. baseHeight: number;
  92655. /**
  92656. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92657. */
  92658. baseDepth: number;
  92659. /**
  92660. * Gets a boolean indicating if the texture is inverted on Y axis
  92661. */
  92662. invertY: boolean;
  92663. /** @hidden */
  92664. _invertVScale: boolean;
  92665. /** @hidden */
  92666. _associatedChannel: number;
  92667. /** @hidden */
  92668. _dataSource: number;
  92669. /** @hidden */
  92670. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92671. /** @hidden */
  92672. _bufferView: Nullable<ArrayBufferView>;
  92673. /** @hidden */
  92674. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92675. /** @hidden */
  92676. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92677. /** @hidden */
  92678. _size: number;
  92679. /** @hidden */
  92680. _extension: string;
  92681. /** @hidden */
  92682. _files: Nullable<string[]>;
  92683. /** @hidden */
  92684. _workingCanvas: Nullable<HTMLCanvasElement>;
  92685. /** @hidden */
  92686. _workingContext: Nullable<CanvasRenderingContext2D>;
  92687. /** @hidden */
  92688. _framebuffer: Nullable<WebGLFramebuffer>;
  92689. /** @hidden */
  92690. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92691. /** @hidden */
  92692. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92693. /** @hidden */
  92694. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92695. /** @hidden */
  92696. _attachments: Nullable<number[]>;
  92697. /** @hidden */
  92698. _cachedCoordinatesMode: Nullable<number>;
  92699. /** @hidden */
  92700. _cachedWrapU: Nullable<number>;
  92701. /** @hidden */
  92702. _cachedWrapV: Nullable<number>;
  92703. /** @hidden */
  92704. _cachedWrapR: Nullable<number>;
  92705. /** @hidden */
  92706. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92707. /** @hidden */
  92708. _isDisabled: boolean;
  92709. /** @hidden */
  92710. _compression: Nullable<string>;
  92711. /** @hidden */
  92712. _generateStencilBuffer: boolean;
  92713. /** @hidden */
  92714. _generateDepthBuffer: boolean;
  92715. /** @hidden */
  92716. _comparisonFunction: number;
  92717. /** @hidden */
  92718. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92719. /** @hidden */
  92720. _lodGenerationScale: number;
  92721. /** @hidden */
  92722. _lodGenerationOffset: number;
  92723. /** @hidden */
  92724. _colorTextureArray: Nullable<WebGLTexture>;
  92725. /** @hidden */
  92726. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92727. /** @hidden */
  92728. _lodTextureHigh: Nullable<BaseTexture>;
  92729. /** @hidden */
  92730. _lodTextureMid: Nullable<BaseTexture>;
  92731. /** @hidden */
  92732. _lodTextureLow: Nullable<BaseTexture>;
  92733. /** @hidden */
  92734. _isRGBD: boolean;
  92735. /** @hidden */
  92736. _linearSpecularLOD: boolean;
  92737. /** @hidden */
  92738. _irradianceTexture: Nullable<BaseTexture>;
  92739. /** @hidden */
  92740. _webGLTexture: Nullable<WebGLTexture>;
  92741. /** @hidden */
  92742. _references: number;
  92743. private _engine;
  92744. /**
  92745. * Gets the Engine the texture belongs to.
  92746. * @returns The babylon engine
  92747. */
  92748. getEngine(): Engine;
  92749. /**
  92750. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92751. */
  92752. readonly dataSource: number;
  92753. /**
  92754. * Creates a new InternalTexture
  92755. * @param engine defines the engine to use
  92756. * @param dataSource defines the type of data that will be used
  92757. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92758. */
  92759. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92760. /**
  92761. * Increments the number of references (ie. the number of Texture that point to it)
  92762. */
  92763. incrementReferences(): void;
  92764. /**
  92765. * Change the size of the texture (not the size of the content)
  92766. * @param width defines the new width
  92767. * @param height defines the new height
  92768. * @param depth defines the new depth (1 by default)
  92769. */
  92770. updateSize(width: int, height: int, depth?: int): void;
  92771. /** @hidden */
  92772. _rebuild(): void;
  92773. /** @hidden */
  92774. _swapAndDie(target: InternalTexture): void;
  92775. /**
  92776. * Dispose the current allocated resources
  92777. */
  92778. dispose(): void;
  92779. }
  92780. }
  92781. declare module BABYLON {
  92782. /**
  92783. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92784. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92785. */
  92786. export class EffectFallbacks {
  92787. private _defines;
  92788. private _currentRank;
  92789. private _maxRank;
  92790. private _mesh;
  92791. /**
  92792. * Removes the fallback from the bound mesh.
  92793. */
  92794. unBindMesh(): void;
  92795. /**
  92796. * Adds a fallback on the specified property.
  92797. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92798. * @param define The name of the define in the shader
  92799. */
  92800. addFallback(rank: number, define: string): void;
  92801. /**
  92802. * Sets the mesh to use CPU skinning when needing to fallback.
  92803. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92804. * @param mesh The mesh to use the fallbacks.
  92805. */
  92806. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92807. /**
  92808. * Checks to see if more fallbacks are still availible.
  92809. */
  92810. readonly isMoreFallbacks: boolean;
  92811. /**
  92812. * Removes the defines that should be removed when falling back.
  92813. * @param currentDefines defines the current define statements for the shader.
  92814. * @param effect defines the current effect we try to compile
  92815. * @returns The resulting defines with defines of the current rank removed.
  92816. */
  92817. reduce(currentDefines: string, effect: Effect): string;
  92818. }
  92819. /**
  92820. * Options to be used when creating an effect.
  92821. */
  92822. export class EffectCreationOptions {
  92823. /**
  92824. * Atrributes that will be used in the shader.
  92825. */
  92826. attributes: string[];
  92827. /**
  92828. * Uniform varible names that will be set in the shader.
  92829. */
  92830. uniformsNames: string[];
  92831. /**
  92832. * Uniform buffer varible names that will be set in the shader.
  92833. */
  92834. uniformBuffersNames: string[];
  92835. /**
  92836. * Sampler texture variable names that will be set in the shader.
  92837. */
  92838. samplers: string[];
  92839. /**
  92840. * Define statements that will be set in the shader.
  92841. */
  92842. defines: any;
  92843. /**
  92844. * Possible fallbacks for this effect to improve performance when needed.
  92845. */
  92846. fallbacks: Nullable<EffectFallbacks>;
  92847. /**
  92848. * Callback that will be called when the shader is compiled.
  92849. */
  92850. onCompiled: Nullable<(effect: Effect) => void>;
  92851. /**
  92852. * Callback that will be called if an error occurs during shader compilation.
  92853. */
  92854. onError: Nullable<(effect: Effect, errors: string) => void>;
  92855. /**
  92856. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92857. */
  92858. indexParameters: any;
  92859. /**
  92860. * Max number of lights that can be used in the shader.
  92861. */
  92862. maxSimultaneousLights: number;
  92863. /**
  92864. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92865. */
  92866. transformFeedbackVaryings: Nullable<string[]>;
  92867. }
  92868. /**
  92869. * Effect containing vertex and fragment shader that can be executed on an object.
  92870. */
  92871. export class Effect implements IDisposable {
  92872. /**
  92873. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92874. */
  92875. static ShadersRepository: string;
  92876. /**
  92877. * Name of the effect.
  92878. */
  92879. name: any;
  92880. /**
  92881. * String container all the define statements that should be set on the shader.
  92882. */
  92883. defines: string;
  92884. /**
  92885. * Callback that will be called when the shader is compiled.
  92886. */
  92887. onCompiled: Nullable<(effect: Effect) => void>;
  92888. /**
  92889. * Callback that will be called if an error occurs during shader compilation.
  92890. */
  92891. onError: Nullable<(effect: Effect, errors: string) => void>;
  92892. /**
  92893. * Callback that will be called when effect is bound.
  92894. */
  92895. onBind: Nullable<(effect: Effect) => void>;
  92896. /**
  92897. * Unique ID of the effect.
  92898. */
  92899. uniqueId: number;
  92900. /**
  92901. * Observable that will be called when the shader is compiled.
  92902. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92903. */
  92904. onCompileObservable: Observable<Effect>;
  92905. /**
  92906. * Observable that will be called if an error occurs during shader compilation.
  92907. */
  92908. onErrorObservable: Observable<Effect>;
  92909. /** @hidden */
  92910. _onBindObservable: Nullable<Observable<Effect>>;
  92911. /**
  92912. * Observable that will be called when effect is bound.
  92913. */
  92914. readonly onBindObservable: Observable<Effect>;
  92915. /** @hidden */
  92916. _bonesComputationForcedToCPU: boolean;
  92917. private static _uniqueIdSeed;
  92918. private _engine;
  92919. private _uniformBuffersNames;
  92920. private _uniformsNames;
  92921. private _samplerList;
  92922. private _samplers;
  92923. private _isReady;
  92924. private _compilationError;
  92925. private _attributesNames;
  92926. private _attributes;
  92927. private _uniforms;
  92928. /**
  92929. * Key for the effect.
  92930. * @hidden
  92931. */
  92932. _key: string;
  92933. private _indexParameters;
  92934. private _fallbacks;
  92935. private _vertexSourceCode;
  92936. private _fragmentSourceCode;
  92937. private _vertexSourceCodeOverride;
  92938. private _fragmentSourceCodeOverride;
  92939. private _transformFeedbackVaryings;
  92940. /**
  92941. * Compiled shader to webGL program.
  92942. * @hidden
  92943. */
  92944. _pipelineContext: Nullable<IPipelineContext>;
  92945. private _valueCache;
  92946. private static _baseCache;
  92947. /**
  92948. * Instantiates an effect.
  92949. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92950. * @param baseName Name of the effect.
  92951. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92952. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92953. * @param samplers List of sampler variables that will be passed to the shader.
  92954. * @param engine Engine to be used to render the effect
  92955. * @param defines Define statements to be added to the shader.
  92956. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92957. * @param onCompiled Callback that will be called when the shader is compiled.
  92958. * @param onError Callback that will be called if an error occurs during shader compilation.
  92959. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92960. */
  92961. 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);
  92962. private _useFinalCode;
  92963. /**
  92964. * Unique key for this effect
  92965. */
  92966. readonly key: string;
  92967. /**
  92968. * If the effect has been compiled and prepared.
  92969. * @returns if the effect is compiled and prepared.
  92970. */
  92971. isReady(): boolean;
  92972. /**
  92973. * The engine the effect was initialized with.
  92974. * @returns the engine.
  92975. */
  92976. getEngine(): Engine;
  92977. /**
  92978. * The pipeline context for this effect
  92979. * @returns the associated pipeline context
  92980. */
  92981. getPipelineContext(): Nullable<IPipelineContext>;
  92982. /**
  92983. * The set of names of attribute variables for the shader.
  92984. * @returns An array of attribute names.
  92985. */
  92986. getAttributesNames(): string[];
  92987. /**
  92988. * Returns the attribute at the given index.
  92989. * @param index The index of the attribute.
  92990. * @returns The location of the attribute.
  92991. */
  92992. getAttributeLocation(index: number): number;
  92993. /**
  92994. * Returns the attribute based on the name of the variable.
  92995. * @param name of the attribute to look up.
  92996. * @returns the attribute location.
  92997. */
  92998. getAttributeLocationByName(name: string): number;
  92999. /**
  93000. * The number of attributes.
  93001. * @returns the numnber of attributes.
  93002. */
  93003. getAttributesCount(): number;
  93004. /**
  93005. * Gets the index of a uniform variable.
  93006. * @param uniformName of the uniform to look up.
  93007. * @returns the index.
  93008. */
  93009. getUniformIndex(uniformName: string): number;
  93010. /**
  93011. * Returns the attribute based on the name of the variable.
  93012. * @param uniformName of the uniform to look up.
  93013. * @returns the location of the uniform.
  93014. */
  93015. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93016. /**
  93017. * Returns an array of sampler variable names
  93018. * @returns The array of sampler variable neames.
  93019. */
  93020. getSamplers(): string[];
  93021. /**
  93022. * The error from the last compilation.
  93023. * @returns the error string.
  93024. */
  93025. getCompilationError(): string;
  93026. /**
  93027. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93028. * @param func The callback to be used.
  93029. */
  93030. executeWhenCompiled(func: (effect: Effect) => void): void;
  93031. private _checkIsReady;
  93032. /** @hidden */
  93033. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93034. /** @hidden */
  93035. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93036. /** @hidden */
  93037. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93038. /**
  93039. * Recompiles the webGL program
  93040. * @param vertexSourceCode The source code for the vertex shader.
  93041. * @param fragmentSourceCode The source code for the fragment shader.
  93042. * @param onCompiled Callback called when completed.
  93043. * @param onError Callback called on error.
  93044. * @hidden
  93045. */
  93046. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93047. /**
  93048. * Prepares the effect
  93049. * @hidden
  93050. */
  93051. _prepareEffect(): void;
  93052. private _processCompilationErrors;
  93053. /**
  93054. * Checks if the effect is supported. (Must be called after compilation)
  93055. */
  93056. readonly isSupported: boolean;
  93057. /**
  93058. * Binds a texture to the engine to be used as output of the shader.
  93059. * @param channel Name of the output variable.
  93060. * @param texture Texture to bind.
  93061. * @hidden
  93062. */
  93063. _bindTexture(channel: string, texture: InternalTexture): void;
  93064. /**
  93065. * Sets a texture on the engine to be used in the shader.
  93066. * @param channel Name of the sampler variable.
  93067. * @param texture Texture to set.
  93068. */
  93069. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93070. /**
  93071. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93072. * @param channel Name of the sampler variable.
  93073. * @param texture Texture to set.
  93074. */
  93075. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93076. /**
  93077. * Sets an array of textures on the engine to be used in the shader.
  93078. * @param channel Name of the variable.
  93079. * @param textures Textures to set.
  93080. */
  93081. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93082. /**
  93083. * 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)
  93084. * @param channel Name of the sampler variable.
  93085. * @param postProcess Post process to get the input texture from.
  93086. */
  93087. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93088. /**
  93089. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93090. * 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)
  93091. * @param channel Name of the sampler variable.
  93092. * @param postProcess Post process to get the output texture from.
  93093. */
  93094. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93095. /** @hidden */
  93096. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93097. /** @hidden */
  93098. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93099. /** @hidden */
  93100. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93101. /** @hidden */
  93102. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93103. /**
  93104. * Binds a buffer to a uniform.
  93105. * @param buffer Buffer to bind.
  93106. * @param name Name of the uniform variable to bind to.
  93107. */
  93108. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93109. /**
  93110. * Binds block to a uniform.
  93111. * @param blockName Name of the block to bind.
  93112. * @param index Index to bind.
  93113. */
  93114. bindUniformBlock(blockName: string, index: number): void;
  93115. /**
  93116. * Sets an interger value on a uniform variable.
  93117. * @param uniformName Name of the variable.
  93118. * @param value Value to be set.
  93119. * @returns this effect.
  93120. */
  93121. setInt(uniformName: string, value: number): Effect;
  93122. /**
  93123. * Sets an int array on a uniform variable.
  93124. * @param uniformName Name of the variable.
  93125. * @param array array to be set.
  93126. * @returns this effect.
  93127. */
  93128. setIntArray(uniformName: string, array: Int32Array): Effect;
  93129. /**
  93130. * 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)
  93131. * @param uniformName Name of the variable.
  93132. * @param array array to be set.
  93133. * @returns this effect.
  93134. */
  93135. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93136. /**
  93137. * 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)
  93138. * @param uniformName Name of the variable.
  93139. * @param array array to be set.
  93140. * @returns this effect.
  93141. */
  93142. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93143. /**
  93144. * 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)
  93145. * @param uniformName Name of the variable.
  93146. * @param array array to be set.
  93147. * @returns this effect.
  93148. */
  93149. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93150. /**
  93151. * Sets an float array on a uniform variable.
  93152. * @param uniformName Name of the variable.
  93153. * @param array array to be set.
  93154. * @returns this effect.
  93155. */
  93156. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93157. /**
  93158. * 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)
  93159. * @param uniformName Name of the variable.
  93160. * @param array array to be set.
  93161. * @returns this effect.
  93162. */
  93163. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93164. /**
  93165. * 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)
  93166. * @param uniformName Name of the variable.
  93167. * @param array array to be set.
  93168. * @returns this effect.
  93169. */
  93170. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93171. /**
  93172. * 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)
  93173. * @param uniformName Name of the variable.
  93174. * @param array array to be set.
  93175. * @returns this effect.
  93176. */
  93177. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93178. /**
  93179. * Sets an array on a uniform variable.
  93180. * @param uniformName Name of the variable.
  93181. * @param array array to be set.
  93182. * @returns this effect.
  93183. */
  93184. setArray(uniformName: string, array: number[]): Effect;
  93185. /**
  93186. * 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)
  93187. * @param uniformName Name of the variable.
  93188. * @param array array to be set.
  93189. * @returns this effect.
  93190. */
  93191. setArray2(uniformName: string, array: number[]): Effect;
  93192. /**
  93193. * 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)
  93194. * @param uniformName Name of the variable.
  93195. * @param array array to be set.
  93196. * @returns this effect.
  93197. */
  93198. setArray3(uniformName: string, array: number[]): Effect;
  93199. /**
  93200. * 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)
  93201. * @param uniformName Name of the variable.
  93202. * @param array array to be set.
  93203. * @returns this effect.
  93204. */
  93205. setArray4(uniformName: string, array: number[]): Effect;
  93206. /**
  93207. * Sets matrices on a uniform variable.
  93208. * @param uniformName Name of the variable.
  93209. * @param matrices matrices to be set.
  93210. * @returns this effect.
  93211. */
  93212. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93213. /**
  93214. * Sets matrix on a uniform variable.
  93215. * @param uniformName Name of the variable.
  93216. * @param matrix matrix to be set.
  93217. * @returns this effect.
  93218. */
  93219. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93220. /**
  93221. * 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)
  93222. * @param uniformName Name of the variable.
  93223. * @param matrix matrix to be set.
  93224. * @returns this effect.
  93225. */
  93226. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93227. /**
  93228. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93229. * @param uniformName Name of the variable.
  93230. * @param matrix matrix to be set.
  93231. * @returns this effect.
  93232. */
  93233. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93234. /**
  93235. * Sets a float on a uniform variable.
  93236. * @param uniformName Name of the variable.
  93237. * @param value value to be set.
  93238. * @returns this effect.
  93239. */
  93240. setFloat(uniformName: string, value: number): Effect;
  93241. /**
  93242. * Sets a boolean on a uniform variable.
  93243. * @param uniformName Name of the variable.
  93244. * @param bool value to be set.
  93245. * @returns this effect.
  93246. */
  93247. setBool(uniformName: string, bool: boolean): Effect;
  93248. /**
  93249. * Sets a Vector2 on a uniform variable.
  93250. * @param uniformName Name of the variable.
  93251. * @param vector2 vector2 to be set.
  93252. * @returns this effect.
  93253. */
  93254. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93255. /**
  93256. * Sets a float2 on a uniform variable.
  93257. * @param uniformName Name of the variable.
  93258. * @param x First float in float2.
  93259. * @param y Second float in float2.
  93260. * @returns this effect.
  93261. */
  93262. setFloat2(uniformName: string, x: number, y: number): Effect;
  93263. /**
  93264. * Sets a Vector3 on a uniform variable.
  93265. * @param uniformName Name of the variable.
  93266. * @param vector3 Value to be set.
  93267. * @returns this effect.
  93268. */
  93269. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93270. /**
  93271. * Sets a float3 on a uniform variable.
  93272. * @param uniformName Name of the variable.
  93273. * @param x First float in float3.
  93274. * @param y Second float in float3.
  93275. * @param z Third float in float3.
  93276. * @returns this effect.
  93277. */
  93278. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93279. /**
  93280. * Sets a Vector4 on a uniform variable.
  93281. * @param uniformName Name of the variable.
  93282. * @param vector4 Value to be set.
  93283. * @returns this effect.
  93284. */
  93285. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93286. /**
  93287. * Sets a float4 on a uniform variable.
  93288. * @param uniformName Name of the variable.
  93289. * @param x First float in float4.
  93290. * @param y Second float in float4.
  93291. * @param z Third float in float4.
  93292. * @param w Fourth float in float4.
  93293. * @returns this effect.
  93294. */
  93295. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93296. /**
  93297. * Sets a Color3 on a uniform variable.
  93298. * @param uniformName Name of the variable.
  93299. * @param color3 Value to be set.
  93300. * @returns this effect.
  93301. */
  93302. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93303. /**
  93304. * Sets a Color4 on a uniform variable.
  93305. * @param uniformName Name of the variable.
  93306. * @param color3 Value to be set.
  93307. * @param alpha Alpha value to be set.
  93308. * @returns this effect.
  93309. */
  93310. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93311. /**
  93312. * Sets a Color4 on a uniform variable
  93313. * @param uniformName defines the name of the variable
  93314. * @param color4 defines the value to be set
  93315. * @returns this effect.
  93316. */
  93317. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93318. /** Release all associated resources */
  93319. dispose(): void;
  93320. /**
  93321. * This function will add a new shader to the shader store
  93322. * @param name the name of the shader
  93323. * @param pixelShader optional pixel shader content
  93324. * @param vertexShader optional vertex shader content
  93325. */
  93326. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93327. /**
  93328. * Store of each shader (The can be looked up using effect.key)
  93329. */
  93330. static ShadersStore: {
  93331. [key: string]: string;
  93332. };
  93333. /**
  93334. * Store of each included file for a shader (The can be looked up using effect.key)
  93335. */
  93336. static IncludesShadersStore: {
  93337. [key: string]: string;
  93338. };
  93339. /**
  93340. * Resets the cache of effects.
  93341. */
  93342. static ResetCache(): void;
  93343. }
  93344. }
  93345. declare module BABYLON {
  93346. /**
  93347. * Uniform buffer objects.
  93348. *
  93349. * Handles blocks of uniform on the GPU.
  93350. *
  93351. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93352. *
  93353. * For more information, please refer to :
  93354. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93355. */
  93356. export class UniformBuffer {
  93357. private _engine;
  93358. private _buffer;
  93359. private _data;
  93360. private _bufferData;
  93361. private _dynamic?;
  93362. private _uniformLocations;
  93363. private _uniformSizes;
  93364. private _uniformLocationPointer;
  93365. private _needSync;
  93366. private _noUBO;
  93367. private _currentEffect;
  93368. private static _MAX_UNIFORM_SIZE;
  93369. private static _tempBuffer;
  93370. /**
  93371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93372. * This is dynamic to allow compat with webgl 1 and 2.
  93373. * You will need to pass the name of the uniform as well as the value.
  93374. */
  93375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93376. /**
  93377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93378. * This is dynamic to allow compat with webgl 1 and 2.
  93379. * You will need to pass the name of the uniform as well as the value.
  93380. */
  93381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93382. /**
  93383. * Lambda to Update a single float in a uniform buffer.
  93384. * This is dynamic to allow compat with webgl 1 and 2.
  93385. * You will need to pass the name of the uniform as well as the value.
  93386. */
  93387. updateFloat: (name: string, x: number) => void;
  93388. /**
  93389. * Lambda to Update a vec2 of float in a uniform buffer.
  93390. * This is dynamic to allow compat with webgl 1 and 2.
  93391. * You will need to pass the name of the uniform as well as the value.
  93392. */
  93393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93394. /**
  93395. * Lambda to Update a vec3 of float in a uniform buffer.
  93396. * This is dynamic to allow compat with webgl 1 and 2.
  93397. * You will need to pass the name of the uniform as well as the value.
  93398. */
  93399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93400. /**
  93401. * Lambda to Update a vec4 of float in a uniform buffer.
  93402. * This is dynamic to allow compat with webgl 1 and 2.
  93403. * You will need to pass the name of the uniform as well as the value.
  93404. */
  93405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93406. /**
  93407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93408. * This is dynamic to allow compat with webgl 1 and 2.
  93409. * You will need to pass the name of the uniform as well as the value.
  93410. */
  93411. updateMatrix: (name: string, mat: Matrix) => void;
  93412. /**
  93413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93414. * This is dynamic to allow compat with webgl 1 and 2.
  93415. * You will need to pass the name of the uniform as well as the value.
  93416. */
  93417. updateVector3: (name: string, vector: Vector3) => void;
  93418. /**
  93419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93420. * This is dynamic to allow compat with webgl 1 and 2.
  93421. * You will need to pass the name of the uniform as well as the value.
  93422. */
  93423. updateVector4: (name: string, vector: Vector4) => void;
  93424. /**
  93425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93426. * This is dynamic to allow compat with webgl 1 and 2.
  93427. * You will need to pass the name of the uniform as well as the value.
  93428. */
  93429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93430. /**
  93431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93432. * This is dynamic to allow compat with webgl 1 and 2.
  93433. * You will need to pass the name of the uniform as well as the value.
  93434. */
  93435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93436. /**
  93437. * Instantiates a new Uniform buffer objects.
  93438. *
  93439. * Handles blocks of uniform on the GPU.
  93440. *
  93441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93442. *
  93443. * For more information, please refer to :
  93444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93445. * @param engine Define the engine the buffer is associated with
  93446. * @param data Define the data contained in the buffer
  93447. * @param dynamic Define if the buffer is updatable
  93448. */
  93449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93450. /**
  93451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93452. * or just falling back on setUniformXXX calls.
  93453. */
  93454. readonly useUbo: boolean;
  93455. /**
  93456. * Indicates if the WebGL underlying uniform buffer is in sync
  93457. * with the javascript cache data.
  93458. */
  93459. readonly isSync: boolean;
  93460. /**
  93461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93462. * Also, a dynamic UniformBuffer will disable cache verification and always
  93463. * update the underlying WebGL uniform buffer to the GPU.
  93464. * @returns if Dynamic, otherwise false
  93465. */
  93466. isDynamic(): boolean;
  93467. /**
  93468. * The data cache on JS side.
  93469. * @returns the underlying data as a float array
  93470. */
  93471. getData(): Float32Array;
  93472. /**
  93473. * The underlying WebGL Uniform buffer.
  93474. * @returns the webgl buffer
  93475. */
  93476. getBuffer(): Nullable<DataBuffer>;
  93477. /**
  93478. * std140 layout specifies how to align data within an UBO structure.
  93479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93480. * for specs.
  93481. */
  93482. private _fillAlignment;
  93483. /**
  93484. * Adds an uniform in the buffer.
  93485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93486. * for the layout to be correct !
  93487. * @param name Name of the uniform, as used in the uniform block in the shader.
  93488. * @param size Data size, or data directly.
  93489. */
  93490. addUniform(name: string, size: number | number[]): void;
  93491. /**
  93492. * Adds a Matrix 4x4 to the uniform buffer.
  93493. * @param name Name of the uniform, as used in the uniform block in the shader.
  93494. * @param mat A 4x4 matrix.
  93495. */
  93496. addMatrix(name: string, mat: Matrix): void;
  93497. /**
  93498. * Adds a vec2 to the uniform buffer.
  93499. * @param name Name of the uniform, as used in the uniform block in the shader.
  93500. * @param x Define the x component value of the vec2
  93501. * @param y Define the y component value of the vec2
  93502. */
  93503. addFloat2(name: string, x: number, y: number): void;
  93504. /**
  93505. * Adds a vec3 to the uniform buffer.
  93506. * @param name Name of the uniform, as used in the uniform block in the shader.
  93507. * @param x Define the x component value of the vec3
  93508. * @param y Define the y component value of the vec3
  93509. * @param z Define the z component value of the vec3
  93510. */
  93511. addFloat3(name: string, x: number, y: number, z: number): void;
  93512. /**
  93513. * Adds a vec3 to the uniform buffer.
  93514. * @param name Name of the uniform, as used in the uniform block in the shader.
  93515. * @param color Define the vec3 from a Color
  93516. */
  93517. addColor3(name: string, color: Color3): void;
  93518. /**
  93519. * Adds a vec4 to the uniform buffer.
  93520. * @param name Name of the uniform, as used in the uniform block in the shader.
  93521. * @param color Define the rgb components from a Color
  93522. * @param alpha Define the a component of the vec4
  93523. */
  93524. addColor4(name: string, color: Color3, alpha: number): void;
  93525. /**
  93526. * Adds a vec3 to the uniform buffer.
  93527. * @param name Name of the uniform, as used in the uniform block in the shader.
  93528. * @param vector Define the vec3 components from a Vector
  93529. */
  93530. addVector3(name: string, vector: Vector3): void;
  93531. /**
  93532. * Adds a Matrix 3x3 to the uniform buffer.
  93533. * @param name Name of the uniform, as used in the uniform block in the shader.
  93534. */
  93535. addMatrix3x3(name: string): void;
  93536. /**
  93537. * Adds a Matrix 2x2 to the uniform buffer.
  93538. * @param name Name of the uniform, as used in the uniform block in the shader.
  93539. */
  93540. addMatrix2x2(name: string): void;
  93541. /**
  93542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93543. */
  93544. create(): void;
  93545. /** @hidden */
  93546. _rebuild(): void;
  93547. /**
  93548. * Updates the WebGL Uniform Buffer on the GPU.
  93549. * If the `dynamic` flag is set to true, no cache comparison is done.
  93550. * Otherwise, the buffer will be updated only if the cache differs.
  93551. */
  93552. update(): void;
  93553. /**
  93554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93556. * @param data Define the flattened data
  93557. * @param size Define the size of the data.
  93558. */
  93559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93560. private _valueCache;
  93561. private _cacheMatrix;
  93562. private _updateMatrix3x3ForUniform;
  93563. private _updateMatrix3x3ForEffect;
  93564. private _updateMatrix2x2ForEffect;
  93565. private _updateMatrix2x2ForUniform;
  93566. private _updateFloatForEffect;
  93567. private _updateFloatForUniform;
  93568. private _updateFloat2ForEffect;
  93569. private _updateFloat2ForUniform;
  93570. private _updateFloat3ForEffect;
  93571. private _updateFloat3ForUniform;
  93572. private _updateFloat4ForEffect;
  93573. private _updateFloat4ForUniform;
  93574. private _updateMatrixForEffect;
  93575. private _updateMatrixForUniform;
  93576. private _updateVector3ForEffect;
  93577. private _updateVector3ForUniform;
  93578. private _updateVector4ForEffect;
  93579. private _updateVector4ForUniform;
  93580. private _updateColor3ForEffect;
  93581. private _updateColor3ForUniform;
  93582. private _updateColor4ForEffect;
  93583. private _updateColor4ForUniform;
  93584. /**
  93585. * Sets a sampler uniform on the effect.
  93586. * @param name Define the name of the sampler.
  93587. * @param texture Define the texture to set in the sampler
  93588. */
  93589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93590. /**
  93591. * Directly updates the value of the uniform in the cache AND on the GPU.
  93592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93593. * @param data Define the flattened data
  93594. */
  93595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93596. /**
  93597. * Binds this uniform buffer to an effect.
  93598. * @param effect Define the effect to bind the buffer to
  93599. * @param name Name of the uniform block in the shader.
  93600. */
  93601. bindToEffect(effect: Effect, name: string): void;
  93602. /**
  93603. * Disposes the uniform buffer.
  93604. */
  93605. dispose(): void;
  93606. }
  93607. }
  93608. declare module BABYLON {
  93609. /**
  93610. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93612. */
  93613. export class Analyser {
  93614. /**
  93615. * Gets or sets the smoothing
  93616. * @ignorenaming
  93617. */
  93618. SMOOTHING: number;
  93619. /**
  93620. * Gets or sets the FFT table size
  93621. * @ignorenaming
  93622. */
  93623. FFT_SIZE: number;
  93624. /**
  93625. * Gets or sets the bar graph amplitude
  93626. * @ignorenaming
  93627. */
  93628. BARGRAPHAMPLITUDE: number;
  93629. /**
  93630. * Gets or sets the position of the debug canvas
  93631. * @ignorenaming
  93632. */
  93633. DEBUGCANVASPOS: {
  93634. x: number;
  93635. y: number;
  93636. };
  93637. /**
  93638. * Gets or sets the debug canvas size
  93639. * @ignorenaming
  93640. */
  93641. DEBUGCANVASSIZE: {
  93642. width: number;
  93643. height: number;
  93644. };
  93645. private _byteFreqs;
  93646. private _byteTime;
  93647. private _floatFreqs;
  93648. private _webAudioAnalyser;
  93649. private _debugCanvas;
  93650. private _debugCanvasContext;
  93651. private _scene;
  93652. private _registerFunc;
  93653. private _audioEngine;
  93654. /**
  93655. * Creates a new analyser
  93656. * @param scene defines hosting scene
  93657. */
  93658. constructor(scene: Scene);
  93659. /**
  93660. * Get the number of data values you will have to play with for the visualization
  93661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93662. * @returns a number
  93663. */
  93664. getFrequencyBinCount(): number;
  93665. /**
  93666. * Gets the current frequency data as a byte array
  93667. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93668. * @returns a Uint8Array
  93669. */
  93670. getByteFrequencyData(): Uint8Array;
  93671. /**
  93672. * Gets the current waveform as a byte array
  93673. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93674. * @returns a Uint8Array
  93675. */
  93676. getByteTimeDomainData(): Uint8Array;
  93677. /**
  93678. * Gets the current frequency data as a float array
  93679. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93680. * @returns a Float32Array
  93681. */
  93682. getFloatFrequencyData(): Float32Array;
  93683. /**
  93684. * Renders the debug canvas
  93685. */
  93686. drawDebugCanvas(): void;
  93687. /**
  93688. * Stops rendering the debug canvas and removes it
  93689. */
  93690. stopDebugCanvas(): void;
  93691. /**
  93692. * Connects two audio nodes
  93693. * @param inputAudioNode defines first node to connect
  93694. * @param outputAudioNode defines second node to connect
  93695. */
  93696. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93697. /**
  93698. * Releases all associated resources
  93699. */
  93700. dispose(): void;
  93701. }
  93702. }
  93703. declare module BABYLON {
  93704. /**
  93705. * This represents an audio engine and it is responsible
  93706. * to play, synchronize and analyse sounds throughout the application.
  93707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93708. */
  93709. export interface IAudioEngine extends IDisposable {
  93710. /**
  93711. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93712. */
  93713. readonly canUseWebAudio: boolean;
  93714. /**
  93715. * Gets the current AudioContext if available.
  93716. */
  93717. readonly audioContext: Nullable<AudioContext>;
  93718. /**
  93719. * The master gain node defines the global audio volume of your audio engine.
  93720. */
  93721. readonly masterGain: GainNode;
  93722. /**
  93723. * Gets whether or not mp3 are supported by your browser.
  93724. */
  93725. readonly isMP3supported: boolean;
  93726. /**
  93727. * Gets whether or not ogg are supported by your browser.
  93728. */
  93729. readonly isOGGsupported: boolean;
  93730. /**
  93731. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93732. * @ignoreNaming
  93733. */
  93734. WarnedWebAudioUnsupported: boolean;
  93735. /**
  93736. * Defines if the audio engine relies on a custom unlocked button.
  93737. * In this case, the embedded button will not be displayed.
  93738. */
  93739. useCustomUnlockedButton: boolean;
  93740. /**
  93741. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93742. */
  93743. readonly unlocked: boolean;
  93744. /**
  93745. * Event raised when audio has been unlocked on the browser.
  93746. */
  93747. onAudioUnlockedObservable: Observable<AudioEngine>;
  93748. /**
  93749. * Event raised when audio has been locked on the browser.
  93750. */
  93751. onAudioLockedObservable: Observable<AudioEngine>;
  93752. /**
  93753. * Flags the audio engine in Locked state.
  93754. * This happens due to new browser policies preventing audio to autoplay.
  93755. */
  93756. lock(): void;
  93757. /**
  93758. * Unlocks the audio engine once a user action has been done on the dom.
  93759. * This is helpful to resume play once browser policies have been satisfied.
  93760. */
  93761. unlock(): void;
  93762. }
  93763. /**
  93764. * This represents the default audio engine used in babylon.
  93765. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93767. */
  93768. export class AudioEngine implements IAudioEngine {
  93769. private _audioContext;
  93770. private _audioContextInitialized;
  93771. private _muteButton;
  93772. private _hostElement;
  93773. /**
  93774. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93775. */
  93776. canUseWebAudio: boolean;
  93777. /**
  93778. * The master gain node defines the global audio volume of your audio engine.
  93779. */
  93780. masterGain: GainNode;
  93781. /**
  93782. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93783. * @ignoreNaming
  93784. */
  93785. WarnedWebAudioUnsupported: boolean;
  93786. /**
  93787. * Gets whether or not mp3 are supported by your browser.
  93788. */
  93789. isMP3supported: boolean;
  93790. /**
  93791. * Gets whether or not ogg are supported by your browser.
  93792. */
  93793. isOGGsupported: boolean;
  93794. /**
  93795. * Gets whether audio has been unlocked on the device.
  93796. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93797. * a user interaction has happened.
  93798. */
  93799. unlocked: boolean;
  93800. /**
  93801. * Defines if the audio engine relies on a custom unlocked button.
  93802. * In this case, the embedded button will not be displayed.
  93803. */
  93804. useCustomUnlockedButton: boolean;
  93805. /**
  93806. * Event raised when audio has been unlocked on the browser.
  93807. */
  93808. onAudioUnlockedObservable: Observable<AudioEngine>;
  93809. /**
  93810. * Event raised when audio has been locked on the browser.
  93811. */
  93812. onAudioLockedObservable: Observable<AudioEngine>;
  93813. /**
  93814. * Gets the current AudioContext if available.
  93815. */
  93816. readonly audioContext: Nullable<AudioContext>;
  93817. private _connectedAnalyser;
  93818. /**
  93819. * Instantiates a new audio engine.
  93820. *
  93821. * There should be only one per page as some browsers restrict the number
  93822. * of audio contexts you can create.
  93823. * @param hostElement defines the host element where to display the mute icon if necessary
  93824. */
  93825. constructor(hostElement?: Nullable<HTMLElement>);
  93826. /**
  93827. * Flags the audio engine in Locked state.
  93828. * This happens due to new browser policies preventing audio to autoplay.
  93829. */
  93830. lock(): void;
  93831. /**
  93832. * Unlocks the audio engine once a user action has been done on the dom.
  93833. * This is helpful to resume play once browser policies have been satisfied.
  93834. */
  93835. unlock(): void;
  93836. private _resumeAudioContext;
  93837. private _initializeAudioContext;
  93838. private _tryToRun;
  93839. private _triggerRunningState;
  93840. private _triggerSuspendedState;
  93841. private _displayMuteButton;
  93842. private _moveButtonToTopLeft;
  93843. private _onResize;
  93844. private _hideMuteButton;
  93845. /**
  93846. * Destroy and release the resources associated with the audio ccontext.
  93847. */
  93848. dispose(): void;
  93849. /**
  93850. * Gets the global volume sets on the master gain.
  93851. * @returns the global volume if set or -1 otherwise
  93852. */
  93853. getGlobalVolume(): number;
  93854. /**
  93855. * Sets the global volume of your experience (sets on the master gain).
  93856. * @param newVolume Defines the new global volume of the application
  93857. */
  93858. setGlobalVolume(newVolume: number): void;
  93859. /**
  93860. * Connect the audio engine to an audio analyser allowing some amazing
  93861. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93863. * @param analyser The analyser to connect to the engine
  93864. */
  93865. connectToAnalyser(analyser: Analyser): void;
  93866. }
  93867. }
  93868. declare module BABYLON {
  93869. /**
  93870. * Interface used to present a loading screen while loading a scene
  93871. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93872. */
  93873. export interface ILoadingScreen {
  93874. /**
  93875. * Function called to display the loading screen
  93876. */
  93877. displayLoadingUI: () => void;
  93878. /**
  93879. * Function called to hide the loading screen
  93880. */
  93881. hideLoadingUI: () => void;
  93882. /**
  93883. * Gets or sets the color to use for the background
  93884. */
  93885. loadingUIBackgroundColor: string;
  93886. /**
  93887. * Gets or sets the text to display while loading
  93888. */
  93889. loadingUIText: string;
  93890. }
  93891. /**
  93892. * Class used for the default loading screen
  93893. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93894. */
  93895. export class DefaultLoadingScreen implements ILoadingScreen {
  93896. private _renderingCanvas;
  93897. private _loadingText;
  93898. private _loadingDivBackgroundColor;
  93899. private _loadingDiv;
  93900. private _loadingTextDiv;
  93901. /** Gets or sets the logo url to use for the default loading screen */
  93902. static DefaultLogoUrl: string;
  93903. /** Gets or sets the spinner url to use for the default loading screen */
  93904. static DefaultSpinnerUrl: string;
  93905. /**
  93906. * Creates a new default loading screen
  93907. * @param _renderingCanvas defines the canvas used to render the scene
  93908. * @param _loadingText defines the default text to display
  93909. * @param _loadingDivBackgroundColor defines the default background color
  93910. */
  93911. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93912. /**
  93913. * Function called to display the loading screen
  93914. */
  93915. displayLoadingUI(): void;
  93916. /**
  93917. * Function called to hide the loading screen
  93918. */
  93919. hideLoadingUI(): void;
  93920. /**
  93921. * Gets or sets the text to display while loading
  93922. */
  93923. loadingUIText: string;
  93924. /**
  93925. * Gets or sets the color to use for the background
  93926. */
  93927. loadingUIBackgroundColor: string;
  93928. private _resizeLoadingUI;
  93929. }
  93930. }
  93931. declare module BABYLON {
  93932. /** @hidden */
  93933. export class WebGLPipelineContext implements IPipelineContext {
  93934. engine: Engine;
  93935. program: Nullable<WebGLProgram>;
  93936. context?: WebGLRenderingContext;
  93937. vertexShader?: WebGLShader;
  93938. fragmentShader?: WebGLShader;
  93939. isParallelCompiled: boolean;
  93940. onCompiled?: () => void;
  93941. transformFeedback?: WebGLTransformFeedback | null;
  93942. readonly isAsync: boolean;
  93943. readonly isReady: boolean;
  93944. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93945. }
  93946. }
  93947. declare module BABYLON {
  93948. /** @hidden */
  93949. export class WebGLDataBuffer extends DataBuffer {
  93950. private _buffer;
  93951. constructor(resource: WebGLBuffer);
  93952. readonly underlyingResource: any;
  93953. }
  93954. }
  93955. declare module BABYLON {
  93956. /** @hidden */
  93957. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93958. attributeProcessor(attribute: string): string;
  93959. varyingProcessor(varying: string, isFragment: boolean): string;
  93960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93961. }
  93962. }
  93963. declare module BABYLON {
  93964. /**
  93965. * This class is used to track a performance counter which is number based.
  93966. * The user has access to many properties which give statistics of different nature.
  93967. *
  93968. * The implementer can track two kinds of Performance Counter: time and count.
  93969. * 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.
  93970. * 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.
  93971. */
  93972. export class PerfCounter {
  93973. /**
  93974. * Gets or sets a global boolean to turn on and off all the counters
  93975. */
  93976. static Enabled: boolean;
  93977. /**
  93978. * Returns the smallest value ever
  93979. */
  93980. readonly min: number;
  93981. /**
  93982. * Returns the biggest value ever
  93983. */
  93984. readonly max: number;
  93985. /**
  93986. * Returns the average value since the performance counter is running
  93987. */
  93988. readonly average: number;
  93989. /**
  93990. * Returns the average value of the last second the counter was monitored
  93991. */
  93992. readonly lastSecAverage: number;
  93993. /**
  93994. * Returns the current value
  93995. */
  93996. readonly current: number;
  93997. /**
  93998. * Gets the accumulated total
  93999. */
  94000. readonly total: number;
  94001. /**
  94002. * Gets the total value count
  94003. */
  94004. readonly count: number;
  94005. /**
  94006. * Creates a new counter
  94007. */
  94008. constructor();
  94009. /**
  94010. * Call this method to start monitoring a new frame.
  94011. * 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.
  94012. */
  94013. fetchNewFrame(): void;
  94014. /**
  94015. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94016. * @param newCount the count value to add to the monitored count
  94017. * @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.
  94018. */
  94019. addCount(newCount: number, fetchResult: boolean): void;
  94020. /**
  94021. * Start monitoring this performance counter
  94022. */
  94023. beginMonitoring(): void;
  94024. /**
  94025. * Compute the time lapsed since the previous beginMonitoring() call.
  94026. * @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
  94027. */
  94028. endMonitoring(newFrame?: boolean): void;
  94029. private _fetchResult;
  94030. private _startMonitoringTime;
  94031. private _min;
  94032. private _max;
  94033. private _average;
  94034. private _current;
  94035. private _totalValueCount;
  94036. private _totalAccumulated;
  94037. private _lastSecAverage;
  94038. private _lastSecAccumulated;
  94039. private _lastSecTime;
  94040. private _lastSecValueCount;
  94041. }
  94042. }
  94043. declare module BABYLON {
  94044. /**
  94045. * Interface for any object that can request an animation frame
  94046. */
  94047. export interface ICustomAnimationFrameRequester {
  94048. /**
  94049. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94050. */
  94051. renderFunction?: Function;
  94052. /**
  94053. * Called to request the next frame to render to
  94054. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94055. */
  94056. requestAnimationFrame: Function;
  94057. /**
  94058. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94059. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94060. */
  94061. requestID?: number;
  94062. }
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Settings for finer control over video usage
  94067. */
  94068. export interface VideoTextureSettings {
  94069. /**
  94070. * Applies `autoplay` to video, if specified
  94071. */
  94072. autoPlay?: boolean;
  94073. /**
  94074. * Applies `loop` to video, if specified
  94075. */
  94076. loop?: boolean;
  94077. /**
  94078. * Automatically updates internal texture from video at every frame in the render loop
  94079. */
  94080. autoUpdateTexture: boolean;
  94081. /**
  94082. * Image src displayed during the video loading or until the user interacts with the video.
  94083. */
  94084. poster?: string;
  94085. }
  94086. /**
  94087. * If you want to display a video in your scene, this is the special texture for that.
  94088. * This special texture works similar to other textures, with the exception of a few parameters.
  94089. * @see https://doc.babylonjs.com/how_to/video_texture
  94090. */
  94091. export class VideoTexture extends Texture {
  94092. /**
  94093. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94094. */
  94095. readonly autoUpdateTexture: boolean;
  94096. /**
  94097. * The video instance used by the texture internally
  94098. */
  94099. readonly video: HTMLVideoElement;
  94100. private _onUserActionRequestedObservable;
  94101. /**
  94102. * Event triggerd when a dom action is required by the user to play the video.
  94103. * This happens due to recent changes in browser policies preventing video to auto start.
  94104. */
  94105. readonly onUserActionRequestedObservable: Observable<Texture>;
  94106. private _generateMipMaps;
  94107. private _engine;
  94108. private _stillImageCaptured;
  94109. private _displayingPosterTexture;
  94110. private _settings;
  94111. private _createInternalTextureOnEvent;
  94112. /**
  94113. * Creates a video texture.
  94114. * If you want to display a video in your scene, this is the special texture for that.
  94115. * This special texture works similar to other textures, with the exception of a few parameters.
  94116. * @see https://doc.babylonjs.com/how_to/video_texture
  94117. * @param name optional name, will detect from video source, if not defined
  94118. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94119. * @param scene is obviously the current scene.
  94120. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94121. * @param invertY is false by default but can be used to invert video on Y axis
  94122. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94123. * @param settings allows finer control over video usage
  94124. */
  94125. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94126. private _getName;
  94127. private _getVideo;
  94128. private _createInternalTexture;
  94129. private reset;
  94130. /**
  94131. * @hidden Internal method to initiate `update`.
  94132. */
  94133. _rebuild(): void;
  94134. /**
  94135. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  94136. */
  94137. update(): void;
  94138. /**
  94139. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94140. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94141. */
  94142. updateTexture(isVisible: boolean): void;
  94143. protected _updateInternalTexture: () => void;
  94144. /**
  94145. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94146. * @param url New url.
  94147. */
  94148. updateURL(url: string): void;
  94149. /**
  94150. * Dispose the texture and release its associated resources.
  94151. */
  94152. dispose(): void;
  94153. /**
  94154. * Creates a video texture straight from a stream.
  94155. * @param scene Define the scene the texture should be created in
  94156. * @param stream Define the stream the texture should be created from
  94157. * @returns The created video texture as a promise
  94158. */
  94159. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94160. /**
  94161. * Creates a video texture straight from your WebCam video feed.
  94162. * @param scene Define the scene the texture should be created in
  94163. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94164. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94165. * @returns The created video texture as a promise
  94166. */
  94167. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94168. minWidth: number;
  94169. maxWidth: number;
  94170. minHeight: number;
  94171. maxHeight: number;
  94172. deviceId: string;
  94173. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94174. /**
  94175. * Creates a video texture straight from your WebCam video feed.
  94176. * @param scene Define the scene the texture should be created in
  94177. * @param onReady Define a callback to triggered once the texture will be ready
  94178. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94179. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94180. */
  94181. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94182. minWidth: number;
  94183. maxWidth: number;
  94184. minHeight: number;
  94185. maxHeight: number;
  94186. deviceId: string;
  94187. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94188. }
  94189. }
  94190. declare module BABYLON {
  94191. /**
  94192. * Defines the interface used by objects containing a viewport (like a camera)
  94193. */
  94194. interface IViewportOwnerLike {
  94195. /**
  94196. * Gets or sets the viewport
  94197. */
  94198. viewport: IViewportLike;
  94199. }
  94200. /**
  94201. * Interface for attribute information associated with buffer instanciation
  94202. */
  94203. export class InstancingAttributeInfo {
  94204. /**
  94205. * Index/offset of the attribute in the vertex shader
  94206. */
  94207. index: number;
  94208. /**
  94209. * size of the attribute, 1, 2, 3 or 4
  94210. */
  94211. attributeSize: number;
  94212. /**
  94213. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94214. * default is FLOAT
  94215. */
  94216. attribyteType: number;
  94217. /**
  94218. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94219. */
  94220. normalized: boolean;
  94221. /**
  94222. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94223. */
  94224. offset: number;
  94225. /**
  94226. * Name of the GLSL attribute, for debugging purpose only
  94227. */
  94228. attributeName: string;
  94229. }
  94230. /**
  94231. * Define options used to create a depth texture
  94232. */
  94233. export class DepthTextureCreationOptions {
  94234. /** Specifies whether or not a stencil should be allocated in the texture */
  94235. generateStencil?: boolean;
  94236. /** Specifies whether or not bilinear filtering is enable on the texture */
  94237. bilinearFiltering?: boolean;
  94238. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94239. comparisonFunction?: number;
  94240. /** Specifies if the created texture is a cube texture */
  94241. isCube?: boolean;
  94242. }
  94243. /**
  94244. * Class used to describe the capabilities of the engine relatively to the current browser
  94245. */
  94246. export class EngineCapabilities {
  94247. /** Maximum textures units per fragment shader */
  94248. maxTexturesImageUnits: number;
  94249. /** Maximum texture units per vertex shader */
  94250. maxVertexTextureImageUnits: number;
  94251. /** Maximum textures units in the entire pipeline */
  94252. maxCombinedTexturesImageUnits: number;
  94253. /** Maximum texture size */
  94254. maxTextureSize: number;
  94255. /** Maximum cube texture size */
  94256. maxCubemapTextureSize: number;
  94257. /** Maximum render texture size */
  94258. maxRenderTextureSize: number;
  94259. /** Maximum number of vertex attributes */
  94260. maxVertexAttribs: number;
  94261. /** Maximum number of varyings */
  94262. maxVaryingVectors: number;
  94263. /** Maximum number of uniforms per vertex shader */
  94264. maxVertexUniformVectors: number;
  94265. /** Maximum number of uniforms per fragment shader */
  94266. maxFragmentUniformVectors: number;
  94267. /** Defines if standard derivates (dx/dy) are supported */
  94268. standardDerivatives: boolean;
  94269. /** Defines if s3tc texture compression is supported */
  94270. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94271. /** Defines if pvrtc texture compression is supported */
  94272. pvrtc: any;
  94273. /** Defines if etc1 texture compression is supported */
  94274. etc1: any;
  94275. /** Defines if etc2 texture compression is supported */
  94276. etc2: any;
  94277. /** Defines if astc texture compression is supported */
  94278. astc: any;
  94279. /** Defines if float textures are supported */
  94280. textureFloat: boolean;
  94281. /** Defines if vertex array objects are supported */
  94282. vertexArrayObject: boolean;
  94283. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94284. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94285. /** Gets the maximum level of anisotropy supported */
  94286. maxAnisotropy: number;
  94287. /** Defines if instancing is supported */
  94288. instancedArrays: boolean;
  94289. /** Defines if 32 bits indices are supported */
  94290. uintIndices: boolean;
  94291. /** Defines if high precision shaders are supported */
  94292. highPrecisionShaderSupported: boolean;
  94293. /** Defines if depth reading in the fragment shader is supported */
  94294. fragmentDepthSupported: boolean;
  94295. /** Defines if float texture linear filtering is supported*/
  94296. textureFloatLinearFiltering: boolean;
  94297. /** Defines if rendering to float textures is supported */
  94298. textureFloatRender: boolean;
  94299. /** Defines if half float textures are supported*/
  94300. textureHalfFloat: boolean;
  94301. /** Defines if half float texture linear filtering is supported*/
  94302. textureHalfFloatLinearFiltering: boolean;
  94303. /** Defines if rendering to half float textures is supported */
  94304. textureHalfFloatRender: boolean;
  94305. /** Defines if textureLOD shader command is supported */
  94306. textureLOD: boolean;
  94307. /** Defines if draw buffers extension is supported */
  94308. drawBuffersExtension: boolean;
  94309. /** Defines if depth textures are supported */
  94310. depthTextureExtension: boolean;
  94311. /** Defines if float color buffer are supported */
  94312. colorBufferFloat: boolean;
  94313. /** Gets disjoint timer query extension (null if not supported) */
  94314. timerQuery: EXT_disjoint_timer_query;
  94315. /** Defines if timestamp can be used with timer query */
  94316. canUseTimestampForTimerQuery: boolean;
  94317. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94318. multiview: any;
  94319. /** Function used to let the system compiles shaders in background */
  94320. parallelShaderCompile: {
  94321. COMPLETION_STATUS_KHR: number;
  94322. };
  94323. /** Max number of texture samples for MSAA */
  94324. maxMSAASamples: number;
  94325. }
  94326. /** Interface defining initialization parameters for Engine class */
  94327. export interface EngineOptions extends WebGLContextAttributes {
  94328. /**
  94329. * Defines if the engine should no exceed a specified device ratio
  94330. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94331. */
  94332. limitDeviceRatio?: number;
  94333. /**
  94334. * Defines if webvr should be enabled automatically
  94335. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94336. */
  94337. autoEnableWebVR?: boolean;
  94338. /**
  94339. * Defines if webgl2 should be turned off even if supported
  94340. * @see http://doc.babylonjs.com/features/webgl2
  94341. */
  94342. disableWebGL2Support?: boolean;
  94343. /**
  94344. * Defines if webaudio should be initialized as well
  94345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94346. */
  94347. audioEngine?: boolean;
  94348. /**
  94349. * Defines if animations should run using a deterministic lock step
  94350. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94351. */
  94352. deterministicLockstep?: boolean;
  94353. /** Defines the maximum steps to use with deterministic lock step mode */
  94354. lockstepMaxSteps?: number;
  94355. /**
  94356. * Defines that engine should ignore context lost events
  94357. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94358. */
  94359. doNotHandleContextLost?: boolean;
  94360. /**
  94361. * Defines that engine should ignore modifying touch action attribute and style
  94362. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94363. */
  94364. doNotHandleTouchAction?: boolean;
  94365. /**
  94366. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94367. */
  94368. useHighPrecisionFloats?: boolean;
  94369. }
  94370. /**
  94371. * Defines the interface used by display changed events
  94372. */
  94373. export interface IDisplayChangedEventArgs {
  94374. /** Gets the vrDisplay object (if any) */
  94375. vrDisplay: Nullable<any>;
  94376. /** Gets a boolean indicating if webVR is supported */
  94377. vrSupported: boolean;
  94378. }
  94379. /**
  94380. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94381. */
  94382. export class Engine {
  94383. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94384. static ExceptionList: ({
  94385. key: string;
  94386. capture: string;
  94387. captureConstraint: number;
  94388. targets: string[];
  94389. } | {
  94390. key: string;
  94391. capture: null;
  94392. captureConstraint: null;
  94393. targets: string[];
  94394. })[];
  94395. /** Gets the list of created engines */
  94396. static readonly Instances: Engine[];
  94397. /**
  94398. * Gets the latest created engine
  94399. */
  94400. static readonly LastCreatedEngine: Nullable<Engine>;
  94401. /**
  94402. * Gets the latest created scene
  94403. */
  94404. static readonly LastCreatedScene: Nullable<Scene>;
  94405. /**
  94406. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94407. * @param flag defines which part of the materials must be marked as dirty
  94408. * @param predicate defines a predicate used to filter which materials should be affected
  94409. */
  94410. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94411. /** @hidden */
  94412. static _TextureLoaders: IInternalTextureLoader[];
  94413. /** Defines that alpha blending is disabled */
  94414. static readonly ALPHA_DISABLE: number;
  94415. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94416. static readonly ALPHA_ADD: number;
  94417. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94418. static readonly ALPHA_COMBINE: number;
  94419. /** Defines that alpha blending to DEST - SRC * DEST */
  94420. static readonly ALPHA_SUBTRACT: number;
  94421. /** Defines that alpha blending to SRC * DEST */
  94422. static readonly ALPHA_MULTIPLY: number;
  94423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94424. static readonly ALPHA_MAXIMIZED: number;
  94425. /** Defines that alpha blending to SRC + DEST */
  94426. static readonly ALPHA_ONEONE: number;
  94427. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94428. static readonly ALPHA_PREMULTIPLIED: number;
  94429. /**
  94430. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94431. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94432. */
  94433. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94434. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94435. static readonly ALPHA_INTERPOLATE: number;
  94436. /**
  94437. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94438. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94439. */
  94440. static readonly ALPHA_SCREENMODE: number;
  94441. /** Defines that the ressource is not delayed*/
  94442. static readonly DELAYLOADSTATE_NONE: number;
  94443. /** Defines that the ressource was successfully delay loaded */
  94444. static readonly DELAYLOADSTATE_LOADED: number;
  94445. /** Defines that the ressource is currently delay loading */
  94446. static readonly DELAYLOADSTATE_LOADING: number;
  94447. /** Defines that the ressource is delayed and has not started loading */
  94448. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94449. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94450. static readonly NEVER: number;
  94451. /** 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 */
  94452. static readonly ALWAYS: number;
  94453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94454. static readonly LESS: number;
  94455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94456. static readonly EQUAL: number;
  94457. /** 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 */
  94458. static readonly LEQUAL: number;
  94459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94460. static readonly GREATER: number;
  94461. /** 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 */
  94462. static readonly GEQUAL: number;
  94463. /** 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 */
  94464. static readonly NOTEQUAL: number;
  94465. /** Passed to stencilOperation to specify that stencil value must be kept */
  94466. static readonly KEEP: number;
  94467. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94468. static readonly REPLACE: number;
  94469. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94470. static readonly INCR: number;
  94471. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94472. static readonly DECR: number;
  94473. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94474. static readonly INVERT: number;
  94475. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94476. static readonly INCR_WRAP: number;
  94477. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94478. static readonly DECR_WRAP: number;
  94479. /** Texture is not repeating outside of 0..1 UVs */
  94480. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94481. /** Texture is repeating outside of 0..1 UVs */
  94482. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94483. /** Texture is repeating and mirrored */
  94484. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94485. /** ALPHA */
  94486. static readonly TEXTUREFORMAT_ALPHA: number;
  94487. /** LUMINANCE */
  94488. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94489. /** LUMINANCE_ALPHA */
  94490. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94491. /** RGB */
  94492. static readonly TEXTUREFORMAT_RGB: number;
  94493. /** RGBA */
  94494. static readonly TEXTUREFORMAT_RGBA: number;
  94495. /** RED */
  94496. static readonly TEXTUREFORMAT_RED: number;
  94497. /** RED (2nd reference) */
  94498. static readonly TEXTUREFORMAT_R: number;
  94499. /** RG */
  94500. static readonly TEXTUREFORMAT_RG: number;
  94501. /** RED_INTEGER */
  94502. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94503. /** RED_INTEGER (2nd reference) */
  94504. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94505. /** RG_INTEGER */
  94506. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94507. /** RGB_INTEGER */
  94508. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94509. /** RGBA_INTEGER */
  94510. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94511. /** UNSIGNED_BYTE */
  94512. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94513. /** UNSIGNED_BYTE (2nd reference) */
  94514. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94515. /** FLOAT */
  94516. static readonly TEXTURETYPE_FLOAT: number;
  94517. /** HALF_FLOAT */
  94518. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94519. /** BYTE */
  94520. static readonly TEXTURETYPE_BYTE: number;
  94521. /** SHORT */
  94522. static readonly TEXTURETYPE_SHORT: number;
  94523. /** UNSIGNED_SHORT */
  94524. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94525. /** INT */
  94526. static readonly TEXTURETYPE_INT: number;
  94527. /** UNSIGNED_INT */
  94528. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94529. /** UNSIGNED_SHORT_4_4_4_4 */
  94530. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94531. /** UNSIGNED_SHORT_5_5_5_1 */
  94532. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94533. /** UNSIGNED_SHORT_5_6_5 */
  94534. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94535. /** UNSIGNED_INT_2_10_10_10_REV */
  94536. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94537. /** UNSIGNED_INT_24_8 */
  94538. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94539. /** UNSIGNED_INT_10F_11F_11F_REV */
  94540. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94541. /** UNSIGNED_INT_5_9_9_9_REV */
  94542. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94543. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94544. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94545. /** nearest is mag = nearest and min = nearest and mip = linear */
  94546. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94547. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94548. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94549. /** Trilinear is mag = linear and min = linear and mip = linear */
  94550. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94551. /** nearest is mag = nearest and min = nearest and mip = linear */
  94552. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94554. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94555. /** Trilinear is mag = linear and min = linear and mip = linear */
  94556. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94557. /** mag = nearest and min = nearest and mip = nearest */
  94558. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94559. /** mag = nearest and min = linear and mip = nearest */
  94560. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94561. /** mag = nearest and min = linear and mip = linear */
  94562. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94563. /** mag = nearest and min = linear and mip = none */
  94564. static readonly TEXTURE_NEAREST_LINEAR: number;
  94565. /** mag = nearest and min = nearest and mip = none */
  94566. static readonly TEXTURE_NEAREST_NEAREST: number;
  94567. /** mag = linear and min = nearest and mip = nearest */
  94568. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94569. /** mag = linear and min = nearest and mip = linear */
  94570. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94571. /** mag = linear and min = linear and mip = none */
  94572. static readonly TEXTURE_LINEAR_LINEAR: number;
  94573. /** mag = linear and min = nearest and mip = none */
  94574. static readonly TEXTURE_LINEAR_NEAREST: number;
  94575. /** Explicit coordinates mode */
  94576. static readonly TEXTURE_EXPLICIT_MODE: number;
  94577. /** Spherical coordinates mode */
  94578. static readonly TEXTURE_SPHERICAL_MODE: number;
  94579. /** Planar coordinates mode */
  94580. static readonly TEXTURE_PLANAR_MODE: number;
  94581. /** Cubic coordinates mode */
  94582. static readonly TEXTURE_CUBIC_MODE: number;
  94583. /** Projection coordinates mode */
  94584. static readonly TEXTURE_PROJECTION_MODE: number;
  94585. /** Skybox coordinates mode */
  94586. static readonly TEXTURE_SKYBOX_MODE: number;
  94587. /** Inverse Cubic coordinates mode */
  94588. static readonly TEXTURE_INVCUBIC_MODE: number;
  94589. /** Equirectangular coordinates mode */
  94590. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94591. /** Equirectangular Fixed coordinates mode */
  94592. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94593. /** Equirectangular Fixed Mirrored coordinates mode */
  94594. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94595. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94596. static readonly SCALEMODE_FLOOR: number;
  94597. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94598. static readonly SCALEMODE_NEAREST: number;
  94599. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94600. static readonly SCALEMODE_CEILING: number;
  94601. /**
  94602. * Returns the current npm package of the sdk
  94603. */
  94604. static readonly NpmPackage: string;
  94605. /**
  94606. * Returns the current version of the framework
  94607. */
  94608. static readonly Version: string;
  94609. /**
  94610. * Returns a string describing the current engine
  94611. */
  94612. readonly description: string;
  94613. /**
  94614. * Gets or sets the epsilon value used by collision engine
  94615. */
  94616. static CollisionsEpsilon: number;
  94617. /**
  94618. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94619. */
  94620. static ShadersRepository: string;
  94621. /**
  94622. * Method called to create the default loading screen.
  94623. * This can be overriden in your own app.
  94624. * @param canvas The rendering canvas element
  94625. * @returns The loading screen
  94626. */
  94627. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94628. /**
  94629. * Method called to create the default rescale post process on each engine.
  94630. */
  94631. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94632. /** @hidden */
  94633. _shaderProcessor: IShaderProcessor;
  94634. /**
  94635. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94636. */
  94637. forcePOTTextures: boolean;
  94638. /**
  94639. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94640. */
  94641. isFullscreen: boolean;
  94642. /**
  94643. * Gets a boolean indicating if the pointer is currently locked
  94644. */
  94645. isPointerLock: boolean;
  94646. /**
  94647. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94648. */
  94649. cullBackFaces: boolean;
  94650. /**
  94651. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94652. */
  94653. renderEvenInBackground: boolean;
  94654. /**
  94655. * Gets or sets a boolean indicating that cache can be kept between frames
  94656. */
  94657. preventCacheWipeBetweenFrames: boolean;
  94658. /**
  94659. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94660. **/
  94661. enableOfflineSupport: boolean;
  94662. /**
  94663. * 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)
  94664. **/
  94665. disableManifestCheck: boolean;
  94666. /**
  94667. * Gets the list of created scenes
  94668. */
  94669. scenes: Scene[];
  94670. /**
  94671. * Event raised when a new scene is created
  94672. */
  94673. onNewSceneAddedObservable: Observable<Scene>;
  94674. /**
  94675. * Gets the list of created postprocesses
  94676. */
  94677. postProcesses: PostProcess[];
  94678. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94679. validateShaderPrograms: boolean;
  94680. /**
  94681. * Observable event triggered each time the rendering canvas is resized
  94682. */
  94683. onResizeObservable: Observable<Engine>;
  94684. /**
  94685. * Observable event triggered each time the canvas loses focus
  94686. */
  94687. onCanvasBlurObservable: Observable<Engine>;
  94688. /**
  94689. * Observable event triggered each time the canvas gains focus
  94690. */
  94691. onCanvasFocusObservable: Observable<Engine>;
  94692. /**
  94693. * Observable event triggered each time the canvas receives pointerout event
  94694. */
  94695. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94696. /**
  94697. * Observable event triggered before each texture is initialized
  94698. */
  94699. onBeforeTextureInitObservable: Observable<Texture>;
  94700. /**
  94701. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94702. */
  94703. disableUniformBuffers: boolean;
  94704. /** @hidden */
  94705. _uniformBuffers: UniformBuffer[];
  94706. /**
  94707. * Gets a boolean indicating that the engine supports uniform buffers
  94708. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94709. */
  94710. readonly supportsUniformBuffers: boolean;
  94711. /**
  94712. * Observable raised when the engine begins a new frame
  94713. */
  94714. onBeginFrameObservable: Observable<Engine>;
  94715. /**
  94716. * If set, will be used to request the next animation frame for the render loop
  94717. */
  94718. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94719. /**
  94720. * Observable raised when the engine ends the current frame
  94721. */
  94722. onEndFrameObservable: Observable<Engine>;
  94723. /**
  94724. * Observable raised when the engine is about to compile a shader
  94725. */
  94726. onBeforeShaderCompilationObservable: Observable<Engine>;
  94727. /**
  94728. * Observable raised when the engine has jsut compiled a shader
  94729. */
  94730. onAfterShaderCompilationObservable: Observable<Engine>;
  94731. /** @hidden */
  94732. _gl: WebGLRenderingContext;
  94733. private _renderingCanvas;
  94734. private _windowIsBackground;
  94735. private _webGLVersion;
  94736. protected _highPrecisionShadersAllowed: boolean;
  94737. /** @hidden */
  94738. readonly _shouldUseHighPrecisionShader: boolean;
  94739. /**
  94740. * Gets a boolean indicating that only power of 2 textures are supported
  94741. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94742. */
  94743. readonly needPOTTextures: boolean;
  94744. /** @hidden */
  94745. _badOS: boolean;
  94746. /** @hidden */
  94747. _badDesktopOS: boolean;
  94748. /**
  94749. * Gets the audio engine
  94750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94751. * @ignorenaming
  94752. */
  94753. static audioEngine: IAudioEngine;
  94754. /**
  94755. * Default AudioEngine factory responsible of creating the Audio Engine.
  94756. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94757. */
  94758. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94759. /**
  94760. * Default offline support factory responsible of creating a tool used to store data locally.
  94761. * By default, this will create a Database object if the workload has been embedded.
  94762. */
  94763. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94764. private _onFocus;
  94765. private _onBlur;
  94766. private _onCanvasPointerOut;
  94767. private _onCanvasBlur;
  94768. private _onCanvasFocus;
  94769. private _onFullscreenChange;
  94770. private _onPointerLockChange;
  94771. private _hardwareScalingLevel;
  94772. /** @hidden */
  94773. _caps: EngineCapabilities;
  94774. private _pointerLockRequested;
  94775. private _isStencilEnable;
  94776. private _colorWrite;
  94777. private _loadingScreen;
  94778. /** @hidden */
  94779. _drawCalls: PerfCounter;
  94780. private _glVersion;
  94781. private _glRenderer;
  94782. private _glVendor;
  94783. private _videoTextureSupported;
  94784. private _renderingQueueLaunched;
  94785. private _activeRenderLoops;
  94786. private _deterministicLockstep;
  94787. private _lockstepMaxSteps;
  94788. /**
  94789. * Observable signaled when a context lost event is raised
  94790. */
  94791. onContextLostObservable: Observable<Engine>;
  94792. /**
  94793. * Observable signaled when a context restored event is raised
  94794. */
  94795. onContextRestoredObservable: Observable<Engine>;
  94796. private _onContextLost;
  94797. private _onContextRestored;
  94798. private _contextWasLost;
  94799. /** @hidden */
  94800. _doNotHandleContextLost: boolean;
  94801. /**
  94802. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94804. */
  94805. doNotHandleContextLost: boolean;
  94806. private _performanceMonitor;
  94807. private _fps;
  94808. private _deltaTime;
  94809. /**
  94810. * Turn this value on if you want to pause FPS computation when in background
  94811. */
  94812. disablePerformanceMonitorInBackground: boolean;
  94813. /**
  94814. * Gets the performance monitor attached to this engine
  94815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94816. */
  94817. readonly performanceMonitor: PerformanceMonitor;
  94818. /**
  94819. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94820. */
  94821. disableVertexArrayObjects: boolean;
  94822. /** @hidden */
  94823. protected _depthCullingState: _DepthCullingState;
  94824. /** @hidden */
  94825. protected _stencilState: _StencilState;
  94826. /** @hidden */
  94827. protected _alphaState: _AlphaState;
  94828. /** @hidden */
  94829. protected _alphaMode: number;
  94830. /** @hidden */
  94831. _internalTexturesCache: InternalTexture[];
  94832. /** @hidden */
  94833. protected _activeChannel: number;
  94834. private _currentTextureChannel;
  94835. /** @hidden */
  94836. protected _boundTexturesCache: {
  94837. [key: string]: Nullable<InternalTexture>;
  94838. };
  94839. /** @hidden */
  94840. protected _currentEffect: Nullable<Effect>;
  94841. /** @hidden */
  94842. protected _currentProgram: Nullable<WebGLProgram>;
  94843. private _compiledEffects;
  94844. private _vertexAttribArraysEnabled;
  94845. /** @hidden */
  94846. protected _cachedViewport: Nullable<IViewportLike>;
  94847. private _cachedVertexArrayObject;
  94848. /** @hidden */
  94849. protected _cachedVertexBuffers: any;
  94850. /** @hidden */
  94851. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94852. /** @hidden */
  94853. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94854. /** @hidden */
  94855. _currentRenderTarget: Nullable<InternalTexture>;
  94856. private _uintIndicesCurrentlySet;
  94857. private _currentBoundBuffer;
  94858. /** @hidden */
  94859. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94860. private _currentBufferPointers;
  94861. private _currentInstanceLocations;
  94862. private _currentInstanceBuffers;
  94863. private _textureUnits;
  94864. /** @hidden */
  94865. _workingCanvas: Nullable<HTMLCanvasElement>;
  94866. /** @hidden */
  94867. _workingContext: Nullable<CanvasRenderingContext2D>;
  94868. private _rescalePostProcess;
  94869. private _dummyFramebuffer;
  94870. private _externalData;
  94871. /** @hidden */
  94872. _bindedRenderFunction: any;
  94873. private _vaoRecordInProgress;
  94874. private _mustWipeVertexAttributes;
  94875. private _emptyTexture;
  94876. private _emptyCubeTexture;
  94877. private _emptyTexture3D;
  94878. /** @hidden */
  94879. _frameHandler: number;
  94880. private _nextFreeTextureSlots;
  94881. private _maxSimultaneousTextures;
  94882. private _activeRequests;
  94883. private _texturesSupported;
  94884. /** @hidden */
  94885. _textureFormatInUse: Nullable<string>;
  94886. /**
  94887. * Gets the list of texture formats supported
  94888. */
  94889. readonly texturesSupported: Array<string>;
  94890. /**
  94891. * Gets the list of texture formats in use
  94892. */
  94893. readonly textureFormatInUse: Nullable<string>;
  94894. /**
  94895. * Gets the current viewport
  94896. */
  94897. readonly currentViewport: Nullable<IViewportLike>;
  94898. /**
  94899. * Gets the default empty texture
  94900. */
  94901. readonly emptyTexture: InternalTexture;
  94902. /**
  94903. * Gets the default empty 3D texture
  94904. */
  94905. readonly emptyTexture3D: InternalTexture;
  94906. /**
  94907. * Gets the default empty cube texture
  94908. */
  94909. readonly emptyCubeTexture: InternalTexture;
  94910. /**
  94911. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94912. */
  94913. readonly premultipliedAlpha: boolean;
  94914. /**
  94915. * Creates a new engine
  94916. * @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
  94917. * @param antialias defines enable antialiasing (default: false)
  94918. * @param options defines further options to be sent to the getContext() function
  94919. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94920. */
  94921. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94922. /**
  94923. * Initializes a webVR display and starts listening to display change events
  94924. * The onVRDisplayChangedObservable will be notified upon these changes
  94925. * @returns The onVRDisplayChangedObservable
  94926. */
  94927. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94928. /** @hidden */
  94929. _prepareVRComponent(): void;
  94930. /** @hidden */
  94931. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94932. /** @hidden */
  94933. _submitVRFrame(): void;
  94934. /**
  94935. * Call this function to leave webVR mode
  94936. * Will do nothing if webVR is not supported or if there is no webVR device
  94937. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94938. */
  94939. disableVR(): void;
  94940. /**
  94941. * Gets a boolean indicating that the system is in VR mode and is presenting
  94942. * @returns true if VR mode is engaged
  94943. */
  94944. isVRPresenting(): boolean;
  94945. /** @hidden */
  94946. _requestVRFrame(): void;
  94947. private _disableTouchAction;
  94948. private _rebuildInternalTextures;
  94949. private _rebuildEffects;
  94950. /**
  94951. * Gets a boolean indicating if all created effects are ready
  94952. * @returns true if all effects are ready
  94953. */
  94954. areAllEffectsReady(): boolean;
  94955. private _rebuildBuffers;
  94956. private _initGLContext;
  94957. /**
  94958. * Gets version of the current webGL context
  94959. */
  94960. readonly webGLVersion: number;
  94961. /**
  94962. * Gets a string idenfifying the name of the class
  94963. * @returns "Engine" string
  94964. */
  94965. getClassName(): string;
  94966. /**
  94967. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94968. */
  94969. readonly isStencilEnable: boolean;
  94970. /** @hidden */
  94971. _prepareWorkingCanvas(): void;
  94972. /**
  94973. * Reset the texture cache to empty state
  94974. */
  94975. resetTextureCache(): void;
  94976. /**
  94977. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94979. * @returns true if engine is in deterministic lock step mode
  94980. */
  94981. isDeterministicLockStep(): boolean;
  94982. /**
  94983. * Gets the max steps when engine is running in deterministic lock step
  94984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94985. * @returns the max steps
  94986. */
  94987. getLockstepMaxSteps(): number;
  94988. /**
  94989. * Gets an object containing information about the current webGL context
  94990. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94991. */
  94992. getGlInfo(): {
  94993. vendor: string;
  94994. renderer: string;
  94995. version: string;
  94996. };
  94997. /**
  94998. * Gets current aspect ratio
  94999. * @param viewportOwner defines the camera to use to get the aspect ratio
  95000. * @param useScreen defines if screen size must be used (or the current render target if any)
  95001. * @returns a number defining the aspect ratio
  95002. */
  95003. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95004. /**
  95005. * Gets current screen aspect ratio
  95006. * @returns a number defining the aspect ratio
  95007. */
  95008. getScreenAspectRatio(): number;
  95009. /**
  95010. * Gets the current render width
  95011. * @param useScreen defines if screen size must be used (or the current render target if any)
  95012. * @returns a number defining the current render width
  95013. */
  95014. getRenderWidth(useScreen?: boolean): number;
  95015. /**
  95016. * Gets the current render height
  95017. * @param useScreen defines if screen size must be used (or the current render target if any)
  95018. * @returns a number defining the current render height
  95019. */
  95020. getRenderHeight(useScreen?: boolean): number;
  95021. /**
  95022. * Gets the HTML canvas attached with the current webGL context
  95023. * @returns a HTML canvas
  95024. */
  95025. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95026. /**
  95027. * Gets host window
  95028. * @returns the host window object
  95029. */
  95030. getHostWindow(): Window;
  95031. /**
  95032. * Gets host document
  95033. * @returns the host document object
  95034. */
  95035. getHostDocument(): Document;
  95036. /**
  95037. * Gets the client rect of the HTML canvas attached with the current webGL context
  95038. * @returns a client rectanglee
  95039. */
  95040. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95041. /**
  95042. * Defines the hardware scaling level.
  95043. * By default the hardware scaling level is computed from the window device ratio.
  95044. * 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.
  95045. * @param level defines the level to use
  95046. */
  95047. setHardwareScalingLevel(level: number): void;
  95048. /**
  95049. * Gets the current hardware scaling level.
  95050. * By default the hardware scaling level is computed from the window device ratio.
  95051. * 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.
  95052. * @returns a number indicating the current hardware scaling level
  95053. */
  95054. getHardwareScalingLevel(): number;
  95055. /**
  95056. * Gets the list of loaded textures
  95057. * @returns an array containing all loaded textures
  95058. */
  95059. getLoadedTexturesCache(): InternalTexture[];
  95060. /**
  95061. * Gets the object containing all engine capabilities
  95062. * @returns the EngineCapabilities object
  95063. */
  95064. getCaps(): EngineCapabilities;
  95065. /**
  95066. * Gets the current depth function
  95067. * @returns a number defining the depth function
  95068. */
  95069. getDepthFunction(): Nullable<number>;
  95070. /**
  95071. * Sets the current depth function
  95072. * @param depthFunc defines the function to use
  95073. */
  95074. setDepthFunction(depthFunc: number): void;
  95075. /**
  95076. * Sets the current depth function to GREATER
  95077. */
  95078. setDepthFunctionToGreater(): void;
  95079. /**
  95080. * Sets the current depth function to GEQUAL
  95081. */
  95082. setDepthFunctionToGreaterOrEqual(): void;
  95083. /**
  95084. * Sets the current depth function to LESS
  95085. */
  95086. setDepthFunctionToLess(): void;
  95087. private _cachedStencilBuffer;
  95088. private _cachedStencilFunction;
  95089. private _cachedStencilMask;
  95090. private _cachedStencilOperationPass;
  95091. private _cachedStencilOperationFail;
  95092. private _cachedStencilOperationDepthFail;
  95093. private _cachedStencilReference;
  95094. /**
  95095. * Caches the the state of the stencil buffer
  95096. */
  95097. cacheStencilState(): void;
  95098. /**
  95099. * Restores the state of the stencil buffer
  95100. */
  95101. restoreStencilState(): void;
  95102. /**
  95103. * Sets the current depth function to LEQUAL
  95104. */
  95105. setDepthFunctionToLessOrEqual(): void;
  95106. /**
  95107. * Gets a boolean indicating if stencil buffer is enabled
  95108. * @returns the current stencil buffer state
  95109. */
  95110. getStencilBuffer(): boolean;
  95111. /**
  95112. * Enable or disable the stencil buffer
  95113. * @param enable defines if the stencil buffer must be enabled or disabled
  95114. */
  95115. setStencilBuffer(enable: boolean): void;
  95116. /**
  95117. * Gets the current stencil mask
  95118. * @returns a number defining the new stencil mask to use
  95119. */
  95120. getStencilMask(): number;
  95121. /**
  95122. * Sets the current stencil mask
  95123. * @param mask defines the new stencil mask to use
  95124. */
  95125. setStencilMask(mask: number): void;
  95126. /**
  95127. * Gets the current stencil function
  95128. * @returns a number defining the stencil function to use
  95129. */
  95130. getStencilFunction(): number;
  95131. /**
  95132. * Gets the current stencil reference value
  95133. * @returns a number defining the stencil reference value to use
  95134. */
  95135. getStencilFunctionReference(): number;
  95136. /**
  95137. * Gets the current stencil mask
  95138. * @returns a number defining the stencil mask to use
  95139. */
  95140. getStencilFunctionMask(): number;
  95141. /**
  95142. * Sets the current stencil function
  95143. * @param stencilFunc defines the new stencil function to use
  95144. */
  95145. setStencilFunction(stencilFunc: number): void;
  95146. /**
  95147. * Sets the current stencil reference
  95148. * @param reference defines the new stencil reference to use
  95149. */
  95150. setStencilFunctionReference(reference: number): void;
  95151. /**
  95152. * Sets the current stencil mask
  95153. * @param mask defines the new stencil mask to use
  95154. */
  95155. setStencilFunctionMask(mask: number): void;
  95156. /**
  95157. * Gets the current stencil operation when stencil fails
  95158. * @returns a number defining stencil operation to use when stencil fails
  95159. */
  95160. getStencilOperationFail(): number;
  95161. /**
  95162. * Gets the current stencil operation when depth fails
  95163. * @returns a number defining stencil operation to use when depth fails
  95164. */
  95165. getStencilOperationDepthFail(): number;
  95166. /**
  95167. * Gets the current stencil operation when stencil passes
  95168. * @returns a number defining stencil operation to use when stencil passes
  95169. */
  95170. getStencilOperationPass(): number;
  95171. /**
  95172. * Sets the stencil operation to use when stencil fails
  95173. * @param operation defines the stencil operation to use when stencil fails
  95174. */
  95175. setStencilOperationFail(operation: number): void;
  95176. /**
  95177. * Sets the stencil operation to use when depth fails
  95178. * @param operation defines the stencil operation to use when depth fails
  95179. */
  95180. setStencilOperationDepthFail(operation: number): void;
  95181. /**
  95182. * Sets the stencil operation to use when stencil passes
  95183. * @param operation defines the stencil operation to use when stencil passes
  95184. */
  95185. setStencilOperationPass(operation: number): void;
  95186. /**
  95187. * Sets a boolean indicating if the dithering state is enabled or disabled
  95188. * @param value defines the dithering state
  95189. */
  95190. setDitheringState(value: boolean): void;
  95191. /**
  95192. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95193. * @param value defines the rasterizer state
  95194. */
  95195. setRasterizerState(value: boolean): void;
  95196. /**
  95197. * stop executing a render loop function and remove it from the execution array
  95198. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95199. */
  95200. stopRenderLoop(renderFunction?: () => void): void;
  95201. /** @hidden */
  95202. _renderLoop(): void;
  95203. /**
  95204. * Register and execute a render loop. The engine can have more than one render function
  95205. * @param renderFunction defines the function to continuously execute
  95206. */
  95207. runRenderLoop(renderFunction: () => void): void;
  95208. /**
  95209. * Toggle full screen mode
  95210. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95211. */
  95212. switchFullscreen(requestPointerLock: boolean): void;
  95213. /**
  95214. * Enters full screen mode
  95215. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95216. */
  95217. enterFullscreen(requestPointerLock: boolean): void;
  95218. /**
  95219. * Exits full screen mode
  95220. */
  95221. exitFullscreen(): void;
  95222. /**
  95223. * Enters Pointerlock mode
  95224. */
  95225. enterPointerlock(): void;
  95226. /**
  95227. * Exits Pointerlock mode
  95228. */
  95229. exitPointerlock(): void;
  95230. /**
  95231. * Clear the current render buffer or the current render target (if any is set up)
  95232. * @param color defines the color to use
  95233. * @param backBuffer defines if the back buffer must be cleared
  95234. * @param depth defines if the depth buffer must be cleared
  95235. * @param stencil defines if the stencil buffer must be cleared
  95236. */
  95237. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95238. /**
  95239. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95240. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95241. * @param y defines the y-coordinate of the corner of the clear rectangle
  95242. * @param width defines the width of the clear rectangle
  95243. * @param height defines the height of the clear rectangle
  95244. * @param clearColor defines the clear color
  95245. */
  95246. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95247. /**
  95248. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95249. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95250. * @param y defines the y-coordinate of the corner of the clear rectangle
  95251. * @param width defines the width of the clear rectangle
  95252. * @param height defines the height of the clear rectangle
  95253. */
  95254. enableScissor(x: number, y: number, width: number, height: number): void;
  95255. /**
  95256. * Disable previously set scissor test rectangle
  95257. */
  95258. disableScissor(): void;
  95259. private _viewportCached;
  95260. /** @hidden */
  95261. _viewport(x: number, y: number, width: number, height: number): void;
  95262. /**
  95263. * Set the WebGL's viewport
  95264. * @param viewport defines the viewport element to be used
  95265. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95266. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95267. */
  95268. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95269. /**
  95270. * Directly set the WebGL Viewport
  95271. * @param x defines the x coordinate of the viewport (in screen space)
  95272. * @param y defines the y coordinate of the viewport (in screen space)
  95273. * @param width defines the width of the viewport (in screen space)
  95274. * @param height defines the height of the viewport (in screen space)
  95275. * @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
  95276. */
  95277. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95278. /**
  95279. * Begin a new frame
  95280. */
  95281. beginFrame(): void;
  95282. /**
  95283. * Enf the current frame
  95284. */
  95285. endFrame(): void;
  95286. /**
  95287. * Resize the view according to the canvas' size
  95288. */
  95289. resize(): void;
  95290. /**
  95291. * Force a specific size of the canvas
  95292. * @param width defines the new canvas' width
  95293. * @param height defines the new canvas' height
  95294. */
  95295. setSize(width: number, height: number): void;
  95296. /**
  95297. * Binds the frame buffer to the specified texture.
  95298. * @param texture The texture to render to or null for the default canvas
  95299. * @param faceIndex The face of the texture to render to in case of cube texture
  95300. * @param requiredWidth The width of the target to render to
  95301. * @param requiredHeight The height of the target to render to
  95302. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95303. * @param depthStencilTexture The depth stencil texture to use to render
  95304. * @param lodLevel defines le lod level to bind to the frame buffer
  95305. */
  95306. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95307. /** @hidden */
  95308. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95309. /**
  95310. * Unbind the current render target texture from the webGL context
  95311. * @param texture defines the render target texture to unbind
  95312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95314. */
  95315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95316. /**
  95317. * Force the mipmap generation for the given render target texture
  95318. * @param texture defines the render target texture to use
  95319. */
  95320. generateMipMapsForCubemap(texture: InternalTexture): void;
  95321. /**
  95322. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95323. */
  95324. flushFramebuffer(): void;
  95325. /**
  95326. * Unbind the current render target and bind the default framebuffer
  95327. */
  95328. restoreDefaultFramebuffer(): void;
  95329. /**
  95330. * Create an uniform buffer
  95331. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95332. * @param elements defines the content of the uniform buffer
  95333. * @returns the webGL uniform buffer
  95334. */
  95335. createUniformBuffer(elements: FloatArray): DataBuffer;
  95336. /**
  95337. * Create a dynamic uniform buffer
  95338. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95339. * @param elements defines the content of the uniform buffer
  95340. * @returns the webGL uniform buffer
  95341. */
  95342. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95343. /**
  95344. * Update an existing uniform buffer
  95345. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95346. * @param uniformBuffer defines the target uniform buffer
  95347. * @param elements defines the content to update
  95348. * @param offset defines the offset in the uniform buffer where update should start
  95349. * @param count defines the size of the data to update
  95350. */
  95351. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95352. private _resetVertexBufferBinding;
  95353. /**
  95354. * Creates a vertex buffer
  95355. * @param data the data for the vertex buffer
  95356. * @returns the new WebGL static buffer
  95357. */
  95358. createVertexBuffer(data: DataArray): DataBuffer;
  95359. /**
  95360. * Creates a dynamic vertex buffer
  95361. * @param data the data for the dynamic vertex buffer
  95362. * @returns the new WebGL dynamic buffer
  95363. */
  95364. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95365. /**
  95366. * Update a dynamic index buffer
  95367. * @param indexBuffer defines the target index buffer
  95368. * @param indices defines the data to update
  95369. * @param offset defines the offset in the target index buffer where update should start
  95370. */
  95371. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95372. /**
  95373. * Updates a dynamic vertex buffer.
  95374. * @param vertexBuffer the vertex buffer to update
  95375. * @param data the data used to update the vertex buffer
  95376. * @param byteOffset the byte offset of the data
  95377. * @param byteLength the byte length of the data
  95378. */
  95379. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95380. private _resetIndexBufferBinding;
  95381. /**
  95382. * Creates a new index buffer
  95383. * @param indices defines the content of the index buffer
  95384. * @param updatable defines if the index buffer must be updatable
  95385. * @returns a new webGL buffer
  95386. */
  95387. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95388. /**
  95389. * Bind a webGL buffer to the webGL context
  95390. * @param buffer defines the buffer to bind
  95391. */
  95392. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95393. /**
  95394. * Bind an uniform buffer to the current webGL context
  95395. * @param buffer defines the buffer to bind
  95396. */
  95397. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95398. /**
  95399. * Bind a buffer to the current webGL context at a given location
  95400. * @param buffer defines the buffer to bind
  95401. * @param location defines the index where to bind the buffer
  95402. */
  95403. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95404. /**
  95405. * Bind a specific block at a given index in a specific shader program
  95406. * @param pipelineContext defines the pipeline context to use
  95407. * @param blockName defines the block name
  95408. * @param index defines the index where to bind the block
  95409. */
  95410. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95411. private bindIndexBuffer;
  95412. private bindBuffer;
  95413. /**
  95414. * update the bound buffer with the given data
  95415. * @param data defines the data to update
  95416. */
  95417. updateArrayBuffer(data: Float32Array): void;
  95418. private _vertexAttribPointer;
  95419. private _bindIndexBufferWithCache;
  95420. private _bindVertexBuffersAttributes;
  95421. /**
  95422. * Records a vertex array object
  95423. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95424. * @param vertexBuffers defines the list of vertex buffers to store
  95425. * @param indexBuffer defines the index buffer to store
  95426. * @param effect defines the effect to store
  95427. * @returns the new vertex array object
  95428. */
  95429. recordVertexArrayObject(vertexBuffers: {
  95430. [key: string]: VertexBuffer;
  95431. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95432. /**
  95433. * Bind a specific vertex array object
  95434. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95435. * @param vertexArrayObject defines the vertex array object to bind
  95436. * @param indexBuffer defines the index buffer to bind
  95437. */
  95438. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95439. /**
  95440. * Bind webGl buffers directly to the webGL context
  95441. * @param vertexBuffer defines the vertex buffer to bind
  95442. * @param indexBuffer defines the index buffer to bind
  95443. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95444. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95445. * @param effect defines the effect associated with the vertex buffer
  95446. */
  95447. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95448. private _unbindVertexArrayObject;
  95449. /**
  95450. * Bind a list of vertex buffers to the webGL context
  95451. * @param vertexBuffers defines the list of vertex buffers to bind
  95452. * @param indexBuffer defines the index buffer to bind
  95453. * @param effect defines the effect associated with the vertex buffers
  95454. */
  95455. bindBuffers(vertexBuffers: {
  95456. [key: string]: Nullable<VertexBuffer>;
  95457. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95458. /**
  95459. * Unbind all instance attributes
  95460. */
  95461. unbindInstanceAttributes(): void;
  95462. /**
  95463. * Release and free the memory of a vertex array object
  95464. * @param vao defines the vertex array object to delete
  95465. */
  95466. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95467. /** @hidden */
  95468. _releaseBuffer(buffer: DataBuffer): boolean;
  95469. /**
  95470. * Creates a webGL buffer to use with instanciation
  95471. * @param capacity defines the size of the buffer
  95472. * @returns the webGL buffer
  95473. */
  95474. createInstancesBuffer(capacity: number): DataBuffer;
  95475. /**
  95476. * Delete a webGL buffer used with instanciation
  95477. * @param buffer defines the webGL buffer to delete
  95478. */
  95479. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95480. /**
  95481. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95482. * @param instancesBuffer defines the webGL buffer to update and bind
  95483. * @param data defines the data to store in the buffer
  95484. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95485. */
  95486. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95487. /**
  95488. * Apply all cached states (depth, culling, stencil and alpha)
  95489. */
  95490. applyStates(): void;
  95491. /**
  95492. * Send a draw order
  95493. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95494. * @param indexStart defines the starting index
  95495. * @param indexCount defines the number of index to draw
  95496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95497. */
  95498. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95499. /**
  95500. * Draw a list of points
  95501. * @param verticesStart defines the index of first vertex to draw
  95502. * @param verticesCount defines the count of vertices to draw
  95503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95504. */
  95505. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95506. /**
  95507. * Draw a list of unindexed primitives
  95508. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95509. * @param verticesStart defines the index of first vertex to draw
  95510. * @param verticesCount defines the count of vertices to draw
  95511. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95512. */
  95513. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95514. /**
  95515. * Draw a list of indexed primitives
  95516. * @param fillMode defines the primitive to use
  95517. * @param indexStart defines the starting index
  95518. * @param indexCount defines the number of index to draw
  95519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95520. */
  95521. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95522. /**
  95523. * Draw a list of unindexed primitives
  95524. * @param fillMode defines the primitive to use
  95525. * @param verticesStart defines the index of first vertex to draw
  95526. * @param verticesCount defines the count of vertices to draw
  95527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95528. */
  95529. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95530. private _drawMode;
  95531. /** @hidden */
  95532. _releaseEffect(effect: Effect): void;
  95533. /** @hidden */
  95534. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95535. /**
  95536. * Create a new effect (used to store vertex/fragment shaders)
  95537. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95538. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95539. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95540. * @param samplers defines an array of string used to represent textures
  95541. * @param defines defines the string containing the defines to use to compile the shaders
  95542. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95543. * @param onCompiled defines a function to call when the effect creation is successful
  95544. * @param onError defines a function to call when the effect creation has failed
  95545. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95546. * @returns the new Effect
  95547. */
  95548. 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;
  95549. private _compileShader;
  95550. private _compileRawShader;
  95551. /**
  95552. * Directly creates a webGL program
  95553. * @param pipelineContext defines the pipeline context to attach to
  95554. * @param vertexCode defines the vertex shader code to use
  95555. * @param fragmentCode defines the fragment shader code to use
  95556. * @param context defines the webGL context to use (if not set, the current one will be used)
  95557. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95558. * @returns the new webGL program
  95559. */
  95560. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95561. /**
  95562. * Creates a webGL program
  95563. * @param pipelineContext defines the pipeline context to attach to
  95564. * @param vertexCode defines the vertex shader code to use
  95565. * @param fragmentCode defines the fragment shader code to use
  95566. * @param defines defines the string containing the defines to use to compile the shaders
  95567. * @param context defines the webGL context to use (if not set, the current one will be used)
  95568. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95569. * @returns the new webGL program
  95570. */
  95571. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95572. /**
  95573. * Creates a new pipeline context
  95574. * @returns the new pipeline
  95575. */
  95576. createPipelineContext(): WebGLPipelineContext;
  95577. private _createShaderProgram;
  95578. private _finalizePipelineContext;
  95579. /** @hidden */
  95580. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95581. /** @hidden */
  95582. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95583. /** @hidden */
  95584. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95585. /**
  95586. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95587. * @param pipelineContext defines the pipeline context to use
  95588. * @param uniformsNames defines the list of uniform names
  95589. * @returns an array of webGL uniform locations
  95590. */
  95591. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95592. /**
  95593. * Gets the lsit of active attributes for a given webGL program
  95594. * @param pipelineContext defines the pipeline context to use
  95595. * @param attributesNames defines the list of attribute names to get
  95596. * @returns an array of indices indicating the offset of each attribute
  95597. */
  95598. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95599. /**
  95600. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95601. * @param effect defines the effect to activate
  95602. */
  95603. enableEffect(effect: Nullable<Effect>): void;
  95604. /**
  95605. * Set the value of an uniform to an array of int32
  95606. * @param uniform defines the webGL uniform location where to store the value
  95607. * @param array defines the array of int32 to store
  95608. */
  95609. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95610. /**
  95611. * Set the value of an uniform to an array of int32 (stored as vec2)
  95612. * @param uniform defines the webGL uniform location where to store the value
  95613. * @param array defines the array of int32 to store
  95614. */
  95615. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95616. /**
  95617. * Set the value of an uniform to an array of int32 (stored as vec3)
  95618. * @param uniform defines the webGL uniform location where to store the value
  95619. * @param array defines the array of int32 to store
  95620. */
  95621. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95622. /**
  95623. * Set the value of an uniform to an array of int32 (stored as vec4)
  95624. * @param uniform defines the webGL uniform location where to store the value
  95625. * @param array defines the array of int32 to store
  95626. */
  95627. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95628. /**
  95629. * Set the value of an uniform to an array of float32
  95630. * @param uniform defines the webGL uniform location where to store the value
  95631. * @param array defines the array of float32 to store
  95632. */
  95633. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95634. /**
  95635. * Set the value of an uniform to an array of float32 (stored as vec2)
  95636. * @param uniform defines the webGL uniform location where to store the value
  95637. * @param array defines the array of float32 to store
  95638. */
  95639. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95640. /**
  95641. * Set the value of an uniform to an array of float32 (stored as vec3)
  95642. * @param uniform defines the webGL uniform location where to store the value
  95643. * @param array defines the array of float32 to store
  95644. */
  95645. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95646. /**
  95647. * Set the value of an uniform to an array of float32 (stored as vec4)
  95648. * @param uniform defines the webGL uniform location where to store the value
  95649. * @param array defines the array of float32 to store
  95650. */
  95651. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95652. /**
  95653. * Set the value of an uniform to an array of number
  95654. * @param uniform defines the webGL uniform location where to store the value
  95655. * @param array defines the array of number to store
  95656. */
  95657. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95658. /**
  95659. * Set the value of an uniform to an array of number (stored as vec2)
  95660. * @param uniform defines the webGL uniform location where to store the value
  95661. * @param array defines the array of number to store
  95662. */
  95663. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95664. /**
  95665. * Set the value of an uniform to an array of number (stored as vec3)
  95666. * @param uniform defines the webGL uniform location where to store the value
  95667. * @param array defines the array of number to store
  95668. */
  95669. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95670. /**
  95671. * Set the value of an uniform to an array of number (stored as vec4)
  95672. * @param uniform defines the webGL uniform location where to store the value
  95673. * @param array defines the array of number to store
  95674. */
  95675. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95676. /**
  95677. * Set the value of an uniform to an array of float32 (stored as matrices)
  95678. * @param uniform defines the webGL uniform location where to store the value
  95679. * @param matrices defines the array of float32 to store
  95680. */
  95681. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95682. /**
  95683. * Set the value of an uniform to a matrix (3x3)
  95684. * @param uniform defines the webGL uniform location where to store the value
  95685. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95686. */
  95687. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95688. /**
  95689. * Set the value of an uniform to a matrix (2x2)
  95690. * @param uniform defines the webGL uniform location where to store the value
  95691. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95692. */
  95693. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95694. /**
  95695. * Set the value of an uniform to a number (int)
  95696. * @param uniform defines the webGL uniform location where to store the value
  95697. * @param value defines the int number to store
  95698. */
  95699. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95700. /**
  95701. * Set the value of an uniform to a number (float)
  95702. * @param uniform defines the webGL uniform location where to store the value
  95703. * @param value defines the float number to store
  95704. */
  95705. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95706. /**
  95707. * Set the value of an uniform to a vec2
  95708. * @param uniform defines the webGL uniform location where to store the value
  95709. * @param x defines the 1st component of the value
  95710. * @param y defines the 2nd component of the value
  95711. */
  95712. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95713. /**
  95714. * Set the value of an uniform to a vec3
  95715. * @param uniform defines the webGL uniform location where to store the value
  95716. * @param x defines the 1st component of the value
  95717. * @param y defines the 2nd component of the value
  95718. * @param z defines the 3rd component of the value
  95719. */
  95720. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95721. /**
  95722. * Set the value of an uniform to a boolean
  95723. * @param uniform defines the webGL uniform location where to store the value
  95724. * @param bool defines the boolean to store
  95725. */
  95726. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95727. /**
  95728. * Set the value of an uniform to a vec4
  95729. * @param uniform defines the webGL uniform location where to store the value
  95730. * @param x defines the 1st component of the value
  95731. * @param y defines the 2nd component of the value
  95732. * @param z defines the 3rd component of the value
  95733. * @param w defines the 4th component of the value
  95734. */
  95735. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95736. /**
  95737. * Sets a Color4 on a uniform variable
  95738. * @param uniform defines the uniform location
  95739. * @param color4 defines the value to be set
  95740. */
  95741. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95742. /**
  95743. * Set various states to the webGL context
  95744. * @param culling defines backface culling state
  95745. * @param zOffset defines the value to apply to zOffset (0 by default)
  95746. * @param force defines if states must be applied even if cache is up to date
  95747. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95748. */
  95749. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95750. /**
  95751. * Set the z offset to apply to current rendering
  95752. * @param value defines the offset to apply
  95753. */
  95754. setZOffset(value: number): void;
  95755. /**
  95756. * Gets the current value of the zOffset
  95757. * @returns the current zOffset state
  95758. */
  95759. getZOffset(): number;
  95760. /**
  95761. * Enable or disable depth buffering
  95762. * @param enable defines the state to set
  95763. */
  95764. setDepthBuffer(enable: boolean): void;
  95765. /**
  95766. * Gets a boolean indicating if depth writing is enabled
  95767. * @returns the current depth writing state
  95768. */
  95769. getDepthWrite(): boolean;
  95770. /**
  95771. * Enable or disable depth writing
  95772. * @param enable defines the state to set
  95773. */
  95774. setDepthWrite(enable: boolean): void;
  95775. /**
  95776. * Enable or disable color writing
  95777. * @param enable defines the state to set
  95778. */
  95779. setColorWrite(enable: boolean): void;
  95780. /**
  95781. * Gets a boolean indicating if color writing is enabled
  95782. * @returns the current color writing state
  95783. */
  95784. getColorWrite(): boolean;
  95785. /**
  95786. * Sets alpha constants used by some alpha blending modes
  95787. * @param r defines the red component
  95788. * @param g defines the green component
  95789. * @param b defines the blue component
  95790. * @param a defines the alpha component
  95791. */
  95792. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95793. /**
  95794. * Sets the current alpha mode
  95795. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95796. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95797. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95798. */
  95799. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95800. /**
  95801. * Gets the current alpha mode
  95802. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95803. * @returns the current alpha mode
  95804. */
  95805. getAlphaMode(): number;
  95806. /**
  95807. * Clears the list of texture accessible through engine.
  95808. * This can help preventing texture load conflict due to name collision.
  95809. */
  95810. clearInternalTexturesCache(): void;
  95811. /**
  95812. * Force the entire cache to be cleared
  95813. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95814. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95815. */
  95816. wipeCaches(bruteForce?: boolean): void;
  95817. /**
  95818. * Set the compressed texture format to use, based on the formats you have, and the formats
  95819. * supported by the hardware / browser.
  95820. *
  95821. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95822. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95823. * to API arguments needed to compressed textures. This puts the burden on the container
  95824. * generator to house the arcane code for determining these for current & future formats.
  95825. *
  95826. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95827. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95828. *
  95829. * Note: The result of this call is not taken into account when a texture is base64.
  95830. *
  95831. * @param formatsAvailable defines the list of those format families you have created
  95832. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95833. *
  95834. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95835. * @returns The extension selected.
  95836. */
  95837. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95838. /** @hidden */
  95839. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95840. min: number;
  95841. mag: number;
  95842. };
  95843. /** @hidden */
  95844. _createTexture(): WebGLTexture;
  95845. /**
  95846. * Usually called from Texture.ts.
  95847. * Passed information to create a WebGLTexture
  95848. * @param urlArg defines a value which contains one of the following:
  95849. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95850. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95851. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95852. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95853. * @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)
  95854. * @param scene needed for loading to the correct scene
  95855. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95856. * @param onLoad optional callback to be called upon successful completion
  95857. * @param onError optional callback to be called upon failure
  95858. * @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
  95859. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95860. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95861. * @param forcedExtension defines the extension to use to pick the right loader
  95862. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95863. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95864. */
  95865. 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;
  95866. /**
  95867. * @hidden
  95868. * Rescales a texture
  95869. * @param source input texutre
  95870. * @param destination destination texture
  95871. * @param scene scene to use to render the resize
  95872. * @param internalFormat format to use when resizing
  95873. * @param onComplete callback to be called when resize has completed
  95874. */
  95875. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95876. private _unpackFlipYCached;
  95877. /**
  95878. * In case you are sharing the context with other applications, it might
  95879. * be interested to not cache the unpack flip y state to ensure a consistent
  95880. * value would be set.
  95881. */
  95882. enableUnpackFlipYCached: boolean;
  95883. /** @hidden */
  95884. _unpackFlipY(value: boolean): void;
  95885. /** @hidden */
  95886. _getUnpackAlignement(): number;
  95887. /**
  95888. * Creates a dynamic texture
  95889. * @param width defines the width of the texture
  95890. * @param height defines the height of the texture
  95891. * @param generateMipMaps defines if the engine should generate the mip levels
  95892. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95893. * @returns the dynamic texture inside an InternalTexture
  95894. */
  95895. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95896. /**
  95897. * Update the sampling mode of a given texture
  95898. * @param samplingMode defines the required sampling mode
  95899. * @param texture defines the texture to update
  95900. */
  95901. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95902. /**
  95903. * Update the content of a dynamic texture
  95904. * @param texture defines the texture to update
  95905. * @param canvas defines the canvas containing the source
  95906. * @param invertY defines if data must be stored with Y axis inverted
  95907. * @param premulAlpha defines if alpha is stored as premultiplied
  95908. * @param format defines the format of the data
  95909. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95910. */
  95911. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95912. /**
  95913. * Update a video texture
  95914. * @param texture defines the texture to update
  95915. * @param video defines the video element to use
  95916. * @param invertY defines if data must be stored with Y axis inverted
  95917. */
  95918. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95919. /**
  95920. * Updates a depth texture Comparison Mode and Function.
  95921. * If the comparison Function is equal to 0, the mode will be set to none.
  95922. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95923. * @param texture The texture to set the comparison function for
  95924. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95925. */
  95926. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95927. /** @hidden */
  95928. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95929. width: number;
  95930. height: number;
  95931. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95932. /**
  95933. * Creates a depth stencil texture.
  95934. * This is only available in WebGL 2 or with the depth texture extension available.
  95935. * @param size The size of face edge in the texture.
  95936. * @param options The options defining the texture.
  95937. * @returns The texture
  95938. */
  95939. createDepthStencilTexture(size: number | {
  95940. width: number;
  95941. height: number;
  95942. }, options: DepthTextureCreationOptions): InternalTexture;
  95943. /**
  95944. * Creates a depth stencil texture.
  95945. * This is only available in WebGL 2 or with the depth texture extension available.
  95946. * @param size The size of face edge in the texture.
  95947. * @param options The options defining the texture.
  95948. * @returns The texture
  95949. */
  95950. private _createDepthStencilTexture;
  95951. /**
  95952. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95953. * @param renderTarget The render target to set the frame buffer for
  95954. */
  95955. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95956. /**
  95957. * Creates a new render target texture
  95958. * @param size defines the size of the texture
  95959. * @param options defines the options used to create the texture
  95960. * @returns a new render target texture stored in an InternalTexture
  95961. */
  95962. createRenderTargetTexture(size: number | {
  95963. width: number;
  95964. height: number;
  95965. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95966. /** @hidden */
  95967. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95968. /**
  95969. * Updates the sample count of a render target texture
  95970. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95971. * @param texture defines the texture to update
  95972. * @param samples defines the sample count to set
  95973. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95974. */
  95975. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95976. /** @hidden */
  95977. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95978. /** @hidden */
  95979. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95980. /** @hidden */
  95981. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95982. /** @hidden */
  95983. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95984. /**
  95985. * @hidden
  95986. */
  95987. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95988. private _prepareWebGLTextureContinuation;
  95989. private _prepareWebGLTexture;
  95990. /** @hidden */
  95991. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95992. /** @hidden */
  95993. _releaseFramebufferObjects(texture: InternalTexture): void;
  95994. /** @hidden */
  95995. _releaseTexture(texture: InternalTexture): void;
  95996. private setProgram;
  95997. private _boundUniforms;
  95998. /**
  95999. * Binds an effect to the webGL context
  96000. * @param effect defines the effect to bind
  96001. */
  96002. bindSamplers(effect: Effect): void;
  96003. private _activateCurrentTexture;
  96004. /** @hidden */
  96005. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96006. /** @hidden */
  96007. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96008. /**
  96009. * Sets a texture to the webGL context from a postprocess
  96010. * @param channel defines the channel to use
  96011. * @param postProcess defines the source postprocess
  96012. */
  96013. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96014. /**
  96015. * Binds the output of the passed in post process to the texture channel specified
  96016. * @param channel The channel the texture should be bound to
  96017. * @param postProcess The post process which's output should be bound
  96018. */
  96019. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96020. /**
  96021. * Unbind all textures from the webGL context
  96022. */
  96023. unbindAllTextures(): void;
  96024. /**
  96025. * Sets a texture to the according uniform.
  96026. * @param channel The texture channel
  96027. * @param uniform The uniform to set
  96028. * @param texture The texture to apply
  96029. */
  96030. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96031. /**
  96032. * Sets a depth stencil texture from a render target to the according uniform.
  96033. * @param channel The texture channel
  96034. * @param uniform The uniform to set
  96035. * @param texture The render target texture containing the depth stencil texture to apply
  96036. */
  96037. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96038. private _bindSamplerUniformToChannel;
  96039. private _getTextureWrapMode;
  96040. private _setTexture;
  96041. /**
  96042. * Sets an array of texture to the webGL context
  96043. * @param channel defines the channel where the texture array must be set
  96044. * @param uniform defines the associated uniform location
  96045. * @param textures defines the array of textures to bind
  96046. */
  96047. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96048. /** @hidden */
  96049. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96050. private _setTextureParameterFloat;
  96051. private _setTextureParameterInteger;
  96052. /**
  96053. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96054. * @param x defines the x coordinate of the rectangle where pixels must be read
  96055. * @param y defines the y coordinate of the rectangle where pixels must be read
  96056. * @param width defines the width of the rectangle where pixels must be read
  96057. * @param height defines the height of the rectangle where pixels must be read
  96058. * @returns a Uint8Array containing RGBA colors
  96059. */
  96060. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96061. /**
  96062. * Add an externaly attached data from its key.
  96063. * This method call will fail and return false, if such key already exists.
  96064. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96065. * @param key the unique key that identifies the data
  96066. * @param data the data object to associate to the key for this Engine instance
  96067. * @return true if no such key were already present and the data was added successfully, false otherwise
  96068. */
  96069. addExternalData<T>(key: string, data: T): boolean;
  96070. /**
  96071. * Get an externaly attached data from its key
  96072. * @param key the unique key that identifies the data
  96073. * @return the associated data, if present (can be null), or undefined if not present
  96074. */
  96075. getExternalData<T>(key: string): T;
  96076. /**
  96077. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96078. * @param key the unique key that identifies the data
  96079. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96080. * @return the associated data, can be null if the factory returned null.
  96081. */
  96082. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96083. /**
  96084. * Remove an externaly attached data from the Engine instance
  96085. * @param key the unique key that identifies the data
  96086. * @return true if the data was successfully removed, false if it doesn't exist
  96087. */
  96088. removeExternalData(key: string): boolean;
  96089. /**
  96090. * Unbind all vertex attributes from the webGL context
  96091. */
  96092. unbindAllAttributes(): void;
  96093. /**
  96094. * 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
  96095. */
  96096. releaseEffects(): void;
  96097. /**
  96098. * Dispose and release all associated resources
  96099. */
  96100. dispose(): void;
  96101. /**
  96102. * Display the loading screen
  96103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96104. */
  96105. displayLoadingUI(): void;
  96106. /**
  96107. * Hide the loading screen
  96108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96109. */
  96110. hideLoadingUI(): void;
  96111. /**
  96112. * Gets the current loading screen object
  96113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96114. */
  96115. /**
  96116. * Sets the current loading screen object
  96117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96118. */
  96119. loadingScreen: ILoadingScreen;
  96120. /**
  96121. * Sets the current loading screen text
  96122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96123. */
  96124. loadingUIText: string;
  96125. /**
  96126. * Sets the current loading screen background color
  96127. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96128. */
  96129. loadingUIBackgroundColor: string;
  96130. /**
  96131. * Attach a new callback raised when context lost event is fired
  96132. * @param callback defines the callback to call
  96133. */
  96134. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96135. /**
  96136. * Attach a new callback raised when context restored event is fired
  96137. * @param callback defines the callback to call
  96138. */
  96139. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96140. /**
  96141. * Gets the source code of the vertex shader associated with a specific webGL program
  96142. * @param program defines the program to use
  96143. * @returns a string containing the source code of the vertex shader associated with the program
  96144. */
  96145. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96146. /**
  96147. * Gets the source code of the fragment shader associated with a specific webGL program
  96148. * @param program defines the program to use
  96149. * @returns a string containing the source code of the fragment shader associated with the program
  96150. */
  96151. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96152. /**
  96153. * Get the current error code of the webGL context
  96154. * @returns the error code
  96155. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96156. */
  96157. getError(): number;
  96158. /**
  96159. * Gets the current framerate
  96160. * @returns a number representing the framerate
  96161. */
  96162. getFps(): number;
  96163. /**
  96164. * Gets the time spent between current and previous frame
  96165. * @returns a number representing the delta time in ms
  96166. */
  96167. getDeltaTime(): number;
  96168. private _measureFps;
  96169. /** @hidden */
  96170. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96171. private _canRenderToFloatFramebuffer;
  96172. private _canRenderToHalfFloatFramebuffer;
  96173. private _canRenderToFramebuffer;
  96174. /** @hidden */
  96175. _getWebGLTextureType(type: number): number;
  96176. /** @hidden */
  96177. _getInternalFormat(format: number): number;
  96178. /** @hidden */
  96179. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96180. /** @hidden */
  96181. _getRGBAMultiSampleBufferFormat(type: number): number;
  96182. /** @hidden */
  96183. _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;
  96184. /** @hidden */
  96185. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96186. /**
  96187. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96188. * @returns true if the engine can be created
  96189. * @ignorenaming
  96190. */
  96191. static isSupported(): boolean;
  96192. /**
  96193. * Find the next highest power of two.
  96194. * @param x Number to start search from.
  96195. * @return Next highest power of two.
  96196. */
  96197. static CeilingPOT(x: number): number;
  96198. /**
  96199. * Find the next lowest power of two.
  96200. * @param x Number to start search from.
  96201. * @return Next lowest power of two.
  96202. */
  96203. static FloorPOT(x: number): number;
  96204. /**
  96205. * Find the nearest power of two.
  96206. * @param x Number to start search from.
  96207. * @return Next nearest power of two.
  96208. */
  96209. static NearestPOT(x: number): number;
  96210. /**
  96211. * Get the closest exponent of two
  96212. * @param value defines the value to approximate
  96213. * @param max defines the maximum value to return
  96214. * @param mode defines how to define the closest value
  96215. * @returns closest exponent of two of the given value
  96216. */
  96217. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96218. /**
  96219. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96220. * @param func - the function to be called
  96221. * @param requester - the object that will request the next frame. Falls back to window.
  96222. * @returns frame number
  96223. */
  96224. static QueueNewFrame(func: () => void, requester?: any): number;
  96225. /**
  96226. * Ask the browser to promote the current element to pointerlock mode
  96227. * @param element defines the DOM element to promote
  96228. */
  96229. static _RequestPointerlock(element: HTMLElement): void;
  96230. /**
  96231. * Asks the browser to exit pointerlock mode
  96232. */
  96233. static _ExitPointerlock(): void;
  96234. /**
  96235. * Ask the browser to promote the current element to fullscreen rendering mode
  96236. * @param element defines the DOM element to promote
  96237. */
  96238. static _RequestFullscreen(element: HTMLElement): void;
  96239. /**
  96240. * Asks the browser to exit fullscreen mode
  96241. */
  96242. static _ExitFullscreen(): void;
  96243. }
  96244. }
  96245. declare module BABYLON {
  96246. /**
  96247. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96248. * during the life time of the application.
  96249. */
  96250. export class EngineStore {
  96251. /** Gets the list of created engines */
  96252. static Instances: Engine[];
  96253. /** @hidden */
  96254. static _LastCreatedScene: Nullable<Scene>;
  96255. /**
  96256. * Gets the latest created engine
  96257. */
  96258. static readonly LastCreatedEngine: Nullable<Engine>;
  96259. /**
  96260. * Gets the latest created scene
  96261. */
  96262. static readonly LastCreatedScene: Nullable<Scene>;
  96263. /**
  96264. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96265. * @ignorenaming
  96266. */
  96267. static UseFallbackTexture: boolean;
  96268. /**
  96269. * Texture content used if a texture cannot loaded
  96270. * @ignorenaming
  96271. */
  96272. static FallbackTexture: string;
  96273. }
  96274. }
  96275. declare module BABYLON {
  96276. /**
  96277. * Helper class that provides a small promise polyfill
  96278. */
  96279. export class PromisePolyfill {
  96280. /**
  96281. * Static function used to check if the polyfill is required
  96282. * If this is the case then the function will inject the polyfill to window.Promise
  96283. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96284. */
  96285. static Apply(force?: boolean): void;
  96286. }
  96287. }
  96288. declare module BABYLON {
  96289. /**
  96290. * Interface for screenshot methods with describe argument called `size` as object with options
  96291. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96292. */
  96293. export interface IScreenshotSize {
  96294. /**
  96295. * number in pixels for canvas height
  96296. */
  96297. height?: number;
  96298. /**
  96299. * multiplier allowing render at a higher or lower resolution
  96300. * If value is defined then height and width will be ignored and taken from camera
  96301. */
  96302. precision?: number;
  96303. /**
  96304. * number in pixels for canvas width
  96305. */
  96306. width?: number;
  96307. }
  96308. }
  96309. declare module BABYLON {
  96310. interface IColor4Like {
  96311. r: float;
  96312. g: float;
  96313. b: float;
  96314. a: float;
  96315. }
  96316. /**
  96317. * Class containing a set of static utilities functions
  96318. */
  96319. export class Tools {
  96320. /**
  96321. * Gets or sets the base URL to use to load assets
  96322. */
  96323. static BaseUrl: string;
  96324. /**
  96325. * Enable/Disable Custom HTTP Request Headers globally.
  96326. * default = false
  96327. * @see CustomRequestHeaders
  96328. */
  96329. static UseCustomRequestHeaders: boolean;
  96330. /**
  96331. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96332. * i.e. when loading files, where the server/service expects an Authorization header
  96333. */
  96334. static CustomRequestHeaders: {
  96335. [key: string]: string;
  96336. };
  96337. /**
  96338. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96339. */
  96340. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96341. /**
  96342. * Default behaviour for cors in the application.
  96343. * It can be a string if the expected behavior is identical in the entire app.
  96344. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96345. */
  96346. static CorsBehavior: string | ((url: string | string[]) => string);
  96347. /**
  96348. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96349. * @ignorenaming
  96350. */
  96351. static UseFallbackTexture: boolean;
  96352. /**
  96353. * Use this object to register external classes like custom textures or material
  96354. * to allow the laoders to instantiate them
  96355. */
  96356. static RegisteredExternalClasses: {
  96357. [key: string]: Object;
  96358. };
  96359. /**
  96360. * Texture content used if a texture cannot loaded
  96361. * @ignorenaming
  96362. */
  96363. static fallbackTexture: string;
  96364. /**
  96365. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96366. * @param u defines the coordinate on X axis
  96367. * @param v defines the coordinate on Y axis
  96368. * @param width defines the width of the source data
  96369. * @param height defines the height of the source data
  96370. * @param pixels defines the source byte array
  96371. * @param color defines the output color
  96372. */
  96373. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96374. /**
  96375. * Interpolates between a and b via alpha
  96376. * @param a The lower value (returned when alpha = 0)
  96377. * @param b The upper value (returned when alpha = 1)
  96378. * @param alpha The interpolation-factor
  96379. * @return The mixed value
  96380. */
  96381. static Mix(a: number, b: number, alpha: number): number;
  96382. /**
  96383. * Tries to instantiate a new object from a given class name
  96384. * @param className defines the class name to instantiate
  96385. * @returns the new object or null if the system was not able to do the instantiation
  96386. */
  96387. static Instantiate(className: string): any;
  96388. /**
  96389. * Provides a slice function that will work even on IE
  96390. * @param data defines the array to slice
  96391. * @param start defines the start of the data (optional)
  96392. * @param end defines the end of the data (optional)
  96393. * @returns the new sliced array
  96394. */
  96395. static Slice<T>(data: T, start?: number, end?: number): T;
  96396. /**
  96397. * Polyfill for setImmediate
  96398. * @param action defines the action to execute after the current execution block
  96399. */
  96400. static SetImmediate(action: () => void): void;
  96401. /**
  96402. * Function indicating if a number is an exponent of 2
  96403. * @param value defines the value to test
  96404. * @returns true if the value is an exponent of 2
  96405. */
  96406. static IsExponentOfTwo(value: number): boolean;
  96407. private static _tmpFloatArray;
  96408. /**
  96409. * Returns the nearest 32-bit single precision float representation of a Number
  96410. * @param value A Number. If the parameter is of a different type, it will get converted
  96411. * to a number or to NaN if it cannot be converted
  96412. * @returns number
  96413. */
  96414. static FloatRound(value: number): number;
  96415. /**
  96416. * Extracts the filename from a path
  96417. * @param path defines the path to use
  96418. * @returns the filename
  96419. */
  96420. static GetFilename(path: string): string;
  96421. /**
  96422. * Extracts the "folder" part of a path (everything before the filename).
  96423. * @param uri The URI to extract the info from
  96424. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96425. * @returns The "folder" part of the path
  96426. */
  96427. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96428. /**
  96429. * Extracts text content from a DOM element hierarchy
  96430. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96431. */
  96432. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96433. /**
  96434. * Convert an angle in radians to degrees
  96435. * @param angle defines the angle to convert
  96436. * @returns the angle in degrees
  96437. */
  96438. static ToDegrees(angle: number): number;
  96439. /**
  96440. * Convert an angle in degrees to radians
  96441. * @param angle defines the angle to convert
  96442. * @returns the angle in radians
  96443. */
  96444. static ToRadians(angle: number): number;
  96445. /**
  96446. * Encode a buffer to a base64 string
  96447. * @param buffer defines the buffer to encode
  96448. * @returns the encoded string
  96449. */
  96450. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96451. /**
  96452. * Returns an array if obj is not an array
  96453. * @param obj defines the object to evaluate as an array
  96454. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96455. * @returns either obj directly if obj is an array or a new array containing obj
  96456. */
  96457. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96458. /**
  96459. * Gets the pointer prefix to use
  96460. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96461. */
  96462. static GetPointerPrefix(): string;
  96463. /**
  96464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96465. * @param url define the url we are trying
  96466. * @param element define the dom element where to configure the cors policy
  96467. */
  96468. static SetCorsBehavior(url: string | string[], element: {
  96469. crossOrigin: string | null;
  96470. }): void;
  96471. /**
  96472. * Removes unwanted characters from an url
  96473. * @param url defines the url to clean
  96474. * @returns the cleaned url
  96475. */
  96476. static CleanUrl(url: string): string;
  96477. /**
  96478. * Gets or sets a function used to pre-process url before using them to load assets
  96479. */
  96480. static PreprocessUrl: (url: string) => string;
  96481. /**
  96482. * Loads an image as an HTMLImageElement.
  96483. * @param input url string, ArrayBuffer, or Blob to load
  96484. * @param onLoad callback called when the image successfully loads
  96485. * @param onError callback called when the image fails to load
  96486. * @param offlineProvider offline provider for caching
  96487. * @returns the HTMLImageElement of the loaded image
  96488. */
  96489. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96490. /**
  96491. * Loads a file
  96492. * @param url url string, ArrayBuffer, or Blob to load
  96493. * @param onSuccess callback called when the file successfully loads
  96494. * @param onProgress callback called while file is loading (if the server supports this mode)
  96495. * @param offlineProvider defines the offline provider for caching
  96496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96497. * @param onError callback called when the file fails to load
  96498. * @returns a file request object
  96499. */
  96500. 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;
  96501. /**
  96502. * Loads a file from a url
  96503. * @param url the file url to load
  96504. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96505. */
  96506. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96507. /**
  96508. * Load a script (identified by an url). When the url returns, the
  96509. * content of this file is added into a new script element, attached to the DOM (body element)
  96510. * @param scriptUrl defines the url of the script to laod
  96511. * @param onSuccess defines the callback called when the script is loaded
  96512. * @param onError defines the callback to call if an error occurs
  96513. * @param scriptId defines the id of the script element
  96514. */
  96515. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96516. /**
  96517. * Load an asynchronous script (identified by an url). When the url returns, the
  96518. * content of this file is added into a new script element, attached to the DOM (body element)
  96519. * @param scriptUrl defines the url of the script to laod
  96520. * @param scriptId defines the id of the script element
  96521. * @returns a promise request object
  96522. */
  96523. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96524. /**
  96525. * Loads a file from a blob
  96526. * @param fileToLoad defines the blob to use
  96527. * @param callback defines the callback to call when data is loaded
  96528. * @param progressCallback defines the callback to call during loading process
  96529. * @returns a file request object
  96530. */
  96531. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96532. /**
  96533. * Loads a file
  96534. * @param fileToLoad defines the file to load
  96535. * @param callback defines the callback to call when data is loaded
  96536. * @param progressCallBack defines the callback to call during loading process
  96537. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96538. * @returns a file request object
  96539. */
  96540. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96541. /**
  96542. * Creates a data url from a given string content
  96543. * @param content defines the content to convert
  96544. * @returns the new data url link
  96545. */
  96546. static FileAsURL(content: string): string;
  96547. /**
  96548. * Format the given number to a specific decimal format
  96549. * @param value defines the number to format
  96550. * @param decimals defines the number of decimals to use
  96551. * @returns the formatted string
  96552. */
  96553. static Format(value: number, decimals?: number): string;
  96554. /**
  96555. * Tries to copy an object by duplicating every property
  96556. * @param source defines the source object
  96557. * @param destination defines the target object
  96558. * @param doNotCopyList defines a list of properties to avoid
  96559. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96560. */
  96561. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96562. /**
  96563. * Gets a boolean indicating if the given object has no own property
  96564. * @param obj defines the object to test
  96565. * @returns true if object has no own property
  96566. */
  96567. static IsEmpty(obj: any): boolean;
  96568. /**
  96569. * Function used to register events at window level
  96570. * @param windowElement defines the Window object to use
  96571. * @param events defines the events to register
  96572. */
  96573. static RegisterTopRootEvents(windowElement: Window, events: {
  96574. name: string;
  96575. handler: Nullable<(e: FocusEvent) => any>;
  96576. }[]): void;
  96577. /**
  96578. * Function used to unregister events from window level
  96579. * @param windowElement defines the Window object to use
  96580. * @param events defines the events to unregister
  96581. */
  96582. static UnregisterTopRootEvents(windowElement: Window, events: {
  96583. name: string;
  96584. handler: Nullable<(e: FocusEvent) => any>;
  96585. }[]): void;
  96586. /**
  96587. * @ignore
  96588. */
  96589. static _ScreenshotCanvas: HTMLCanvasElement;
  96590. /**
  96591. * Dumps the current bound framebuffer
  96592. * @param width defines the rendering width
  96593. * @param height defines the rendering height
  96594. * @param engine defines the hosting engine
  96595. * @param successCallback defines the callback triggered once the data are available
  96596. * @param mimeType defines the mime type of the result
  96597. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96598. */
  96599. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96600. /**
  96601. * Converts the canvas data to blob.
  96602. * This acts as a polyfill for browsers not supporting the to blob function.
  96603. * @param canvas Defines the canvas to extract the data from
  96604. * @param successCallback Defines the callback triggered once the data are available
  96605. * @param mimeType Defines the mime type of the result
  96606. */
  96607. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96608. /**
  96609. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96610. * @param successCallback defines the callback triggered once the data are available
  96611. * @param mimeType defines the mime type of the result
  96612. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96613. */
  96614. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96615. /**
  96616. * Downloads a blob in the browser
  96617. * @param blob defines the blob to download
  96618. * @param fileName defines the name of the downloaded file
  96619. */
  96620. static Download(blob: Blob, fileName: string): void;
  96621. /**
  96622. * Captures a screenshot of the current rendering
  96623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96624. * @param engine defines the rendering engine
  96625. * @param camera defines the source camera
  96626. * @param size This parameter can be set to a single number or to an object with the
  96627. * following (optional) properties: precision, width, height. If a single number is passed,
  96628. * it will be used for both width and height. If an object is passed, the screenshot size
  96629. * will be derived from the parameters. The precision property is a multiplier allowing
  96630. * rendering at a higher or lower resolution
  96631. * @param successCallback defines the callback receives a single parameter which contains the
  96632. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96633. * src parameter of an <img> to display it
  96634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96635. * Check your browser for supported MIME types
  96636. */
  96637. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96638. /**
  96639. * Captures a screenshot of the current rendering
  96640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96641. * @param engine defines the rendering engine
  96642. * @param camera defines the source camera
  96643. * @param size This parameter can be set to a single number or to an object with the
  96644. * following (optional) properties: precision, width, height. If a single number is passed,
  96645. * it will be used for both width and height. If an object is passed, the screenshot size
  96646. * will be derived from the parameters. The precision property is a multiplier allowing
  96647. * rendering at a higher or lower resolution
  96648. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96649. * Check your browser for supported MIME types
  96650. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96651. * to the src parameter of an <img> to display it
  96652. */
  96653. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96654. /**
  96655. * Generates an image screenshot from the specified camera.
  96656. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96657. * @param engine The engine to use for rendering
  96658. * @param camera The camera to use for rendering
  96659. * @param size This parameter can be set to a single number or to an object with the
  96660. * following (optional) properties: precision, width, height. If a single number is passed,
  96661. * it will be used for both width and height. If an object is passed, the screenshot size
  96662. * will be derived from the parameters. The precision property is a multiplier allowing
  96663. * rendering at a higher or lower resolution
  96664. * @param successCallback The callback receives a single parameter which contains the
  96665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96666. * src parameter of an <img> to display it
  96667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96668. * Check your browser for supported MIME types
  96669. * @param samples Texture samples (default: 1)
  96670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96671. * @param fileName A name for for the downloaded file.
  96672. */
  96673. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96674. /**
  96675. * Generates an image screenshot from the specified camera.
  96676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96677. * @param engine The engine to use for rendering
  96678. * @param camera The camera to use for rendering
  96679. * @param size This parameter can be set to a single number or to an object with the
  96680. * following (optional) properties: precision, width, height. If a single number is passed,
  96681. * it will be used for both width and height. If an object is passed, the screenshot size
  96682. * will be derived from the parameters. The precision property is a multiplier allowing
  96683. * rendering at a higher or lower resolution
  96684. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96685. * Check your browser for supported MIME types
  96686. * @param samples Texture samples (default: 1)
  96687. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96688. * @param fileName A name for for the downloaded file.
  96689. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96690. * to the src parameter of an <img> to display it
  96691. */
  96692. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96693. /**
  96694. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96695. * Be aware Math.random() could cause collisions, but:
  96696. * "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"
  96697. * @returns a pseudo random id
  96698. */
  96699. static RandomId(): string;
  96700. /**
  96701. * Test if the given uri is a base64 string
  96702. * @param uri The uri to test
  96703. * @return True if the uri is a base64 string or false otherwise
  96704. */
  96705. static IsBase64(uri: string): boolean;
  96706. /**
  96707. * Decode the given base64 uri.
  96708. * @param uri The uri to decode
  96709. * @return The decoded base64 data.
  96710. */
  96711. static DecodeBase64(uri: string): ArrayBuffer;
  96712. /**
  96713. * Gets the absolute url.
  96714. * @param url the input url
  96715. * @return the absolute url
  96716. */
  96717. static GetAbsoluteUrl(url: string): string;
  96718. /**
  96719. * No log
  96720. */
  96721. static readonly NoneLogLevel: number;
  96722. /**
  96723. * Only message logs
  96724. */
  96725. static readonly MessageLogLevel: number;
  96726. /**
  96727. * Only warning logs
  96728. */
  96729. static readonly WarningLogLevel: number;
  96730. /**
  96731. * Only error logs
  96732. */
  96733. static readonly ErrorLogLevel: number;
  96734. /**
  96735. * All logs
  96736. */
  96737. static readonly AllLogLevel: number;
  96738. /**
  96739. * Gets a value indicating the number of loading errors
  96740. * @ignorenaming
  96741. */
  96742. static readonly errorsCount: number;
  96743. /**
  96744. * Callback called when a new log is added
  96745. */
  96746. static OnNewCacheEntry: (entry: string) => void;
  96747. /**
  96748. * Log a message to the console
  96749. * @param message defines the message to log
  96750. */
  96751. static Log(message: string): void;
  96752. /**
  96753. * Write a warning message to the console
  96754. * @param message defines the message to log
  96755. */
  96756. static Warn(message: string): void;
  96757. /**
  96758. * Write an error message to the console
  96759. * @param message defines the message to log
  96760. */
  96761. static Error(message: string): void;
  96762. /**
  96763. * Gets current log cache (list of logs)
  96764. */
  96765. static readonly LogCache: string;
  96766. /**
  96767. * Clears the log cache
  96768. */
  96769. static ClearLogCache(): void;
  96770. /**
  96771. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96772. */
  96773. static LogLevels: number;
  96774. /**
  96775. * Checks if the window object exists
  96776. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96777. */
  96778. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96779. /**
  96780. * No performance log
  96781. */
  96782. static readonly PerformanceNoneLogLevel: number;
  96783. /**
  96784. * Use user marks to log performance
  96785. */
  96786. static readonly PerformanceUserMarkLogLevel: number;
  96787. /**
  96788. * Log performance to the console
  96789. */
  96790. static readonly PerformanceConsoleLogLevel: number;
  96791. private static _performance;
  96792. /**
  96793. * Sets the current performance log level
  96794. */
  96795. static PerformanceLogLevel: number;
  96796. private static _StartPerformanceCounterDisabled;
  96797. private static _EndPerformanceCounterDisabled;
  96798. private static _StartUserMark;
  96799. private static _EndUserMark;
  96800. private static _StartPerformanceConsole;
  96801. private static _EndPerformanceConsole;
  96802. /**
  96803. * Starts a performance counter
  96804. */
  96805. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96806. /**
  96807. * Ends a specific performance coutner
  96808. */
  96809. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96810. /**
  96811. * Gets either window.performance.now() if supported or Date.now() else
  96812. */
  96813. static readonly Now: number;
  96814. /**
  96815. * This method will return the name of the class used to create the instance of the given object.
  96816. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96817. * @param object the object to get the class name from
  96818. * @param isType defines if the object is actually a type
  96819. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96820. */
  96821. static GetClassName(object: any, isType?: boolean): string;
  96822. /**
  96823. * Gets the first element of an array satisfying a given predicate
  96824. * @param array defines the array to browse
  96825. * @param predicate defines the predicate to use
  96826. * @returns null if not found or the element
  96827. */
  96828. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96829. /**
  96830. * This method will return the name of the full name of the class, including its owning module (if any).
  96831. * 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).
  96832. * @param object the object to get the class name from
  96833. * @param isType defines if the object is actually a type
  96834. * @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.
  96835. * @ignorenaming
  96836. */
  96837. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96838. /**
  96839. * Returns a promise that resolves after the given amount of time.
  96840. * @param delay Number of milliseconds to delay
  96841. * @returns Promise that resolves after the given amount of time
  96842. */
  96843. static DelayAsync(delay: number): Promise<void>;
  96844. }
  96845. /**
  96846. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96847. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96848. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96849. * @param name The name of the class, case should be preserved
  96850. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96851. */
  96852. export function className(name: string, module?: string): (target: Object) => void;
  96853. /**
  96854. * An implementation of a loop for asynchronous functions.
  96855. */
  96856. export class AsyncLoop {
  96857. /**
  96858. * Defines the number of iterations for the loop
  96859. */
  96860. iterations: number;
  96861. /**
  96862. * Defines the current index of the loop.
  96863. */
  96864. index: number;
  96865. private _done;
  96866. private _fn;
  96867. private _successCallback;
  96868. /**
  96869. * Constructor.
  96870. * @param iterations the number of iterations.
  96871. * @param func the function to run each iteration
  96872. * @param successCallback the callback that will be called upon succesful execution
  96873. * @param offset starting offset.
  96874. */
  96875. constructor(
  96876. /**
  96877. * Defines the number of iterations for the loop
  96878. */
  96879. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96880. /**
  96881. * Execute the next iteration. Must be called after the last iteration was finished.
  96882. */
  96883. executeNext(): void;
  96884. /**
  96885. * Break the loop and run the success callback.
  96886. */
  96887. breakLoop(): void;
  96888. /**
  96889. * Create and run an async loop.
  96890. * @param iterations the number of iterations.
  96891. * @param fn the function to run each iteration
  96892. * @param successCallback the callback that will be called upon succesful execution
  96893. * @param offset starting offset.
  96894. * @returns the created async loop object
  96895. */
  96896. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96897. /**
  96898. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96899. * @param iterations total number of iterations
  96900. * @param syncedIterations number of synchronous iterations in each async iteration.
  96901. * @param fn the function to call each iteration.
  96902. * @param callback a success call back that will be called when iterating stops.
  96903. * @param breakFunction a break condition (optional)
  96904. * @param timeout timeout settings for the setTimeout function. default - 0.
  96905. * @returns the created async loop object
  96906. */
  96907. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96908. }
  96909. }
  96910. declare module BABYLON {
  96911. /** @hidden */
  96912. export interface ICollisionCoordinator {
  96913. createCollider(): Collider;
  96914. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96915. init(scene: Scene): void;
  96916. }
  96917. /** @hidden */
  96918. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96919. private _scene;
  96920. private _scaledPosition;
  96921. private _scaledVelocity;
  96922. private _finalPosition;
  96923. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96924. createCollider(): Collider;
  96925. init(scene: Scene): void;
  96926. private _collideWithWorld;
  96927. }
  96928. }
  96929. declare module BABYLON {
  96930. /**
  96931. * Class used to manage all inputs for the scene.
  96932. */
  96933. export class InputManager {
  96934. /** The distance in pixel that you have to move to prevent some events */
  96935. static DragMovementThreshold: number;
  96936. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96937. static LongPressDelay: number;
  96938. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96939. static DoubleClickDelay: number;
  96940. /** If you need to check double click without raising a single click at first click, enable this flag */
  96941. static ExclusiveDoubleClickMode: boolean;
  96942. private _wheelEventName;
  96943. private _onPointerMove;
  96944. private _onPointerDown;
  96945. private _onPointerUp;
  96946. private _initClickEvent;
  96947. private _initActionManager;
  96948. private _delayedSimpleClick;
  96949. private _delayedSimpleClickTimeout;
  96950. private _previousDelayedSimpleClickTimeout;
  96951. private _meshPickProceed;
  96952. private _previousButtonPressed;
  96953. private _currentPickResult;
  96954. private _previousPickResult;
  96955. private _totalPointersPressed;
  96956. private _doubleClickOccured;
  96957. private _pointerOverMesh;
  96958. private _pickedDownMesh;
  96959. private _pickedUpMesh;
  96960. private _pointerX;
  96961. private _pointerY;
  96962. private _unTranslatedPointerX;
  96963. private _unTranslatedPointerY;
  96964. private _startingPointerPosition;
  96965. private _previousStartingPointerPosition;
  96966. private _startingPointerTime;
  96967. private _previousStartingPointerTime;
  96968. private _pointerCaptures;
  96969. private _onKeyDown;
  96970. private _onKeyUp;
  96971. private _onCanvasFocusObserver;
  96972. private _onCanvasBlurObserver;
  96973. private _scene;
  96974. /**
  96975. * Creates a new InputManager
  96976. * @param scene defines the hosting scene
  96977. */
  96978. constructor(scene: Scene);
  96979. /**
  96980. * Gets the mesh that is currently under the pointer
  96981. */
  96982. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96983. /**
  96984. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96985. */
  96986. readonly unTranslatedPointer: Vector2;
  96987. /**
  96988. * Gets or sets the current on-screen X position of the pointer
  96989. */
  96990. pointerX: number;
  96991. /**
  96992. * Gets or sets the current on-screen Y position of the pointer
  96993. */
  96994. pointerY: number;
  96995. private _updatePointerPosition;
  96996. private _processPointerMove;
  96997. private _setRayOnPointerInfo;
  96998. private _checkPrePointerObservable;
  96999. /**
  97000. * Use this method to simulate a pointer move on a mesh
  97001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97004. */
  97005. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97006. /**
  97007. * Use this method to simulate a pointer down on a mesh
  97008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97011. */
  97012. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97013. private _processPointerDown;
  97014. /** @hidden */
  97015. _isPointerSwiping(): boolean;
  97016. /**
  97017. * Use this method to simulate a pointer up on a mesh
  97018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97021. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97022. */
  97023. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97024. private _processPointerUp;
  97025. /**
  97026. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97027. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97028. * @returns true if the pointer was captured
  97029. */
  97030. isPointerCaptured(pointerId?: number): boolean;
  97031. /**
  97032. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97033. * @param attachUp defines if you want to attach events to pointerup
  97034. * @param attachDown defines if you want to attach events to pointerdown
  97035. * @param attachMove defines if you want to attach events to pointermove
  97036. */
  97037. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97038. /**
  97039. * Detaches all event handlers
  97040. */
  97041. detachControl(): void;
  97042. /**
  97043. * Force the value of meshUnderPointer
  97044. * @param mesh defines the mesh to use
  97045. */
  97046. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97047. /**
  97048. * Gets the mesh under the pointer
  97049. * @returns a Mesh or null if no mesh is under the pointer
  97050. */
  97051. getPointerOverMesh(): Nullable<AbstractMesh>;
  97052. }
  97053. }
  97054. declare module BABYLON {
  97055. /**
  97056. * Helper class used to generate session unique ID
  97057. */
  97058. export class UniqueIdGenerator {
  97059. private static _UniqueIdCounter;
  97060. /**
  97061. * Gets an unique (relatively to the current scene) Id
  97062. */
  97063. static readonly UniqueId: number;
  97064. }
  97065. }
  97066. declare module BABYLON {
  97067. /**
  97068. * This class defines the direct association between an animation and a target
  97069. */
  97070. export class TargetedAnimation {
  97071. /**
  97072. * Animation to perform
  97073. */
  97074. animation: Animation;
  97075. /**
  97076. * Target to animate
  97077. */
  97078. target: any;
  97079. /**
  97080. * Serialize the object
  97081. * @returns the JSON object representing the current entity
  97082. */
  97083. serialize(): any;
  97084. }
  97085. /**
  97086. * Use this class to create coordinated animations on multiple targets
  97087. */
  97088. export class AnimationGroup implements IDisposable {
  97089. /** The name of the animation group */
  97090. name: string;
  97091. private _scene;
  97092. private _targetedAnimations;
  97093. private _animatables;
  97094. private _from;
  97095. private _to;
  97096. private _isStarted;
  97097. private _isPaused;
  97098. private _speedRatio;
  97099. private _loopAnimation;
  97100. /**
  97101. * Gets or sets the unique id of the node
  97102. */
  97103. uniqueId: number;
  97104. /**
  97105. * This observable will notify when one animation have ended
  97106. */
  97107. onAnimationEndObservable: Observable<TargetedAnimation>;
  97108. /**
  97109. * Observer raised when one animation loops
  97110. */
  97111. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97112. /**
  97113. * This observable will notify when all animations have ended.
  97114. */
  97115. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97116. /**
  97117. * This observable will notify when all animations have paused.
  97118. */
  97119. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  97120. /**
  97121. * This observable will notify when all animations are playing.
  97122. */
  97123. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  97124. /**
  97125. * Gets the first frame
  97126. */
  97127. readonly from: number;
  97128. /**
  97129. * Gets the last frame
  97130. */
  97131. readonly to: number;
  97132. /**
  97133. * Define if the animations are started
  97134. */
  97135. readonly isStarted: boolean;
  97136. /**
  97137. * Gets a value indicating that the current group is playing
  97138. */
  97139. readonly isPlaying: boolean;
  97140. /**
  97141. * Gets or sets the speed ratio to use for all animations
  97142. */
  97143. /**
  97144. * Gets or sets the speed ratio to use for all animations
  97145. */
  97146. speedRatio: number;
  97147. /**
  97148. * Gets or sets if all animations should loop or not
  97149. */
  97150. loopAnimation: boolean;
  97151. /**
  97152. * Gets the targeted animations for this animation group
  97153. */
  97154. readonly targetedAnimations: Array<TargetedAnimation>;
  97155. /**
  97156. * returning the list of animatables controlled by this animation group.
  97157. */
  97158. readonly animatables: Array<Animatable>;
  97159. /**
  97160. * Instantiates a new Animation Group.
  97161. * This helps managing several animations at once.
  97162. * @see http://doc.babylonjs.com/how_to/group
  97163. * @param name Defines the name of the group
  97164. * @param scene Defines the scene the group belongs to
  97165. */
  97166. constructor(
  97167. /** The name of the animation group */
  97168. name: string, scene?: Nullable<Scene>);
  97169. /**
  97170. * Add an animation (with its target) in the group
  97171. * @param animation defines the animation we want to add
  97172. * @param target defines the target of the animation
  97173. * @returns the TargetedAnimation object
  97174. */
  97175. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97176. /**
  97177. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97178. * It can add constant keys at begin or end
  97179. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97180. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97181. * @returns the animation group
  97182. */
  97183. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97184. /**
  97185. * Start all animations on given targets
  97186. * @param loop defines if animations must loop
  97187. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97188. * @param from defines the from key (optional)
  97189. * @param to defines the to key (optional)
  97190. * @returns the current animation group
  97191. */
  97192. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97193. /**
  97194. * Pause all animations
  97195. * @returns the animation group
  97196. */
  97197. pause(): AnimationGroup;
  97198. /**
  97199. * Play all animations to initial state
  97200. * This function will start() the animations if they were not started or will restart() them if they were paused
  97201. * @param loop defines if animations must loop
  97202. * @returns the animation group
  97203. */
  97204. play(loop?: boolean): AnimationGroup;
  97205. /**
  97206. * Reset all animations to initial state
  97207. * @returns the animation group
  97208. */
  97209. reset(): AnimationGroup;
  97210. /**
  97211. * Restart animations from key 0
  97212. * @returns the animation group
  97213. */
  97214. restart(): AnimationGroup;
  97215. /**
  97216. * Stop all animations
  97217. * @returns the animation group
  97218. */
  97219. stop(): AnimationGroup;
  97220. /**
  97221. * Set animation weight for all animatables
  97222. * @param weight defines the weight to use
  97223. * @return the animationGroup
  97224. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97225. */
  97226. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97227. /**
  97228. * Synchronize and normalize all animatables with a source animatable
  97229. * @param root defines the root animatable to synchronize with
  97230. * @return the animationGroup
  97231. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97232. */
  97233. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97234. /**
  97235. * Goes to a specific frame in this animation group
  97236. * @param frame the frame number to go to
  97237. * @return the animationGroup
  97238. */
  97239. goToFrame(frame: number): AnimationGroup;
  97240. /**
  97241. * Dispose all associated resources
  97242. */
  97243. dispose(): void;
  97244. private _checkAnimationGroupEnded;
  97245. /**
  97246. * Clone the current animation group and returns a copy
  97247. * @param newName defines the name of the new group
  97248. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97249. * @returns the new aniamtion group
  97250. */
  97251. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97252. /**
  97253. * Serializes the animationGroup to an object
  97254. * @returns Serialized object
  97255. */
  97256. serialize(): any;
  97257. /**
  97258. * Returns a new AnimationGroup object parsed from the source provided.
  97259. * @param parsedAnimationGroup defines the source
  97260. * @param scene defines the scene that will receive the animationGroup
  97261. * @returns a new AnimationGroup
  97262. */
  97263. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97264. /**
  97265. * Returns the string "AnimationGroup"
  97266. * @returns "AnimationGroup"
  97267. */
  97268. getClassName(): string;
  97269. /**
  97270. * Creates a detailled string about the object
  97271. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97272. * @returns a string representing the object
  97273. */
  97274. toString(fullDetails?: boolean): string;
  97275. }
  97276. }
  97277. declare module BABYLON {
  97278. /**
  97279. * Define an interface for all classes that will hold resources
  97280. */
  97281. export interface IDisposable {
  97282. /**
  97283. * Releases all held resources
  97284. */
  97285. dispose(): void;
  97286. }
  97287. /** Interface defining initialization parameters for Scene class */
  97288. export interface SceneOptions {
  97289. /**
  97290. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97291. * It will improve performance when the number of geometries becomes important.
  97292. */
  97293. useGeometryUniqueIdsMap?: boolean;
  97294. /**
  97295. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97296. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97297. */
  97298. useMaterialMeshMap?: boolean;
  97299. /**
  97300. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97301. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97302. */
  97303. useClonedMeshhMap?: boolean;
  97304. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97305. virtual?: boolean;
  97306. }
  97307. /**
  97308. * Represents a scene to be rendered by the engine.
  97309. * @see http://doc.babylonjs.com/features/scene
  97310. */
  97311. export class Scene extends AbstractScene implements IAnimatable {
  97312. /** The fog is deactivated */
  97313. static readonly FOGMODE_NONE: number;
  97314. /** The fog density is following an exponential function */
  97315. static readonly FOGMODE_EXP: number;
  97316. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97317. static readonly FOGMODE_EXP2: number;
  97318. /** The fog density is following a linear function. */
  97319. static readonly FOGMODE_LINEAR: number;
  97320. /**
  97321. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97323. */
  97324. static MinDeltaTime: number;
  97325. /**
  97326. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97328. */
  97329. static MaxDeltaTime: number;
  97330. /**
  97331. * Factory used to create the default material.
  97332. * @param name The name of the material to create
  97333. * @param scene The scene to create the material for
  97334. * @returns The default material
  97335. */
  97336. static DefaultMaterialFactory(scene: Scene): Material;
  97337. /**
  97338. * Factory used to create the a collision coordinator.
  97339. * @returns The collision coordinator
  97340. */
  97341. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97342. /** @hidden */
  97343. _inputManager: InputManager;
  97344. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97345. cameraToUseForPointers: Nullable<Camera>;
  97346. /** @hidden */
  97347. readonly _isScene: boolean;
  97348. /**
  97349. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97350. */
  97351. autoClear: boolean;
  97352. /**
  97353. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97354. */
  97355. autoClearDepthAndStencil: boolean;
  97356. /**
  97357. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97358. */
  97359. clearColor: Color4;
  97360. /**
  97361. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97362. */
  97363. ambientColor: Color3;
  97364. /**
  97365. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97366. * It should only be one of the following (if not the default embedded one):
  97367. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97368. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97369. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97370. * The material properties need to be setup according to the type of texture in use.
  97371. */
  97372. environmentBRDFTexture: BaseTexture;
  97373. /** @hidden */
  97374. protected _environmentTexture: Nullable<BaseTexture>;
  97375. /**
  97376. * Texture used in all pbr material as the reflection texture.
  97377. * As in the majority of the scene they are the same (exception for multi room and so on),
  97378. * this is easier to reference from here than from all the materials.
  97379. */
  97380. /**
  97381. * Texture used in all pbr material as the reflection texture.
  97382. * As in the majority of the scene they are the same (exception for multi room and so on),
  97383. * this is easier to set here than in all the materials.
  97384. */
  97385. environmentTexture: Nullable<BaseTexture>;
  97386. /** @hidden */
  97387. protected _environmentIntensity: number;
  97388. /**
  97389. * Intensity of the environment in all pbr material.
  97390. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97391. * As in the majority of the scene they are the same (exception for multi room and so on),
  97392. * this is easier to reference from here than from all the materials.
  97393. */
  97394. /**
  97395. * Intensity of the environment in all pbr material.
  97396. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97397. * As in the majority of the scene they are the same (exception for multi room and so on),
  97398. * this is easier to set here than in all the materials.
  97399. */
  97400. environmentIntensity: number;
  97401. /** @hidden */
  97402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97403. /**
  97404. * Default image processing configuration used either in the rendering
  97405. * Forward main pass or through the imageProcessingPostProcess if present.
  97406. * As in the majority of the scene they are the same (exception for multi camera),
  97407. * this is easier to reference from here than from all the materials and post process.
  97408. *
  97409. * No setter as we it is a shared configuration, you can set the values instead.
  97410. */
  97411. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97412. private _forceWireframe;
  97413. /**
  97414. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97415. */
  97416. forceWireframe: boolean;
  97417. private _forcePointsCloud;
  97418. /**
  97419. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97420. */
  97421. forcePointsCloud: boolean;
  97422. /**
  97423. * Gets or sets the active clipplane 1
  97424. */
  97425. clipPlane: Nullable<Plane>;
  97426. /**
  97427. * Gets or sets the active clipplane 2
  97428. */
  97429. clipPlane2: Nullable<Plane>;
  97430. /**
  97431. * Gets or sets the active clipplane 3
  97432. */
  97433. clipPlane3: Nullable<Plane>;
  97434. /**
  97435. * Gets or sets the active clipplane 4
  97436. */
  97437. clipPlane4: Nullable<Plane>;
  97438. /**
  97439. * Gets or sets a boolean indicating if animations are enabled
  97440. */
  97441. animationsEnabled: boolean;
  97442. private _animationPropertiesOverride;
  97443. /**
  97444. * Gets or sets the animation properties override
  97445. */
  97446. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97447. /**
  97448. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97449. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97450. */
  97451. useConstantAnimationDeltaTime: boolean;
  97452. /**
  97453. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97454. * Please note that it requires to run a ray cast through the scene on every frame
  97455. */
  97456. constantlyUpdateMeshUnderPointer: boolean;
  97457. /**
  97458. * Defines the HTML cursor to use when hovering over interactive elements
  97459. */
  97460. hoverCursor: string;
  97461. /**
  97462. * Defines the HTML default cursor to use (empty by default)
  97463. */
  97464. defaultCursor: string;
  97465. /**
  97466. * This is used to call preventDefault() on pointer down
  97467. * in order to block unwanted artifacts like system double clicks
  97468. */
  97469. preventDefaultOnPointerDown: boolean;
  97470. /**
  97471. * This is used to call preventDefault() on pointer up
  97472. * in order to block unwanted artifacts like system double clicks
  97473. */
  97474. preventDefaultOnPointerUp: boolean;
  97475. /**
  97476. * Gets or sets user defined metadata
  97477. */
  97478. metadata: any;
  97479. /**
  97480. * For internal use only. Please do not use.
  97481. */
  97482. reservedDataStore: any;
  97483. /**
  97484. * Gets the name of the plugin used to load this scene (null by default)
  97485. */
  97486. loadingPluginName: string;
  97487. /**
  97488. * Use this array to add regular expressions used to disable offline support for specific urls
  97489. */
  97490. disableOfflineSupportExceptionRules: RegExp[];
  97491. /**
  97492. * An event triggered when the scene is disposed.
  97493. */
  97494. onDisposeObservable: Observable<Scene>;
  97495. private _onDisposeObserver;
  97496. /** Sets a function to be executed when this scene is disposed. */
  97497. onDispose: () => void;
  97498. /**
  97499. * An event triggered before rendering the scene (right after animations and physics)
  97500. */
  97501. onBeforeRenderObservable: Observable<Scene>;
  97502. private _onBeforeRenderObserver;
  97503. /** Sets a function to be executed before rendering this scene */
  97504. beforeRender: Nullable<() => void>;
  97505. /**
  97506. * An event triggered after rendering the scene
  97507. */
  97508. onAfterRenderObservable: Observable<Scene>;
  97509. /**
  97510. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97511. */
  97512. onAfterRenderCameraObservable: Observable<Camera>;
  97513. private _onAfterRenderObserver;
  97514. /** Sets a function to be executed after rendering this scene */
  97515. afterRender: Nullable<() => void>;
  97516. /**
  97517. * An event triggered before animating the scene
  97518. */
  97519. onBeforeAnimationsObservable: Observable<Scene>;
  97520. /**
  97521. * An event triggered after animations processing
  97522. */
  97523. onAfterAnimationsObservable: Observable<Scene>;
  97524. /**
  97525. * An event triggered before draw calls are ready to be sent
  97526. */
  97527. onBeforeDrawPhaseObservable: Observable<Scene>;
  97528. /**
  97529. * An event triggered after draw calls have been sent
  97530. */
  97531. onAfterDrawPhaseObservable: Observable<Scene>;
  97532. /**
  97533. * An event triggered when the scene is ready
  97534. */
  97535. onReadyObservable: Observable<Scene>;
  97536. /**
  97537. * An event triggered before rendering a camera
  97538. */
  97539. onBeforeCameraRenderObservable: Observable<Camera>;
  97540. private _onBeforeCameraRenderObserver;
  97541. /** Sets a function to be executed before rendering a camera*/
  97542. beforeCameraRender: () => void;
  97543. /**
  97544. * An event triggered after rendering a camera
  97545. */
  97546. onAfterCameraRenderObservable: Observable<Camera>;
  97547. private _onAfterCameraRenderObserver;
  97548. /** Sets a function to be executed after rendering a camera*/
  97549. afterCameraRender: () => void;
  97550. /**
  97551. * An event triggered when active meshes evaluation is about to start
  97552. */
  97553. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97554. /**
  97555. * An event triggered when active meshes evaluation is done
  97556. */
  97557. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97558. /**
  97559. * An event triggered when particles rendering is about to start
  97560. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97561. */
  97562. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97563. /**
  97564. * An event triggered when particles rendering is done
  97565. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97566. */
  97567. onAfterParticlesRenderingObservable: Observable<Scene>;
  97568. /**
  97569. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97570. */
  97571. onDataLoadedObservable: Observable<Scene>;
  97572. /**
  97573. * An event triggered when a camera is created
  97574. */
  97575. onNewCameraAddedObservable: Observable<Camera>;
  97576. /**
  97577. * An event triggered when a camera is removed
  97578. */
  97579. onCameraRemovedObservable: Observable<Camera>;
  97580. /**
  97581. * An event triggered when a light is created
  97582. */
  97583. onNewLightAddedObservable: Observable<Light>;
  97584. /**
  97585. * An event triggered when a light is removed
  97586. */
  97587. onLightRemovedObservable: Observable<Light>;
  97588. /**
  97589. * An event triggered when a geometry is created
  97590. */
  97591. onNewGeometryAddedObservable: Observable<Geometry>;
  97592. /**
  97593. * An event triggered when a geometry is removed
  97594. */
  97595. onGeometryRemovedObservable: Observable<Geometry>;
  97596. /**
  97597. * An event triggered when a transform node is created
  97598. */
  97599. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97600. /**
  97601. * An event triggered when a transform node is removed
  97602. */
  97603. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97604. /**
  97605. * An event triggered when a mesh is created
  97606. */
  97607. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97608. /**
  97609. * An event triggered when a mesh is removed
  97610. */
  97611. onMeshRemovedObservable: Observable<AbstractMesh>;
  97612. /**
  97613. * An event triggered when a skeleton is created
  97614. */
  97615. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97616. /**
  97617. * An event triggered when a skeleton is removed
  97618. */
  97619. onSkeletonRemovedObservable: Observable<Skeleton>;
  97620. /**
  97621. * An event triggered when a material is created
  97622. */
  97623. onNewMaterialAddedObservable: Observable<Material>;
  97624. /**
  97625. * An event triggered when a material is removed
  97626. */
  97627. onMaterialRemovedObservable: Observable<Material>;
  97628. /**
  97629. * An event triggered when a texture is created
  97630. */
  97631. onNewTextureAddedObservable: Observable<BaseTexture>;
  97632. /**
  97633. * An event triggered when a texture is removed
  97634. */
  97635. onTextureRemovedObservable: Observable<BaseTexture>;
  97636. /**
  97637. * An event triggered when render targets are about to be rendered
  97638. * Can happen multiple times per frame.
  97639. */
  97640. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97641. /**
  97642. * An event triggered when render targets were rendered.
  97643. * Can happen multiple times per frame.
  97644. */
  97645. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97646. /**
  97647. * An event triggered before calculating deterministic simulation step
  97648. */
  97649. onBeforeStepObservable: Observable<Scene>;
  97650. /**
  97651. * An event triggered after calculating deterministic simulation step
  97652. */
  97653. onAfterStepObservable: Observable<Scene>;
  97654. /**
  97655. * An event triggered when the activeCamera property is updated
  97656. */
  97657. onActiveCameraChanged: Observable<Scene>;
  97658. /**
  97659. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97660. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97661. * 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)
  97662. */
  97663. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97664. /**
  97665. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97666. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97667. * 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)
  97668. */
  97669. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97670. /**
  97671. * This Observable will when a mesh has been imported into the scene.
  97672. */
  97673. onMeshImportedObservable: Observable<AbstractMesh>;
  97674. /**
  97675. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97676. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97677. */
  97678. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97679. /** @hidden */
  97680. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97681. /**
  97682. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97683. */
  97684. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97685. /**
  97686. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97687. */
  97688. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97689. /**
  97690. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97691. */
  97692. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97693. /** Callback called when a pointer move is detected */
  97694. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97695. /** Callback called when a pointer down is detected */
  97696. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97697. /** Callback called when a pointer up is detected */
  97698. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97699. /** Callback called when a pointer pick is detected */
  97700. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97701. /**
  97702. * 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).
  97703. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97704. */
  97705. onPrePointerObservable: Observable<PointerInfoPre>;
  97706. /**
  97707. * Observable event triggered each time an input event is received from the rendering canvas
  97708. */
  97709. onPointerObservable: Observable<PointerInfo>;
  97710. /**
  97711. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97712. */
  97713. readonly unTranslatedPointer: Vector2;
  97714. /**
  97715. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97716. */
  97717. static DragMovementThreshold: number;
  97718. /**
  97719. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97720. */
  97721. static LongPressDelay: number;
  97722. /**
  97723. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97724. */
  97725. static DoubleClickDelay: number;
  97726. /** If you need to check double click without raising a single click at first click, enable this flag */
  97727. static ExclusiveDoubleClickMode: boolean;
  97728. /** @hidden */
  97729. _mirroredCameraPosition: Nullable<Vector3>;
  97730. /**
  97731. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97732. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97733. */
  97734. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97735. /**
  97736. * Observable event triggered each time an keyboard event is received from the hosting window
  97737. */
  97738. onKeyboardObservable: Observable<KeyboardInfo>;
  97739. private _useRightHandedSystem;
  97740. /**
  97741. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97742. */
  97743. useRightHandedSystem: boolean;
  97744. private _timeAccumulator;
  97745. private _currentStepId;
  97746. private _currentInternalStep;
  97747. /**
  97748. * Sets the step Id used by deterministic lock step
  97749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97750. * @param newStepId defines the step Id
  97751. */
  97752. setStepId(newStepId: number): void;
  97753. /**
  97754. * Gets the step Id used by deterministic lock step
  97755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97756. * @returns the step Id
  97757. */
  97758. getStepId(): number;
  97759. /**
  97760. * Gets the internal step used by deterministic lock step
  97761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97762. * @returns the internal step
  97763. */
  97764. getInternalStep(): number;
  97765. private _fogEnabled;
  97766. /**
  97767. * Gets or sets a boolean indicating if fog is enabled on this scene
  97768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97769. * (Default is true)
  97770. */
  97771. fogEnabled: boolean;
  97772. private _fogMode;
  97773. /**
  97774. * Gets or sets the fog mode to use
  97775. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97776. * | mode | value |
  97777. * | --- | --- |
  97778. * | FOGMODE_NONE | 0 |
  97779. * | FOGMODE_EXP | 1 |
  97780. * | FOGMODE_EXP2 | 2 |
  97781. * | FOGMODE_LINEAR | 3 |
  97782. */
  97783. fogMode: number;
  97784. /**
  97785. * Gets or sets the fog color to use
  97786. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97787. * (Default is Color3(0.2, 0.2, 0.3))
  97788. */
  97789. fogColor: Color3;
  97790. /**
  97791. * Gets or sets the fog density to use
  97792. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97793. * (Default is 0.1)
  97794. */
  97795. fogDensity: number;
  97796. /**
  97797. * Gets or sets the fog start distance to use
  97798. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97799. * (Default is 0)
  97800. */
  97801. fogStart: number;
  97802. /**
  97803. * Gets or sets the fog end distance to use
  97804. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97805. * (Default is 1000)
  97806. */
  97807. fogEnd: number;
  97808. private _shadowsEnabled;
  97809. /**
  97810. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97811. */
  97812. shadowsEnabled: boolean;
  97813. private _lightsEnabled;
  97814. /**
  97815. * Gets or sets a boolean indicating if lights are enabled on this scene
  97816. */
  97817. lightsEnabled: boolean;
  97818. /** All of the active cameras added to this scene. */
  97819. activeCameras: Camera[];
  97820. /** @hidden */
  97821. _activeCamera: Nullable<Camera>;
  97822. /** Gets or sets the current active camera */
  97823. activeCamera: Nullable<Camera>;
  97824. private _defaultMaterial;
  97825. /** The default material used on meshes when no material is affected */
  97826. /** The default material used on meshes when no material is affected */
  97827. defaultMaterial: Material;
  97828. private _texturesEnabled;
  97829. /**
  97830. * Gets or sets a boolean indicating if textures are enabled on this scene
  97831. */
  97832. texturesEnabled: boolean;
  97833. /**
  97834. * Gets or sets a boolean indicating if particles are enabled on this scene
  97835. */
  97836. particlesEnabled: boolean;
  97837. /**
  97838. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97839. */
  97840. spritesEnabled: boolean;
  97841. private _skeletonsEnabled;
  97842. /**
  97843. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97844. */
  97845. skeletonsEnabled: boolean;
  97846. /**
  97847. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97848. */
  97849. lensFlaresEnabled: boolean;
  97850. /**
  97851. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97853. */
  97854. collisionsEnabled: boolean;
  97855. private _collisionCoordinator;
  97856. /** @hidden */
  97857. readonly collisionCoordinator: ICollisionCoordinator;
  97858. /**
  97859. * Defines the gravity applied to this scene (used only for collisions)
  97860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97861. */
  97862. gravity: Vector3;
  97863. /**
  97864. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97865. */
  97866. postProcessesEnabled: boolean;
  97867. /**
  97868. * The list of postprocesses added to the scene
  97869. */
  97870. postProcesses: PostProcess[];
  97871. /**
  97872. * Gets the current postprocess manager
  97873. */
  97874. postProcessManager: PostProcessManager;
  97875. /**
  97876. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97877. */
  97878. renderTargetsEnabled: boolean;
  97879. /**
  97880. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97881. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97882. */
  97883. dumpNextRenderTargets: boolean;
  97884. /**
  97885. * The list of user defined render targets added to the scene
  97886. */
  97887. customRenderTargets: RenderTargetTexture[];
  97888. /**
  97889. * Defines if texture loading must be delayed
  97890. * If true, textures will only be loaded when they need to be rendered
  97891. */
  97892. useDelayedTextureLoading: boolean;
  97893. /**
  97894. * Gets the list of meshes imported to the scene through SceneLoader
  97895. */
  97896. importedMeshesFiles: String[];
  97897. /**
  97898. * Gets or sets a boolean indicating if probes are enabled on this scene
  97899. */
  97900. probesEnabled: boolean;
  97901. /**
  97902. * Gets or sets the current offline provider to use to store scene data
  97903. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97904. */
  97905. offlineProvider: IOfflineProvider;
  97906. /**
  97907. * Gets or sets the action manager associated with the scene
  97908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97909. */
  97910. actionManager: AbstractActionManager;
  97911. private _meshesForIntersections;
  97912. /**
  97913. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97914. */
  97915. proceduralTexturesEnabled: boolean;
  97916. private _engine;
  97917. private _totalVertices;
  97918. /** @hidden */
  97919. _activeIndices: PerfCounter;
  97920. /** @hidden */
  97921. _activeParticles: PerfCounter;
  97922. /** @hidden */
  97923. _activeBones: PerfCounter;
  97924. private _animationRatio;
  97925. /** @hidden */
  97926. _animationTimeLast: number;
  97927. /** @hidden */
  97928. _animationTime: number;
  97929. /**
  97930. * Gets or sets a general scale for animation speed
  97931. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97932. */
  97933. animationTimeScale: number;
  97934. /** @hidden */
  97935. _cachedMaterial: Nullable<Material>;
  97936. /** @hidden */
  97937. _cachedEffect: Nullable<Effect>;
  97938. /** @hidden */
  97939. _cachedVisibility: Nullable<number>;
  97940. private _renderId;
  97941. private _frameId;
  97942. private _executeWhenReadyTimeoutId;
  97943. private _intermediateRendering;
  97944. private _viewUpdateFlag;
  97945. private _projectionUpdateFlag;
  97946. /** @hidden */
  97947. _toBeDisposed: Nullable<IDisposable>[];
  97948. private _activeRequests;
  97949. /** @hidden */
  97950. _pendingData: any[];
  97951. private _isDisposed;
  97952. /**
  97953. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97954. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97955. */
  97956. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97957. private _activeMeshes;
  97958. private _processedMaterials;
  97959. private _renderTargets;
  97960. /** @hidden */
  97961. _activeParticleSystems: SmartArray<IParticleSystem>;
  97962. private _activeSkeletons;
  97963. private _softwareSkinnedMeshes;
  97964. private _renderingManager;
  97965. /** @hidden */
  97966. _activeAnimatables: Animatable[];
  97967. private _transformMatrix;
  97968. private _sceneUbo;
  97969. /** @hidden */
  97970. _viewMatrix: Matrix;
  97971. private _projectionMatrix;
  97972. /** @hidden */
  97973. _forcedViewPosition: Nullable<Vector3>;
  97974. /** @hidden */
  97975. _frustumPlanes: Plane[];
  97976. /**
  97977. * Gets the list of frustum planes (built from the active camera)
  97978. */
  97979. readonly frustumPlanes: Plane[];
  97980. /**
  97981. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97982. * This is useful if there are more lights that the maximum simulteanous authorized
  97983. */
  97984. requireLightSorting: boolean;
  97985. /** @hidden */
  97986. readonly useMaterialMeshMap: boolean;
  97987. /** @hidden */
  97988. readonly useClonedMeshhMap: boolean;
  97989. private _externalData;
  97990. private _uid;
  97991. /**
  97992. * @hidden
  97993. * Backing store of defined scene components.
  97994. */
  97995. _components: ISceneComponent[];
  97996. /**
  97997. * @hidden
  97998. * Backing store of defined scene components.
  97999. */
  98000. _serializableComponents: ISceneSerializableComponent[];
  98001. /**
  98002. * List of components to register on the next registration step.
  98003. */
  98004. private _transientComponents;
  98005. /**
  98006. * Registers the transient components if needed.
  98007. */
  98008. private _registerTransientComponents;
  98009. /**
  98010. * @hidden
  98011. * Add a component to the scene.
  98012. * Note that the ccomponent could be registered on th next frame if this is called after
  98013. * the register component stage.
  98014. * @param component Defines the component to add to the scene
  98015. */
  98016. _addComponent(component: ISceneComponent): void;
  98017. /**
  98018. * @hidden
  98019. * Gets a component from the scene.
  98020. * @param name defines the name of the component to retrieve
  98021. * @returns the component or null if not present
  98022. */
  98023. _getComponent(name: string): Nullable<ISceneComponent>;
  98024. /**
  98025. * @hidden
  98026. * Defines the actions happening before camera updates.
  98027. */
  98028. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98029. /**
  98030. * @hidden
  98031. * Defines the actions happening before clear the canvas.
  98032. */
  98033. _beforeClearStage: Stage<SimpleStageAction>;
  98034. /**
  98035. * @hidden
  98036. * Defines the actions when collecting render targets for the frame.
  98037. */
  98038. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98039. /**
  98040. * @hidden
  98041. * Defines the actions happening for one camera in the frame.
  98042. */
  98043. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98044. /**
  98045. * @hidden
  98046. * Defines the actions happening during the per mesh ready checks.
  98047. */
  98048. _isReadyForMeshStage: Stage<MeshStageAction>;
  98049. /**
  98050. * @hidden
  98051. * Defines the actions happening before evaluate active mesh checks.
  98052. */
  98053. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98054. /**
  98055. * @hidden
  98056. * Defines the actions happening during the evaluate sub mesh checks.
  98057. */
  98058. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98059. /**
  98060. * @hidden
  98061. * Defines the actions happening during the active mesh stage.
  98062. */
  98063. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98064. /**
  98065. * @hidden
  98066. * Defines the actions happening during the per camera render target step.
  98067. */
  98068. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98069. /**
  98070. * @hidden
  98071. * Defines the actions happening just before the active camera is drawing.
  98072. */
  98073. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98074. /**
  98075. * @hidden
  98076. * Defines the actions happening just before a render target is drawing.
  98077. */
  98078. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98079. /**
  98080. * @hidden
  98081. * Defines the actions happening just before a rendering group is drawing.
  98082. */
  98083. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98084. /**
  98085. * @hidden
  98086. * Defines the actions happening just before a mesh is drawing.
  98087. */
  98088. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98089. /**
  98090. * @hidden
  98091. * Defines the actions happening just after a mesh has been drawn.
  98092. */
  98093. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98094. /**
  98095. * @hidden
  98096. * Defines the actions happening just after a rendering group has been drawn.
  98097. */
  98098. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98099. /**
  98100. * @hidden
  98101. * Defines the actions happening just after the active camera has been drawn.
  98102. */
  98103. _afterCameraDrawStage: Stage<CameraStageAction>;
  98104. /**
  98105. * @hidden
  98106. * Defines the actions happening just after a render target has been drawn.
  98107. */
  98108. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98109. /**
  98110. * @hidden
  98111. * Defines the actions happening just after rendering all cameras and computing intersections.
  98112. */
  98113. _afterRenderStage: Stage<SimpleStageAction>;
  98114. /**
  98115. * @hidden
  98116. * Defines the actions happening when a pointer move event happens.
  98117. */
  98118. _pointerMoveStage: Stage<PointerMoveStageAction>;
  98119. /**
  98120. * @hidden
  98121. * Defines the actions happening when a pointer down event happens.
  98122. */
  98123. _pointerDownStage: Stage<PointerUpDownStageAction>;
  98124. /**
  98125. * @hidden
  98126. * Defines the actions happening when a pointer up event happens.
  98127. */
  98128. _pointerUpStage: Stage<PointerUpDownStageAction>;
  98129. /**
  98130. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  98131. */
  98132. private geometriesByUniqueId;
  98133. /**
  98134. * Creates a new Scene
  98135. * @param engine defines the engine to use to render this scene
  98136. * @param options defines the scene options
  98137. */
  98138. constructor(engine: Engine, options?: SceneOptions);
  98139. /**
  98140. * Gets a string idenfifying the name of the class
  98141. * @returns "Scene" string
  98142. */
  98143. getClassName(): string;
  98144. private _defaultMeshCandidates;
  98145. /**
  98146. * @hidden
  98147. */
  98148. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98149. private _defaultSubMeshCandidates;
  98150. /**
  98151. * @hidden
  98152. */
  98153. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98154. /**
  98155. * Sets the default candidate providers for the scene.
  98156. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98157. * and getCollidingSubMeshCandidates to their default function
  98158. */
  98159. setDefaultCandidateProviders(): void;
  98160. /**
  98161. * Gets the mesh that is currently under the pointer
  98162. */
  98163. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98164. /**
  98165. * Gets or sets the current on-screen X position of the pointer
  98166. */
  98167. pointerX: number;
  98168. /**
  98169. * Gets or sets the current on-screen Y position of the pointer
  98170. */
  98171. pointerY: number;
  98172. /**
  98173. * Gets the cached material (ie. the latest rendered one)
  98174. * @returns the cached material
  98175. */
  98176. getCachedMaterial(): Nullable<Material>;
  98177. /**
  98178. * Gets the cached effect (ie. the latest rendered one)
  98179. * @returns the cached effect
  98180. */
  98181. getCachedEffect(): Nullable<Effect>;
  98182. /**
  98183. * Gets the cached visibility state (ie. the latest rendered one)
  98184. * @returns the cached visibility state
  98185. */
  98186. getCachedVisibility(): Nullable<number>;
  98187. /**
  98188. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98189. * @param material defines the current material
  98190. * @param effect defines the current effect
  98191. * @param visibility defines the current visibility state
  98192. * @returns true if one parameter is not cached
  98193. */
  98194. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98195. /**
  98196. * Gets the engine associated with the scene
  98197. * @returns an Engine
  98198. */
  98199. getEngine(): Engine;
  98200. /**
  98201. * Gets the total number of vertices rendered per frame
  98202. * @returns the total number of vertices rendered per frame
  98203. */
  98204. getTotalVertices(): number;
  98205. /**
  98206. * Gets the performance counter for total vertices
  98207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98208. */
  98209. readonly totalVerticesPerfCounter: PerfCounter;
  98210. /**
  98211. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98212. * @returns the total number of active indices rendered per frame
  98213. */
  98214. getActiveIndices(): number;
  98215. /**
  98216. * Gets the performance counter for active indices
  98217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98218. */
  98219. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98220. /**
  98221. * Gets the total number of active particles rendered per frame
  98222. * @returns the total number of active particles rendered per frame
  98223. */
  98224. getActiveParticles(): number;
  98225. /**
  98226. * Gets the performance counter for active particles
  98227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98228. */
  98229. readonly activeParticlesPerfCounter: PerfCounter;
  98230. /**
  98231. * Gets the total number of active bones rendered per frame
  98232. * @returns the total number of active bones rendered per frame
  98233. */
  98234. getActiveBones(): number;
  98235. /**
  98236. * Gets the performance counter for active bones
  98237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98238. */
  98239. readonly activeBonesPerfCounter: PerfCounter;
  98240. /**
  98241. * Gets the array of active meshes
  98242. * @returns an array of AbstractMesh
  98243. */
  98244. getActiveMeshes(): SmartArray<AbstractMesh>;
  98245. /**
  98246. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98247. * @returns a number
  98248. */
  98249. getAnimationRatio(): number;
  98250. /**
  98251. * Gets an unique Id for the current render phase
  98252. * @returns a number
  98253. */
  98254. getRenderId(): number;
  98255. /**
  98256. * Gets an unique Id for the current frame
  98257. * @returns a number
  98258. */
  98259. getFrameId(): number;
  98260. /** Call this function if you want to manually increment the render Id*/
  98261. incrementRenderId(): void;
  98262. private _createUbo;
  98263. /**
  98264. * Use this method to simulate a pointer move on a mesh
  98265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98268. * @returns the current scene
  98269. */
  98270. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98271. /**
  98272. * Use this method to simulate a pointer down on a mesh
  98273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98276. * @returns the current scene
  98277. */
  98278. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98279. /**
  98280. * Use this method to simulate a pointer up on a mesh
  98281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98285. * @returns the current scene
  98286. */
  98287. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98288. /**
  98289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98291. * @returns true if the pointer was captured
  98292. */
  98293. isPointerCaptured(pointerId?: number): boolean;
  98294. /**
  98295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98296. * @param attachUp defines if you want to attach events to pointerup
  98297. * @param attachDown defines if you want to attach events to pointerdown
  98298. * @param attachMove defines if you want to attach events to pointermove
  98299. */
  98300. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98301. /** Detaches all event handlers*/
  98302. detachControl(): void;
  98303. /**
  98304. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98305. * Delay loaded resources are not taking in account
  98306. * @return true if all required resources are ready
  98307. */
  98308. isReady(): boolean;
  98309. /** Resets all cached information relative to material (including effect and visibility) */
  98310. resetCachedMaterial(): void;
  98311. /**
  98312. * Registers a function to be called before every frame render
  98313. * @param func defines the function to register
  98314. */
  98315. registerBeforeRender(func: () => void): void;
  98316. /**
  98317. * Unregisters a function called before every frame render
  98318. * @param func defines the function to unregister
  98319. */
  98320. unregisterBeforeRender(func: () => void): void;
  98321. /**
  98322. * Registers a function to be called after every frame render
  98323. * @param func defines the function to register
  98324. */
  98325. registerAfterRender(func: () => void): void;
  98326. /**
  98327. * Unregisters a function called after every frame render
  98328. * @param func defines the function to unregister
  98329. */
  98330. unregisterAfterRender(func: () => void): void;
  98331. private _executeOnceBeforeRender;
  98332. /**
  98333. * The provided function will run before render once and will be disposed afterwards.
  98334. * A timeout delay can be provided so that the function will be executed in N ms.
  98335. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98336. * @param func The function to be executed.
  98337. * @param timeout optional delay in ms
  98338. */
  98339. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98340. /** @hidden */
  98341. _addPendingData(data: any): void;
  98342. /** @hidden */
  98343. _removePendingData(data: any): void;
  98344. /**
  98345. * Returns the number of items waiting to be loaded
  98346. * @returns the number of items waiting to be loaded
  98347. */
  98348. getWaitingItemsCount(): number;
  98349. /**
  98350. * Returns a boolean indicating if the scene is still loading data
  98351. */
  98352. readonly isLoading: boolean;
  98353. /**
  98354. * Registers a function to be executed when the scene is ready
  98355. * @param {Function} func - the function to be executed
  98356. */
  98357. executeWhenReady(func: () => void): void;
  98358. /**
  98359. * Returns a promise that resolves when the scene is ready
  98360. * @returns A promise that resolves when the scene is ready
  98361. */
  98362. whenReadyAsync(): Promise<void>;
  98363. /** @hidden */
  98364. _checkIsReady(): void;
  98365. /**
  98366. * Gets all animatable attached to the scene
  98367. */
  98368. readonly animatables: Animatable[];
  98369. /**
  98370. * Resets the last animation time frame.
  98371. * Useful to override when animations start running when loading a scene for the first time.
  98372. */
  98373. resetLastAnimationTimeFrame(): void;
  98374. /**
  98375. * Gets the current view matrix
  98376. * @returns a Matrix
  98377. */
  98378. getViewMatrix(): Matrix;
  98379. /**
  98380. * Gets the current projection matrix
  98381. * @returns a Matrix
  98382. */
  98383. getProjectionMatrix(): Matrix;
  98384. /**
  98385. * Gets the current transform matrix
  98386. * @returns a Matrix made of View * Projection
  98387. */
  98388. getTransformMatrix(): Matrix;
  98389. /**
  98390. * Sets the current transform matrix
  98391. * @param viewL defines the View matrix to use
  98392. * @param projectionL defines the Projection matrix to use
  98393. * @param viewR defines the right View matrix to use (if provided)
  98394. * @param projectionR defines the right Projection matrix to use (if provided)
  98395. */
  98396. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98397. /**
  98398. * Gets the uniform buffer used to store scene data
  98399. * @returns a UniformBuffer
  98400. */
  98401. getSceneUniformBuffer(): UniformBuffer;
  98402. /**
  98403. * Gets an unique (relatively to the current scene) Id
  98404. * @returns an unique number for the scene
  98405. */
  98406. getUniqueId(): number;
  98407. /**
  98408. * Add a mesh to the list of scene's meshes
  98409. * @param newMesh defines the mesh to add
  98410. * @param recursive if all child meshes should also be added to the scene
  98411. */
  98412. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98413. /**
  98414. * Remove a mesh for the list of scene's meshes
  98415. * @param toRemove defines the mesh to remove
  98416. * @param recursive if all child meshes should also be removed from the scene
  98417. * @returns the index where the mesh was in the mesh list
  98418. */
  98419. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98420. /**
  98421. * Add a transform node to the list of scene's transform nodes
  98422. * @param newTransformNode defines the transform node to add
  98423. */
  98424. addTransformNode(newTransformNode: TransformNode): void;
  98425. /**
  98426. * Remove a transform node for the list of scene's transform nodes
  98427. * @param toRemove defines the transform node to remove
  98428. * @returns the index where the transform node was in the transform node list
  98429. */
  98430. removeTransformNode(toRemove: TransformNode): number;
  98431. /**
  98432. * Remove a skeleton for the list of scene's skeletons
  98433. * @param toRemove defines the skeleton to remove
  98434. * @returns the index where the skeleton was in the skeleton list
  98435. */
  98436. removeSkeleton(toRemove: Skeleton): number;
  98437. /**
  98438. * Remove a morph target for the list of scene's morph targets
  98439. * @param toRemove defines the morph target to remove
  98440. * @returns the index where the morph target was in the morph target list
  98441. */
  98442. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98443. /**
  98444. * Remove a light for the list of scene's lights
  98445. * @param toRemove defines the light to remove
  98446. * @returns the index where the light was in the light list
  98447. */
  98448. removeLight(toRemove: Light): number;
  98449. /**
  98450. * Remove a camera for the list of scene's cameras
  98451. * @param toRemove defines the camera to remove
  98452. * @returns the index where the camera was in the camera list
  98453. */
  98454. removeCamera(toRemove: Camera): number;
  98455. /**
  98456. * Remove a particle system for the list of scene's particle systems
  98457. * @param toRemove defines the particle system to remove
  98458. * @returns the index where the particle system was in the particle system list
  98459. */
  98460. removeParticleSystem(toRemove: IParticleSystem): number;
  98461. /**
  98462. * Remove a animation for the list of scene's animations
  98463. * @param toRemove defines the animation to remove
  98464. * @returns the index where the animation was in the animation list
  98465. */
  98466. removeAnimation(toRemove: Animation): number;
  98467. /**
  98468. * Will stop the animation of the given target
  98469. * @param target - the target
  98470. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98471. * @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)
  98472. */
  98473. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98474. /**
  98475. * Removes the given animation group from this scene.
  98476. * @param toRemove The animation group to remove
  98477. * @returns The index of the removed animation group
  98478. */
  98479. removeAnimationGroup(toRemove: AnimationGroup): number;
  98480. /**
  98481. * Removes the given multi-material from this scene.
  98482. * @param toRemove The multi-material to remove
  98483. * @returns The index of the removed multi-material
  98484. */
  98485. removeMultiMaterial(toRemove: MultiMaterial): number;
  98486. /**
  98487. * Removes the given material from this scene.
  98488. * @param toRemove The material to remove
  98489. * @returns The index of the removed material
  98490. */
  98491. removeMaterial(toRemove: Material): number;
  98492. /**
  98493. * Removes the given action manager from this scene.
  98494. * @param toRemove The action manager to remove
  98495. * @returns The index of the removed action manager
  98496. */
  98497. removeActionManager(toRemove: AbstractActionManager): number;
  98498. /**
  98499. * Removes the given texture from this scene.
  98500. * @param toRemove The texture to remove
  98501. * @returns The index of the removed texture
  98502. */
  98503. removeTexture(toRemove: BaseTexture): number;
  98504. /**
  98505. * Adds the given light to this scene
  98506. * @param newLight The light to add
  98507. */
  98508. addLight(newLight: Light): void;
  98509. /**
  98510. * Sorts the list list based on light priorities
  98511. */
  98512. sortLightsByPriority(): void;
  98513. /**
  98514. * Adds the given camera to this scene
  98515. * @param newCamera The camera to add
  98516. */
  98517. addCamera(newCamera: Camera): void;
  98518. /**
  98519. * Adds the given skeleton to this scene
  98520. * @param newSkeleton The skeleton to add
  98521. */
  98522. addSkeleton(newSkeleton: Skeleton): void;
  98523. /**
  98524. * Adds the given particle system to this scene
  98525. * @param newParticleSystem The particle system to add
  98526. */
  98527. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98528. /**
  98529. * Adds the given animation to this scene
  98530. * @param newAnimation The animation to add
  98531. */
  98532. addAnimation(newAnimation: Animation): void;
  98533. /**
  98534. * Adds the given animation group to this scene.
  98535. * @param newAnimationGroup The animation group to add
  98536. */
  98537. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98538. /**
  98539. * Adds the given multi-material to this scene
  98540. * @param newMultiMaterial The multi-material to add
  98541. */
  98542. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98543. /**
  98544. * Adds the given material to this scene
  98545. * @param newMaterial The material to add
  98546. */
  98547. addMaterial(newMaterial: Material): void;
  98548. /**
  98549. * Adds the given morph target to this scene
  98550. * @param newMorphTargetManager The morph target to add
  98551. */
  98552. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98553. /**
  98554. * Adds the given geometry to this scene
  98555. * @param newGeometry The geometry to add
  98556. */
  98557. addGeometry(newGeometry: Geometry): void;
  98558. /**
  98559. * Adds the given action manager to this scene
  98560. * @param newActionManager The action manager to add
  98561. */
  98562. addActionManager(newActionManager: AbstractActionManager): void;
  98563. /**
  98564. * Adds the given texture to this scene.
  98565. * @param newTexture The texture to add
  98566. */
  98567. addTexture(newTexture: BaseTexture): void;
  98568. /**
  98569. * Switch active camera
  98570. * @param newCamera defines the new active camera
  98571. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98572. */
  98573. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98574. /**
  98575. * sets the active camera of the scene using its ID
  98576. * @param id defines the camera's ID
  98577. * @return the new active camera or null if none found.
  98578. */
  98579. setActiveCameraByID(id: string): Nullable<Camera>;
  98580. /**
  98581. * sets the active camera of the scene using its name
  98582. * @param name defines the camera's name
  98583. * @returns the new active camera or null if none found.
  98584. */
  98585. setActiveCameraByName(name: string): Nullable<Camera>;
  98586. /**
  98587. * get an animation group using its name
  98588. * @param name defines the material's name
  98589. * @return the animation group or null if none found.
  98590. */
  98591. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98592. /**
  98593. * Get a material using its unique id
  98594. * @param uniqueId defines the material's unique id
  98595. * @return the material or null if none found.
  98596. */
  98597. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98598. /**
  98599. * get a material using its id
  98600. * @param id defines the material's ID
  98601. * @return the material or null if none found.
  98602. */
  98603. getMaterialByID(id: string): Nullable<Material>;
  98604. /**
  98605. * Gets a the last added material using a given id
  98606. * @param id defines the material's ID
  98607. * @return the last material with the given id or null if none found.
  98608. */
  98609. getLastMaterialByID(id: string): Nullable<Material>;
  98610. /**
  98611. * Gets a material using its name
  98612. * @param name defines the material's name
  98613. * @return the material or null if none found.
  98614. */
  98615. getMaterialByName(name: string): Nullable<Material>;
  98616. /**
  98617. * Get a texture using its unique id
  98618. * @param uniqueId defines the texture's unique id
  98619. * @return the texture or null if none found.
  98620. */
  98621. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98622. /**
  98623. * Gets a camera using its id
  98624. * @param id defines the id to look for
  98625. * @returns the camera or null if not found
  98626. */
  98627. getCameraByID(id: string): Nullable<Camera>;
  98628. /**
  98629. * Gets a camera using its unique id
  98630. * @param uniqueId defines the unique id to look for
  98631. * @returns the camera or null if not found
  98632. */
  98633. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98634. /**
  98635. * Gets a camera using its name
  98636. * @param name defines the camera's name
  98637. * @return the camera or null if none found.
  98638. */
  98639. getCameraByName(name: string): Nullable<Camera>;
  98640. /**
  98641. * Gets a bone using its id
  98642. * @param id defines the bone's id
  98643. * @return the bone or null if not found
  98644. */
  98645. getBoneByID(id: string): Nullable<Bone>;
  98646. /**
  98647. * Gets a bone using its id
  98648. * @param name defines the bone's name
  98649. * @return the bone or null if not found
  98650. */
  98651. getBoneByName(name: string): Nullable<Bone>;
  98652. /**
  98653. * Gets a light node using its name
  98654. * @param name defines the the light's name
  98655. * @return the light or null if none found.
  98656. */
  98657. getLightByName(name: string): Nullable<Light>;
  98658. /**
  98659. * Gets a light node using its id
  98660. * @param id defines the light's id
  98661. * @return the light or null if none found.
  98662. */
  98663. getLightByID(id: string): Nullable<Light>;
  98664. /**
  98665. * Gets a light node using its scene-generated unique ID
  98666. * @param uniqueId defines the light's unique id
  98667. * @return the light or null if none found.
  98668. */
  98669. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98670. /**
  98671. * Gets a particle system by id
  98672. * @param id defines the particle system id
  98673. * @return the corresponding system or null if none found
  98674. */
  98675. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98676. /**
  98677. * Gets a geometry using its ID
  98678. * @param id defines the geometry's id
  98679. * @return the geometry or null if none found.
  98680. */
  98681. getGeometryByID(id: string): Nullable<Geometry>;
  98682. private _getGeometryByUniqueID;
  98683. /**
  98684. * Add a new geometry to this scene
  98685. * @param geometry defines the geometry to be added to the scene.
  98686. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98687. * @return a boolean defining if the geometry was added or not
  98688. */
  98689. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98690. /**
  98691. * Removes an existing geometry
  98692. * @param geometry defines the geometry to be removed from the scene
  98693. * @return a boolean defining if the geometry was removed or not
  98694. */
  98695. removeGeometry(geometry: Geometry): boolean;
  98696. /**
  98697. * Gets the list of geometries attached to the scene
  98698. * @returns an array of Geometry
  98699. */
  98700. getGeometries(): Geometry[];
  98701. /**
  98702. * Gets the first added mesh found of a given ID
  98703. * @param id defines the id to search for
  98704. * @return the mesh found or null if not found at all
  98705. */
  98706. getMeshByID(id: string): Nullable<AbstractMesh>;
  98707. /**
  98708. * Gets a list of meshes using their id
  98709. * @param id defines the id to search for
  98710. * @returns a list of meshes
  98711. */
  98712. getMeshesByID(id: string): Array<AbstractMesh>;
  98713. /**
  98714. * Gets the first added transform node found of a given ID
  98715. * @param id defines the id to search for
  98716. * @return the found transform node or null if not found at all.
  98717. */
  98718. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98719. /**
  98720. * Gets a transform node with its auto-generated unique id
  98721. * @param uniqueId efines the unique id to search for
  98722. * @return the found transform node or null if not found at all.
  98723. */
  98724. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98725. /**
  98726. * Gets a list of transform nodes using their id
  98727. * @param id defines the id to search for
  98728. * @returns a list of transform nodes
  98729. */
  98730. getTransformNodesByID(id: string): Array<TransformNode>;
  98731. /**
  98732. * Gets a mesh with its auto-generated unique id
  98733. * @param uniqueId defines the unique id to search for
  98734. * @return the found mesh or null if not found at all.
  98735. */
  98736. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98737. /**
  98738. * Gets a the last added mesh using a given id
  98739. * @param id defines the id to search for
  98740. * @return the found mesh or null if not found at all.
  98741. */
  98742. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98743. /**
  98744. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98745. * @param id defines the id to search for
  98746. * @return the found node or null if not found at all
  98747. */
  98748. getLastEntryByID(id: string): Nullable<Node>;
  98749. /**
  98750. * Gets a node (Mesh, Camera, Light) using a given id
  98751. * @param id defines the id to search for
  98752. * @return the found node or null if not found at all
  98753. */
  98754. getNodeByID(id: string): Nullable<Node>;
  98755. /**
  98756. * Gets a node (Mesh, Camera, Light) using a given name
  98757. * @param name defines the name to search for
  98758. * @return the found node or null if not found at all.
  98759. */
  98760. getNodeByName(name: string): Nullable<Node>;
  98761. /**
  98762. * Gets a mesh using a given name
  98763. * @param name defines the name to search for
  98764. * @return the found mesh or null if not found at all.
  98765. */
  98766. getMeshByName(name: string): Nullable<AbstractMesh>;
  98767. /**
  98768. * Gets a transform node using a given name
  98769. * @param name defines the name to search for
  98770. * @return the found transform node or null if not found at all.
  98771. */
  98772. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98773. /**
  98774. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98775. * @param id defines the id to search for
  98776. * @return the found skeleton or null if not found at all.
  98777. */
  98778. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98779. /**
  98780. * Gets a skeleton using a given auto generated unique id
  98781. * @param uniqueId defines the unique id to search for
  98782. * @return the found skeleton or null if not found at all.
  98783. */
  98784. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98785. /**
  98786. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98787. * @param id defines the id to search for
  98788. * @return the found skeleton or null if not found at all.
  98789. */
  98790. getSkeletonById(id: string): Nullable<Skeleton>;
  98791. /**
  98792. * Gets a skeleton using a given name
  98793. * @param name defines the name to search for
  98794. * @return the found skeleton or null if not found at all.
  98795. */
  98796. getSkeletonByName(name: string): Nullable<Skeleton>;
  98797. /**
  98798. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98799. * @param id defines the id to search for
  98800. * @return the found morph target manager or null if not found at all.
  98801. */
  98802. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98803. /**
  98804. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98805. * @param id defines the id to search for
  98806. * @return the found morph target or null if not found at all.
  98807. */
  98808. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98809. /**
  98810. * Gets a boolean indicating if the given mesh is active
  98811. * @param mesh defines the mesh to look for
  98812. * @returns true if the mesh is in the active list
  98813. */
  98814. isActiveMesh(mesh: AbstractMesh): boolean;
  98815. /**
  98816. * Return a unique id as a string which can serve as an identifier for the scene
  98817. */
  98818. readonly uid: string;
  98819. /**
  98820. * Add an externaly attached data from its key.
  98821. * This method call will fail and return false, if such key already exists.
  98822. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98823. * @param key the unique key that identifies the data
  98824. * @param data the data object to associate to the key for this Engine instance
  98825. * @return true if no such key were already present and the data was added successfully, false otherwise
  98826. */
  98827. addExternalData<T>(key: string, data: T): boolean;
  98828. /**
  98829. * Get an externaly attached data from its key
  98830. * @param key the unique key that identifies the data
  98831. * @return the associated data, if present (can be null), or undefined if not present
  98832. */
  98833. getExternalData<T>(key: string): Nullable<T>;
  98834. /**
  98835. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98836. * @param key the unique key that identifies the data
  98837. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98838. * @return the associated data, can be null if the factory returned null.
  98839. */
  98840. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98841. /**
  98842. * Remove an externaly attached data from the Engine instance
  98843. * @param key the unique key that identifies the data
  98844. * @return true if the data was successfully removed, false if it doesn't exist
  98845. */
  98846. removeExternalData(key: string): boolean;
  98847. private _evaluateSubMesh;
  98848. /**
  98849. * Clear the processed materials smart array preventing retention point in material dispose.
  98850. */
  98851. freeProcessedMaterials(): void;
  98852. private _preventFreeActiveMeshesAndRenderingGroups;
  98853. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98854. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98855. * when disposing several meshes in a row or a hierarchy of meshes.
  98856. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98857. */
  98858. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98859. /**
  98860. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98861. */
  98862. freeActiveMeshes(): void;
  98863. /**
  98864. * Clear the info related to rendering groups preventing retention points during dispose.
  98865. */
  98866. freeRenderingGroups(): void;
  98867. /** @hidden */
  98868. _isInIntermediateRendering(): boolean;
  98869. /**
  98870. * Lambda returning the list of potentially active meshes.
  98871. */
  98872. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98873. /**
  98874. * Lambda returning the list of potentially active sub meshes.
  98875. */
  98876. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98877. /**
  98878. * Lambda returning the list of potentially intersecting sub meshes.
  98879. */
  98880. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98881. /**
  98882. * Lambda returning the list of potentially colliding sub meshes.
  98883. */
  98884. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98885. private _activeMeshesFrozen;
  98886. /**
  98887. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98888. * @returns the current scene
  98889. */
  98890. freezeActiveMeshes(): Scene;
  98891. /**
  98892. * Use this function to restart evaluating active meshes on every frame
  98893. * @returns the current scene
  98894. */
  98895. unfreezeActiveMeshes(): Scene;
  98896. private _evaluateActiveMeshes;
  98897. private _activeMesh;
  98898. /**
  98899. * Update the transform matrix to update from the current active camera
  98900. * @param force defines a boolean used to force the update even if cache is up to date
  98901. */
  98902. updateTransformMatrix(force?: boolean): void;
  98903. private _bindFrameBuffer;
  98904. /** @hidden */
  98905. _allowPostProcessClearColor: boolean;
  98906. /** @hidden */
  98907. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98908. private _processSubCameras;
  98909. private _checkIntersections;
  98910. /** @hidden */
  98911. _advancePhysicsEngineStep(step: number): void;
  98912. /**
  98913. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98914. */
  98915. getDeterministicFrameTime: () => number;
  98916. /** @hidden */
  98917. _animate(): void;
  98918. /** Execute all animations (for a frame) */
  98919. animate(): void;
  98920. /**
  98921. * Render the scene
  98922. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98923. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98924. */
  98925. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98926. /**
  98927. * Freeze all materials
  98928. * A frozen material will not be updatable but should be faster to render
  98929. */
  98930. freezeMaterials(): void;
  98931. /**
  98932. * Unfreeze all materials
  98933. * A frozen material will not be updatable but should be faster to render
  98934. */
  98935. unfreezeMaterials(): void;
  98936. /**
  98937. * Releases all held ressources
  98938. */
  98939. dispose(): void;
  98940. /**
  98941. * Gets if the scene is already disposed
  98942. */
  98943. readonly isDisposed: boolean;
  98944. /**
  98945. * Call this function to reduce memory footprint of the scene.
  98946. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98947. */
  98948. clearCachedVertexData(): void;
  98949. /**
  98950. * This function will remove the local cached buffer data from texture.
  98951. * It will save memory but will prevent the texture from being rebuilt
  98952. */
  98953. cleanCachedTextureBuffer(): void;
  98954. /**
  98955. * Get the world extend vectors with an optional filter
  98956. *
  98957. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98958. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98959. */
  98960. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98961. min: Vector3;
  98962. max: Vector3;
  98963. };
  98964. /**
  98965. * Creates a ray that can be used to pick in the scene
  98966. * @param x defines the x coordinate of the origin (on-screen)
  98967. * @param y defines the y coordinate of the origin (on-screen)
  98968. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98969. * @param camera defines the camera to use for the picking
  98970. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98971. * @returns a Ray
  98972. */
  98973. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98974. /**
  98975. * Creates a ray that can be used to pick in the scene
  98976. * @param x defines the x coordinate of the origin (on-screen)
  98977. * @param y defines the y coordinate of the origin (on-screen)
  98978. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98979. * @param result defines the ray where to store the picking ray
  98980. * @param camera defines the camera to use for the picking
  98981. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98982. * @returns the current scene
  98983. */
  98984. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98985. /**
  98986. * Creates a ray that can be used to pick in the scene
  98987. * @param x defines the x coordinate of the origin (on-screen)
  98988. * @param y defines the y coordinate of the origin (on-screen)
  98989. * @param camera defines the camera to use for the picking
  98990. * @returns a Ray
  98991. */
  98992. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98993. /**
  98994. * Creates a ray that can be used to pick in the scene
  98995. * @param x defines the x coordinate of the origin (on-screen)
  98996. * @param y defines the y coordinate of the origin (on-screen)
  98997. * @param result defines the ray where to store the picking ray
  98998. * @param camera defines the camera to use for the picking
  98999. * @returns the current scene
  99000. */
  99001. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99002. /** Launch a ray to try to pick a mesh in the scene
  99003. * @param x position on screen
  99004. * @param y position on screen
  99005. * @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
  99006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99007. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99009. * @returns a PickingInfo
  99010. */
  99011. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99012. /** Use the given ray to pick a mesh in the scene
  99013. * @param ray The ray to use to pick meshes
  99014. * @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
  99015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99016. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99017. * @returns a PickingInfo
  99018. */
  99019. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99020. /**
  99021. * Launch a ray to try to pick a mesh in the scene
  99022. * @param x X position on screen
  99023. * @param y Y position on screen
  99024. * @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
  99025. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99026. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99027. * @returns an array of PickingInfo
  99028. */
  99029. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99030. /**
  99031. * Launch a ray to try to pick a mesh in the scene
  99032. * @param ray Ray to use
  99033. * @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
  99034. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99035. * @returns an array of PickingInfo
  99036. */
  99037. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99038. /**
  99039. * Force the value of meshUnderPointer
  99040. * @param mesh defines the mesh to use
  99041. */
  99042. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99043. /**
  99044. * Gets the mesh under the pointer
  99045. * @returns a Mesh or null if no mesh is under the pointer
  99046. */
  99047. getPointerOverMesh(): Nullable<AbstractMesh>;
  99048. /** @hidden */
  99049. _rebuildGeometries(): void;
  99050. /** @hidden */
  99051. _rebuildTextures(): void;
  99052. private _getByTags;
  99053. /**
  99054. * Get a list of meshes by tags
  99055. * @param tagsQuery defines the tags query to use
  99056. * @param forEach defines a predicate used to filter results
  99057. * @returns an array of Mesh
  99058. */
  99059. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99060. /**
  99061. * Get a list of cameras by tags
  99062. * @param tagsQuery defines the tags query to use
  99063. * @param forEach defines a predicate used to filter results
  99064. * @returns an array of Camera
  99065. */
  99066. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99067. /**
  99068. * Get a list of lights by tags
  99069. * @param tagsQuery defines the tags query to use
  99070. * @param forEach defines a predicate used to filter results
  99071. * @returns an array of Light
  99072. */
  99073. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99074. /**
  99075. * Get a list of materials by tags
  99076. * @param tagsQuery defines the tags query to use
  99077. * @param forEach defines a predicate used to filter results
  99078. * @returns an array of Material
  99079. */
  99080. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99081. /**
  99082. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99083. * This allowed control for front to back rendering or reversly depending of the special needs.
  99084. *
  99085. * @param renderingGroupId The rendering group id corresponding to its index
  99086. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99087. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99088. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99089. */
  99090. 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;
  99091. /**
  99092. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99093. *
  99094. * @param renderingGroupId The rendering group id corresponding to its index
  99095. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99096. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99097. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99098. */
  99099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99100. /**
  99101. * Gets the current auto clear configuration for one rendering group of the rendering
  99102. * manager.
  99103. * @param index the rendering group index to get the information for
  99104. * @returns The auto clear setup for the requested rendering group
  99105. */
  99106. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99107. private _blockMaterialDirtyMechanism;
  99108. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99109. blockMaterialDirtyMechanism: boolean;
  99110. /**
  99111. * Will flag all materials as dirty to trigger new shader compilation
  99112. * @param flag defines the flag used to specify which material part must be marked as dirty
  99113. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99114. */
  99115. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99116. /** @hidden */
  99117. _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;
  99118. /** @hidden */
  99119. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99120. }
  99121. }
  99122. declare module BABYLON {
  99123. /**
  99124. * Set of assets to keep when moving a scene into an asset container.
  99125. */
  99126. export class KeepAssets extends AbstractScene {
  99127. }
  99128. /**
  99129. * Container with a set of assets that can be added or removed from a scene.
  99130. */
  99131. export class AssetContainer extends AbstractScene {
  99132. /**
  99133. * The scene the AssetContainer belongs to.
  99134. */
  99135. scene: Scene;
  99136. /**
  99137. * Instantiates an AssetContainer.
  99138. * @param scene The scene the AssetContainer belongs to.
  99139. */
  99140. constructor(scene: Scene);
  99141. /**
  99142. * Adds all the assets from the container to the scene.
  99143. */
  99144. addAllToScene(): void;
  99145. /**
  99146. * Removes all the assets in the container from the scene
  99147. */
  99148. removeAllFromScene(): void;
  99149. /**
  99150. * Disposes all the assets in the container
  99151. */
  99152. dispose(): void;
  99153. private _moveAssets;
  99154. /**
  99155. * Removes all the assets contained in the scene and adds them to the container.
  99156. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99157. */
  99158. moveAllFromScene(keepAssets?: KeepAssets): void;
  99159. /**
  99160. * 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.
  99161. * @returns the root mesh
  99162. */
  99163. createRootMesh(): Mesh;
  99164. }
  99165. }
  99166. declare module BABYLON {
  99167. /**
  99168. * Defines how the parser contract is defined.
  99169. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99170. */
  99171. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99172. /**
  99173. * Defines how the individual parser contract is defined.
  99174. * These parser can parse an individual asset
  99175. */
  99176. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99177. /**
  99178. * Base class of the scene acting as a container for the different elements composing a scene.
  99179. * This class is dynamically extended by the different components of the scene increasing
  99180. * flexibility and reducing coupling
  99181. */
  99182. export abstract class AbstractScene {
  99183. /**
  99184. * Stores the list of available parsers in the application.
  99185. */
  99186. private static _BabylonFileParsers;
  99187. /**
  99188. * Stores the list of available individual parsers in the application.
  99189. */
  99190. private static _IndividualBabylonFileParsers;
  99191. /**
  99192. * Adds a parser in the list of available ones
  99193. * @param name Defines the name of the parser
  99194. * @param parser Defines the parser to add
  99195. */
  99196. static AddParser(name: string, parser: BabylonFileParser): void;
  99197. /**
  99198. * Gets a general parser from the list of avaialble ones
  99199. * @param name Defines the name of the parser
  99200. * @returns the requested parser or null
  99201. */
  99202. static GetParser(name: string): Nullable<BabylonFileParser>;
  99203. /**
  99204. * Adds n individual parser in the list of available ones
  99205. * @param name Defines the name of the parser
  99206. * @param parser Defines the parser to add
  99207. */
  99208. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99209. /**
  99210. * Gets an individual parser from the list of avaialble ones
  99211. * @param name Defines the name of the parser
  99212. * @returns the requested parser or null
  99213. */
  99214. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99215. /**
  99216. * Parser json data and populate both a scene and its associated container object
  99217. * @param jsonData Defines the data to parse
  99218. * @param scene Defines the scene to parse the data for
  99219. * @param container Defines the container attached to the parsing sequence
  99220. * @param rootUrl Defines the root url of the data
  99221. */
  99222. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99223. /**
  99224. * Gets the list of root nodes (ie. nodes with no parent)
  99225. */
  99226. rootNodes: Node[];
  99227. /** All of the cameras added to this scene
  99228. * @see http://doc.babylonjs.com/babylon101/cameras
  99229. */
  99230. cameras: Camera[];
  99231. /**
  99232. * All of the lights added to this scene
  99233. * @see http://doc.babylonjs.com/babylon101/lights
  99234. */
  99235. lights: Light[];
  99236. /**
  99237. * All of the (abstract) meshes added to this scene
  99238. */
  99239. meshes: AbstractMesh[];
  99240. /**
  99241. * The list of skeletons added to the scene
  99242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99243. */
  99244. skeletons: Skeleton[];
  99245. /**
  99246. * All of the particle systems added to this scene
  99247. * @see http://doc.babylonjs.com/babylon101/particles
  99248. */
  99249. particleSystems: IParticleSystem[];
  99250. /**
  99251. * Gets a list of Animations associated with the scene
  99252. */
  99253. animations: Animation[];
  99254. /**
  99255. * All of the animation groups added to this scene
  99256. * @see http://doc.babylonjs.com/how_to/group
  99257. */
  99258. animationGroups: AnimationGroup[];
  99259. /**
  99260. * All of the multi-materials added to this scene
  99261. * @see http://doc.babylonjs.com/how_to/multi_materials
  99262. */
  99263. multiMaterials: MultiMaterial[];
  99264. /**
  99265. * All of the materials added to this scene
  99266. * In the context of a Scene, it is not supposed to be modified manually.
  99267. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99268. * Note also that the order of the Material wihin the array is not significant and might change.
  99269. * @see http://doc.babylonjs.com/babylon101/materials
  99270. */
  99271. materials: Material[];
  99272. /**
  99273. * The list of morph target managers added to the scene
  99274. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99275. */
  99276. morphTargetManagers: MorphTargetManager[];
  99277. /**
  99278. * The list of geometries used in the scene.
  99279. */
  99280. geometries: Geometry[];
  99281. /**
  99282. * All of the tranform nodes added to this scene
  99283. * In the context of a Scene, it is not supposed to be modified manually.
  99284. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99285. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99286. * @see http://doc.babylonjs.com/how_to/transformnode
  99287. */
  99288. transformNodes: TransformNode[];
  99289. /**
  99290. * ActionManagers available on the scene.
  99291. */
  99292. actionManagers: AbstractActionManager[];
  99293. /**
  99294. * Textures to keep.
  99295. */
  99296. textures: BaseTexture[];
  99297. /**
  99298. * Environment texture for the scene
  99299. */
  99300. environmentTexture: Nullable<BaseTexture>;
  99301. }
  99302. }
  99303. declare module BABYLON {
  99304. /**
  99305. * Interface used to define options for Sound class
  99306. */
  99307. export interface ISoundOptions {
  99308. /**
  99309. * Does the sound autoplay once loaded.
  99310. */
  99311. autoplay?: boolean;
  99312. /**
  99313. * Does the sound loop after it finishes playing once.
  99314. */
  99315. loop?: boolean;
  99316. /**
  99317. * Sound's volume
  99318. */
  99319. volume?: number;
  99320. /**
  99321. * Is it a spatial sound?
  99322. */
  99323. spatialSound?: boolean;
  99324. /**
  99325. * Maximum distance to hear that sound
  99326. */
  99327. maxDistance?: number;
  99328. /**
  99329. * Uses user defined attenuation function
  99330. */
  99331. useCustomAttenuation?: boolean;
  99332. /**
  99333. * Define the roll off factor of spatial sounds.
  99334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99335. */
  99336. rolloffFactor?: number;
  99337. /**
  99338. * Define the reference distance the sound should be heard perfectly.
  99339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99340. */
  99341. refDistance?: number;
  99342. /**
  99343. * Define the distance attenuation model the sound will follow.
  99344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99345. */
  99346. distanceModel?: string;
  99347. /**
  99348. * Defines the playback speed (1 by default)
  99349. */
  99350. playbackRate?: number;
  99351. /**
  99352. * Defines if the sound is from a streaming source
  99353. */
  99354. streaming?: boolean;
  99355. /**
  99356. * Defines an optional length (in seconds) inside the sound file
  99357. */
  99358. length?: number;
  99359. /**
  99360. * Defines an optional offset (in seconds) inside the sound file
  99361. */
  99362. offset?: number;
  99363. /**
  99364. * If true, URLs will not be required to state the audio file codec to use.
  99365. */
  99366. skipCodecCheck?: boolean;
  99367. }
  99368. /**
  99369. * Defines a sound that can be played in the application.
  99370. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99372. */
  99373. export class Sound {
  99374. /**
  99375. * The name of the sound in the scene.
  99376. */
  99377. name: string;
  99378. /**
  99379. * Does the sound autoplay once loaded.
  99380. */
  99381. autoplay: boolean;
  99382. /**
  99383. * Does the sound loop after it finishes playing once.
  99384. */
  99385. loop: boolean;
  99386. /**
  99387. * Does the sound use a custom attenuation curve to simulate the falloff
  99388. * happening when the source gets further away from the camera.
  99389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99390. */
  99391. useCustomAttenuation: boolean;
  99392. /**
  99393. * The sound track id this sound belongs to.
  99394. */
  99395. soundTrackId: number;
  99396. /**
  99397. * Is this sound currently played.
  99398. */
  99399. isPlaying: boolean;
  99400. /**
  99401. * Is this sound currently paused.
  99402. */
  99403. isPaused: boolean;
  99404. /**
  99405. * Does this sound enables spatial sound.
  99406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99407. */
  99408. spatialSound: boolean;
  99409. /**
  99410. * Define the reference distance the sound should be heard perfectly.
  99411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99412. */
  99413. refDistance: number;
  99414. /**
  99415. * Define the roll off factor of spatial sounds.
  99416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99417. */
  99418. rolloffFactor: number;
  99419. /**
  99420. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99422. */
  99423. maxDistance: number;
  99424. /**
  99425. * Define the distance attenuation model the sound will follow.
  99426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99427. */
  99428. distanceModel: string;
  99429. /**
  99430. * @hidden
  99431. * Back Compat
  99432. **/
  99433. onended: () => any;
  99434. /**
  99435. * Observable event when the current playing sound finishes.
  99436. */
  99437. onEndedObservable: Observable<Sound>;
  99438. private _panningModel;
  99439. private _playbackRate;
  99440. private _streaming;
  99441. private _startTime;
  99442. private _startOffset;
  99443. private _position;
  99444. /** @hidden */
  99445. _positionInEmitterSpace: boolean;
  99446. private _localDirection;
  99447. private _volume;
  99448. private _isReadyToPlay;
  99449. private _isDirectional;
  99450. private _readyToPlayCallback;
  99451. private _audioBuffer;
  99452. private _soundSource;
  99453. private _streamingSource;
  99454. private _soundPanner;
  99455. private _soundGain;
  99456. private _inputAudioNode;
  99457. private _outputAudioNode;
  99458. private _coneInnerAngle;
  99459. private _coneOuterAngle;
  99460. private _coneOuterGain;
  99461. private _scene;
  99462. private _connectedTransformNode;
  99463. private _customAttenuationFunction;
  99464. private _registerFunc;
  99465. private _isOutputConnected;
  99466. private _htmlAudioElement;
  99467. private _urlType;
  99468. private _length?;
  99469. private _offset?;
  99470. /** @hidden */
  99471. static _SceneComponentInitialization: (scene: Scene) => void;
  99472. /**
  99473. * Create a sound and attach it to a scene
  99474. * @param name Name of your sound
  99475. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99476. * @param scene defines the scene the sound belongs to
  99477. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99478. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99479. */
  99480. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99481. /**
  99482. * Release the sound and its associated resources
  99483. */
  99484. dispose(): void;
  99485. /**
  99486. * Gets if the sounds is ready to be played or not.
  99487. * @returns true if ready, otherwise false
  99488. */
  99489. isReady(): boolean;
  99490. private _soundLoaded;
  99491. /**
  99492. * Sets the data of the sound from an audiobuffer
  99493. * @param audioBuffer The audioBuffer containing the data
  99494. */
  99495. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99496. /**
  99497. * Updates the current sounds options such as maxdistance, loop...
  99498. * @param options A JSON object containing values named as the object properties
  99499. */
  99500. updateOptions(options: ISoundOptions): void;
  99501. private _createSpatialParameters;
  99502. private _updateSpatialParameters;
  99503. /**
  99504. * Switch the panning model to HRTF:
  99505. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99507. */
  99508. switchPanningModelToHRTF(): void;
  99509. /**
  99510. * Switch the panning model to Equal Power:
  99511. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99513. */
  99514. switchPanningModelToEqualPower(): void;
  99515. private _switchPanningModel;
  99516. /**
  99517. * Connect this sound to a sound track audio node like gain...
  99518. * @param soundTrackAudioNode the sound track audio node to connect to
  99519. */
  99520. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99521. /**
  99522. * Transform this sound into a directional source
  99523. * @param coneInnerAngle Size of the inner cone in degree
  99524. * @param coneOuterAngle Size of the outer cone in degree
  99525. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99526. */
  99527. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99528. /**
  99529. * Gets or sets the inner angle for the directional cone.
  99530. */
  99531. /**
  99532. * Gets or sets the inner angle for the directional cone.
  99533. */
  99534. directionalConeInnerAngle: number;
  99535. /**
  99536. * Gets or sets the outer angle for the directional cone.
  99537. */
  99538. /**
  99539. * Gets or sets the outer angle for the directional cone.
  99540. */
  99541. directionalConeOuterAngle: number;
  99542. /**
  99543. * Sets the position of the emitter if spatial sound is enabled
  99544. * @param newPosition Defines the new posisiton
  99545. */
  99546. setPosition(newPosition: Vector3): void;
  99547. /**
  99548. * Sets the local direction of the emitter if spatial sound is enabled
  99549. * @param newLocalDirection Defines the new local direction
  99550. */
  99551. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99552. private _updateDirection;
  99553. /** @hidden */
  99554. updateDistanceFromListener(): void;
  99555. /**
  99556. * Sets a new custom attenuation function for the sound.
  99557. * @param callback Defines the function used for the attenuation
  99558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99559. */
  99560. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99561. /**
  99562. * Play the sound
  99563. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99564. * @param offset (optional) Start the sound at a specific time in seconds
  99565. * @param length (optional) Sound duration (in seconds)
  99566. */
  99567. play(time?: number, offset?: number, length?: number): void;
  99568. private _onended;
  99569. /**
  99570. * Stop the sound
  99571. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99572. */
  99573. stop(time?: number): void;
  99574. /**
  99575. * Put the sound in pause
  99576. */
  99577. pause(): void;
  99578. /**
  99579. * Sets a dedicated volume for this sounds
  99580. * @param newVolume Define the new volume of the sound
  99581. * @param time Define time for gradual change to new volume
  99582. */
  99583. setVolume(newVolume: number, time?: number): void;
  99584. /**
  99585. * Set the sound play back rate
  99586. * @param newPlaybackRate Define the playback rate the sound should be played at
  99587. */
  99588. setPlaybackRate(newPlaybackRate: number): void;
  99589. /**
  99590. * Gets the volume of the sound.
  99591. * @returns the volume of the sound
  99592. */
  99593. getVolume(): number;
  99594. /**
  99595. * Attach the sound to a dedicated mesh
  99596. * @param transformNode The transform node to connect the sound with
  99597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99598. */
  99599. attachToMesh(transformNode: TransformNode): void;
  99600. /**
  99601. * Detach the sound from the previously attached mesh
  99602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99603. */
  99604. detachFromMesh(): void;
  99605. private _onRegisterAfterWorldMatrixUpdate;
  99606. /**
  99607. * Clone the current sound in the scene.
  99608. * @returns the new sound clone
  99609. */
  99610. clone(): Nullable<Sound>;
  99611. /**
  99612. * Gets the current underlying audio buffer containing the data
  99613. * @returns the audio buffer
  99614. */
  99615. getAudioBuffer(): Nullable<AudioBuffer>;
  99616. /**
  99617. * Serializes the Sound in a JSON representation
  99618. * @returns the JSON representation of the sound
  99619. */
  99620. serialize(): any;
  99621. /**
  99622. * Parse a JSON representation of a sound to innstantiate in a given scene
  99623. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99624. * @param scene Define the scene the new parsed sound should be created in
  99625. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99626. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99627. * @returns the newly parsed sound
  99628. */
  99629. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99630. }
  99631. }
  99632. declare module BABYLON {
  99633. /**
  99634. * This defines an action helpful to play a defined sound on a triggered action.
  99635. */
  99636. export class PlaySoundAction extends Action {
  99637. private _sound;
  99638. /**
  99639. * Instantiate the action
  99640. * @param triggerOptions defines the trigger options
  99641. * @param sound defines the sound to play
  99642. * @param condition defines the trigger related conditions
  99643. */
  99644. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99645. /** @hidden */
  99646. _prepare(): void;
  99647. /**
  99648. * Execute the action and play the sound.
  99649. */
  99650. execute(): void;
  99651. /**
  99652. * Serializes the actions and its related information.
  99653. * @param parent defines the object to serialize in
  99654. * @returns the serialized object
  99655. */
  99656. serialize(parent: any): any;
  99657. }
  99658. /**
  99659. * This defines an action helpful to stop a defined sound on a triggered action.
  99660. */
  99661. export class StopSoundAction extends Action {
  99662. private _sound;
  99663. /**
  99664. * Instantiate the action
  99665. * @param triggerOptions defines the trigger options
  99666. * @param sound defines the sound to stop
  99667. * @param condition defines the trigger related conditions
  99668. */
  99669. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99670. /** @hidden */
  99671. _prepare(): void;
  99672. /**
  99673. * Execute the action and stop the sound.
  99674. */
  99675. execute(): void;
  99676. /**
  99677. * Serializes the actions and its related information.
  99678. * @param parent defines the object to serialize in
  99679. * @returns the serialized object
  99680. */
  99681. serialize(parent: any): any;
  99682. }
  99683. }
  99684. declare module BABYLON {
  99685. /**
  99686. * This defines an action responsible to change the value of a property
  99687. * by interpolating between its current value and the newly set one once triggered.
  99688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99689. */
  99690. export class InterpolateValueAction extends Action {
  99691. /**
  99692. * Defines the path of the property where the value should be interpolated
  99693. */
  99694. propertyPath: string;
  99695. /**
  99696. * Defines the target value at the end of the interpolation.
  99697. */
  99698. value: any;
  99699. /**
  99700. * Defines the time it will take for the property to interpolate to the value.
  99701. */
  99702. duration: number;
  99703. /**
  99704. * Defines if the other scene animations should be stopped when the action has been triggered
  99705. */
  99706. stopOtherAnimations?: boolean;
  99707. /**
  99708. * Defines a callback raised once the interpolation animation has been done.
  99709. */
  99710. onInterpolationDone?: () => void;
  99711. /**
  99712. * Observable triggered once the interpolation animation has been done.
  99713. */
  99714. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99715. private _target;
  99716. private _effectiveTarget;
  99717. private _property;
  99718. /**
  99719. * Instantiate the action
  99720. * @param triggerOptions defines the trigger options
  99721. * @param target defines the object containing the value to interpolate
  99722. * @param propertyPath defines the path to the property in the target object
  99723. * @param value defines the target value at the end of the interpolation
  99724. * @param duration deines the time it will take for the property to interpolate to the value.
  99725. * @param condition defines the trigger related conditions
  99726. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99727. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99728. */
  99729. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99730. /** @hidden */
  99731. _prepare(): void;
  99732. /**
  99733. * Execute the action starts the value interpolation.
  99734. */
  99735. execute(): void;
  99736. /**
  99737. * Serializes the actions and its related information.
  99738. * @param parent defines the object to serialize in
  99739. * @returns the serialized object
  99740. */
  99741. serialize(parent: any): any;
  99742. }
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * Options allowed during the creation of a sound track.
  99747. */
  99748. export interface ISoundTrackOptions {
  99749. /**
  99750. * The volume the sound track should take during creation
  99751. */
  99752. volume?: number;
  99753. /**
  99754. * Define if the sound track is the main sound track of the scene
  99755. */
  99756. mainTrack?: boolean;
  99757. }
  99758. /**
  99759. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99760. * It will be also used in a future release to apply effects on a specific track.
  99761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99762. */
  99763. export class SoundTrack {
  99764. /**
  99765. * The unique identifier of the sound track in the scene.
  99766. */
  99767. id: number;
  99768. /**
  99769. * The list of sounds included in the sound track.
  99770. */
  99771. soundCollection: Array<Sound>;
  99772. private _outputAudioNode;
  99773. private _scene;
  99774. private _isMainTrack;
  99775. private _connectedAnalyser;
  99776. private _options;
  99777. private _isInitialized;
  99778. /**
  99779. * Creates a new sound track.
  99780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99781. * @param scene Define the scene the sound track belongs to
  99782. * @param options
  99783. */
  99784. constructor(scene: Scene, options?: ISoundTrackOptions);
  99785. private _initializeSoundTrackAudioGraph;
  99786. /**
  99787. * Release the sound track and its associated resources
  99788. */
  99789. dispose(): void;
  99790. /**
  99791. * Adds a sound to this sound track
  99792. * @param sound define the cound to add
  99793. * @ignoreNaming
  99794. */
  99795. AddSound(sound: Sound): void;
  99796. /**
  99797. * Removes a sound to this sound track
  99798. * @param sound define the cound to remove
  99799. * @ignoreNaming
  99800. */
  99801. RemoveSound(sound: Sound): void;
  99802. /**
  99803. * Set a global volume for the full sound track.
  99804. * @param newVolume Define the new volume of the sound track
  99805. */
  99806. setVolume(newVolume: number): void;
  99807. /**
  99808. * Switch the panning model to HRTF:
  99809. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99811. */
  99812. switchPanningModelToHRTF(): void;
  99813. /**
  99814. * Switch the panning model to Equal Power:
  99815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99817. */
  99818. switchPanningModelToEqualPower(): void;
  99819. /**
  99820. * Connect the sound track to an audio analyser allowing some amazing
  99821. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99823. * @param analyser The analyser to connect to the engine
  99824. */
  99825. connectToAnalyser(analyser: Analyser): void;
  99826. }
  99827. }
  99828. declare module BABYLON {
  99829. interface AbstractScene {
  99830. /**
  99831. * The list of sounds used in the scene.
  99832. */
  99833. sounds: Nullable<Array<Sound>>;
  99834. }
  99835. interface Scene {
  99836. /**
  99837. * @hidden
  99838. * Backing field
  99839. */
  99840. _mainSoundTrack: SoundTrack;
  99841. /**
  99842. * The main sound track played by the scene.
  99843. * It cotains your primary collection of sounds.
  99844. */
  99845. mainSoundTrack: SoundTrack;
  99846. /**
  99847. * The list of sound tracks added to the scene
  99848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99849. */
  99850. soundTracks: Nullable<Array<SoundTrack>>;
  99851. /**
  99852. * Gets a sound using a given name
  99853. * @param name defines the name to search for
  99854. * @return the found sound or null if not found at all.
  99855. */
  99856. getSoundByName(name: string): Nullable<Sound>;
  99857. /**
  99858. * Gets or sets if audio support is enabled
  99859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99860. */
  99861. audioEnabled: boolean;
  99862. /**
  99863. * Gets or sets if audio will be output to headphones
  99864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99865. */
  99866. headphone: boolean;
  99867. /**
  99868. * Gets or sets custom audio listener position provider
  99869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99870. */
  99871. audioListenerPositionProvider: Nullable<() => Vector3>;
  99872. }
  99873. /**
  99874. * Defines the sound scene component responsible to manage any sounds
  99875. * in a given scene.
  99876. */
  99877. export class AudioSceneComponent implements ISceneSerializableComponent {
  99878. /**
  99879. * The component name helpfull to identify the component in the list of scene components.
  99880. */
  99881. readonly name: string;
  99882. /**
  99883. * The scene the component belongs to.
  99884. */
  99885. scene: Scene;
  99886. private _audioEnabled;
  99887. /**
  99888. * Gets whether audio is enabled or not.
  99889. * Please use related enable/disable method to switch state.
  99890. */
  99891. readonly audioEnabled: boolean;
  99892. private _headphone;
  99893. /**
  99894. * Gets whether audio is outputing to headphone or not.
  99895. * Please use the according Switch methods to change output.
  99896. */
  99897. readonly headphone: boolean;
  99898. private _audioListenerPositionProvider;
  99899. /**
  99900. * Gets the current audio listener position provider
  99901. */
  99902. /**
  99903. * Sets a custom listener position for all sounds in the scene
  99904. * By default, this is the position of the first active camera
  99905. */
  99906. audioListenerPositionProvider: Nullable<() => Vector3>;
  99907. /**
  99908. * Creates a new instance of the component for the given scene
  99909. * @param scene Defines the scene to register the component in
  99910. */
  99911. constructor(scene: Scene);
  99912. /**
  99913. * Registers the component in a given scene
  99914. */
  99915. register(): void;
  99916. /**
  99917. * Rebuilds the elements related to this component in case of
  99918. * context lost for instance.
  99919. */
  99920. rebuild(): void;
  99921. /**
  99922. * Serializes the component data to the specified json object
  99923. * @param serializationObject The object to serialize to
  99924. */
  99925. serialize(serializationObject: any): void;
  99926. /**
  99927. * Adds all the elements from the container to the scene
  99928. * @param container the container holding the elements
  99929. */
  99930. addFromContainer(container: AbstractScene): void;
  99931. /**
  99932. * Removes all the elements in the container from the scene
  99933. * @param container contains the elements to remove
  99934. * @param dispose if the removed element should be disposed (default: false)
  99935. */
  99936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99937. /**
  99938. * Disposes the component and the associated ressources.
  99939. */
  99940. dispose(): void;
  99941. /**
  99942. * Disables audio in the associated scene.
  99943. */
  99944. disableAudio(): void;
  99945. /**
  99946. * Enables audio in the associated scene.
  99947. */
  99948. enableAudio(): void;
  99949. /**
  99950. * Switch audio to headphone output.
  99951. */
  99952. switchAudioModeForHeadphones(): void;
  99953. /**
  99954. * Switch audio to normal speakers.
  99955. */
  99956. switchAudioModeForNormalSpeakers(): void;
  99957. private _afterRender;
  99958. }
  99959. }
  99960. declare module BABYLON {
  99961. /**
  99962. * Wraps one or more Sound objects and selects one with random weight for playback.
  99963. */
  99964. export class WeightedSound {
  99965. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99966. loop: boolean;
  99967. private _coneInnerAngle;
  99968. private _coneOuterAngle;
  99969. private _volume;
  99970. /** A Sound is currently playing. */
  99971. isPlaying: boolean;
  99972. /** A Sound is currently paused. */
  99973. isPaused: boolean;
  99974. private _sounds;
  99975. private _weights;
  99976. private _currentIndex?;
  99977. /**
  99978. * Creates a new WeightedSound from the list of sounds given.
  99979. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99980. * @param sounds Array of Sounds that will be selected from.
  99981. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99982. */
  99983. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99984. /**
  99985. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99986. */
  99987. /**
  99988. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99989. */
  99990. directionalConeInnerAngle: number;
  99991. /**
  99992. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99993. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99994. */
  99995. /**
  99996. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99997. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99998. */
  99999. directionalConeOuterAngle: number;
  100000. /**
  100001. * Playback volume.
  100002. */
  100003. /**
  100004. * Playback volume.
  100005. */
  100006. volume: number;
  100007. private _onended;
  100008. /**
  100009. * Suspend playback
  100010. */
  100011. pause(): void;
  100012. /**
  100013. * Stop playback
  100014. */
  100015. stop(): void;
  100016. /**
  100017. * Start playback.
  100018. * @param startOffset Position the clip head at a specific time in seconds.
  100019. */
  100020. play(startOffset?: number): void;
  100021. }
  100022. }
  100023. declare module BABYLON {
  100024. /**
  100025. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100027. */
  100028. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100029. /**
  100030. * Gets the name of the behavior.
  100031. */
  100032. readonly name: string;
  100033. /**
  100034. * The easing function used by animations
  100035. */
  100036. static EasingFunction: BackEase;
  100037. /**
  100038. * The easing mode used by animations
  100039. */
  100040. static EasingMode: number;
  100041. /**
  100042. * The duration of the animation, in milliseconds
  100043. */
  100044. transitionDuration: number;
  100045. /**
  100046. * Length of the distance animated by the transition when lower radius is reached
  100047. */
  100048. lowerRadiusTransitionRange: number;
  100049. /**
  100050. * Length of the distance animated by the transition when upper radius is reached
  100051. */
  100052. upperRadiusTransitionRange: number;
  100053. private _autoTransitionRange;
  100054. /**
  100055. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100056. */
  100057. /**
  100058. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100059. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100060. */
  100061. autoTransitionRange: boolean;
  100062. private _attachedCamera;
  100063. private _onAfterCheckInputsObserver;
  100064. private _onMeshTargetChangedObserver;
  100065. /**
  100066. * Initializes the behavior.
  100067. */
  100068. init(): void;
  100069. /**
  100070. * Attaches the behavior to its arc rotate camera.
  100071. * @param camera Defines the camera to attach the behavior to
  100072. */
  100073. attach(camera: ArcRotateCamera): void;
  100074. /**
  100075. * Detaches the behavior from its current arc rotate camera.
  100076. */
  100077. detach(): void;
  100078. private _radiusIsAnimating;
  100079. private _radiusBounceTransition;
  100080. private _animatables;
  100081. private _cachedWheelPrecision;
  100082. /**
  100083. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100084. * @param radiusLimit The limit to check against.
  100085. * @return Bool to indicate if at limit.
  100086. */
  100087. private _isRadiusAtLimit;
  100088. /**
  100089. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100090. * @param radiusDelta The delta by which to animate to. Can be negative.
  100091. */
  100092. private _applyBoundRadiusAnimation;
  100093. /**
  100094. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100095. */
  100096. protected _clearAnimationLocks(): void;
  100097. /**
  100098. * Stops and removes all animations that have been applied to the camera
  100099. */
  100100. stopAllAnimations(): void;
  100101. }
  100102. }
  100103. declare module BABYLON {
  100104. /**
  100105. * 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.
  100106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100107. */
  100108. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100109. /**
  100110. * Gets the name of the behavior.
  100111. */
  100112. readonly name: string;
  100113. private _mode;
  100114. private _radiusScale;
  100115. private _positionScale;
  100116. private _defaultElevation;
  100117. private _elevationReturnTime;
  100118. private _elevationReturnWaitTime;
  100119. private _zoomStopsAnimation;
  100120. private _framingTime;
  100121. /**
  100122. * The easing function used by animations
  100123. */
  100124. static EasingFunction: ExponentialEase;
  100125. /**
  100126. * The easing mode used by animations
  100127. */
  100128. static EasingMode: number;
  100129. /**
  100130. * Sets the current mode used by the behavior
  100131. */
  100132. /**
  100133. * Gets current mode used by the behavior.
  100134. */
  100135. mode: number;
  100136. /**
  100137. * Sets the scale applied to the radius (1 by default)
  100138. */
  100139. /**
  100140. * Gets the scale applied to the radius
  100141. */
  100142. radiusScale: number;
  100143. /**
  100144. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100145. */
  100146. /**
  100147. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100148. */
  100149. positionScale: number;
  100150. /**
  100151. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100152. * behaviour is triggered, in radians.
  100153. */
  100154. /**
  100155. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100156. * behaviour is triggered, in radians.
  100157. */
  100158. defaultElevation: number;
  100159. /**
  100160. * Sets the time (in milliseconds) taken to return to the default beta position.
  100161. * Negative value indicates camera should not return to default.
  100162. */
  100163. /**
  100164. * Gets the time (in milliseconds) taken to return to the default beta position.
  100165. * Negative value indicates camera should not return to default.
  100166. */
  100167. elevationReturnTime: number;
  100168. /**
  100169. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100170. */
  100171. /**
  100172. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100173. */
  100174. elevationReturnWaitTime: number;
  100175. /**
  100176. * Sets the flag that indicates if user zooming should stop animation.
  100177. */
  100178. /**
  100179. * Gets the flag that indicates if user zooming should stop animation.
  100180. */
  100181. zoomStopsAnimation: boolean;
  100182. /**
  100183. * Sets the transition time when framing the mesh, in milliseconds
  100184. */
  100185. /**
  100186. * Gets the transition time when framing the mesh, in milliseconds
  100187. */
  100188. framingTime: number;
  100189. /**
  100190. * Define if the behavior should automatically change the configured
  100191. * camera limits and sensibilities.
  100192. */
  100193. autoCorrectCameraLimitsAndSensibility: boolean;
  100194. private _onPrePointerObservableObserver;
  100195. private _onAfterCheckInputsObserver;
  100196. private _onMeshTargetChangedObserver;
  100197. private _attachedCamera;
  100198. private _isPointerDown;
  100199. private _lastInteractionTime;
  100200. /**
  100201. * Initializes the behavior.
  100202. */
  100203. init(): void;
  100204. /**
  100205. * Attaches the behavior to its arc rotate camera.
  100206. * @param camera Defines the camera to attach the behavior to
  100207. */
  100208. attach(camera: ArcRotateCamera): void;
  100209. /**
  100210. * Detaches the behavior from its current arc rotate camera.
  100211. */
  100212. detach(): void;
  100213. private _animatables;
  100214. private _betaIsAnimating;
  100215. private _betaTransition;
  100216. private _radiusTransition;
  100217. private _vectorTransition;
  100218. /**
  100219. * Targets the given mesh and updates zoom level accordingly.
  100220. * @param mesh The mesh to target.
  100221. * @param radius Optional. If a cached radius position already exists, overrides default.
  100222. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100223. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100224. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100225. */
  100226. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100227. /**
  100228. * Targets the given mesh with its children and updates zoom level accordingly.
  100229. * @param mesh The mesh to target.
  100230. * @param radius Optional. If a cached radius position already exists, overrides default.
  100231. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100232. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100233. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100234. */
  100235. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100236. /**
  100237. * Targets the given meshes with their children and updates zoom level accordingly.
  100238. * @param meshes The mesh to target.
  100239. * @param radius Optional. If a cached radius position already exists, overrides default.
  100240. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100241. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100242. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100243. */
  100244. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100245. /**
  100246. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100247. * @param minimumWorld Determines the smaller position of the bounding box extend
  100248. * @param maximumWorld Determines the bigger position of the bounding box extend
  100249. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100250. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100251. */
  100252. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100253. /**
  100254. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100255. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100256. * frustum width.
  100257. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100258. * to fully enclose the mesh in the viewing frustum.
  100259. */
  100260. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100261. /**
  100262. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100263. * is automatically returned to its default position (expected to be above ground plane).
  100264. */
  100265. private _maintainCameraAboveGround;
  100266. /**
  100267. * Returns the frustum slope based on the canvas ratio and camera FOV
  100268. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100269. */
  100270. private _getFrustumSlope;
  100271. /**
  100272. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100273. */
  100274. private _clearAnimationLocks;
  100275. /**
  100276. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100277. */
  100278. private _applyUserInteraction;
  100279. /**
  100280. * Stops and removes all animations that have been applied to the camera
  100281. */
  100282. stopAllAnimations(): void;
  100283. /**
  100284. * Gets a value indicating if the user is moving the camera
  100285. */
  100286. readonly isUserIsMoving: boolean;
  100287. /**
  100288. * The camera can move all the way towards the mesh.
  100289. */
  100290. static IgnoreBoundsSizeMode: number;
  100291. /**
  100292. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100293. */
  100294. static FitFrustumSidesMode: number;
  100295. }
  100296. }
  100297. declare module BABYLON {
  100298. /**
  100299. * Base class for Camera Pointer Inputs.
  100300. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100301. * for example usage.
  100302. */
  100303. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100304. /**
  100305. * Defines the camera the input is attached to.
  100306. */
  100307. abstract camera: Camera;
  100308. /**
  100309. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100310. */
  100311. protected _altKey: boolean;
  100312. protected _ctrlKey: boolean;
  100313. protected _metaKey: boolean;
  100314. protected _shiftKey: boolean;
  100315. /**
  100316. * Which mouse buttons were pressed at time of last mouse event.
  100317. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100318. */
  100319. protected _buttonsPressed: number;
  100320. /**
  100321. * Defines the buttons associated with the input to handle camera move.
  100322. */
  100323. buttons: number[];
  100324. /**
  100325. * Attach the input controls to a specific dom element to get the input from.
  100326. * @param element Defines the element the controls should be listened from
  100327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100328. */
  100329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100330. /**
  100331. * Detach the current controls from the specified dom element.
  100332. * @param element Defines the element to stop listening the inputs from
  100333. */
  100334. detachControl(element: Nullable<HTMLElement>): void;
  100335. /**
  100336. * Gets the class name of the current input.
  100337. * @returns the class name
  100338. */
  100339. getClassName(): string;
  100340. /**
  100341. * Get the friendly name associated with the input class.
  100342. * @returns the input friendly name
  100343. */
  100344. getSimpleName(): string;
  100345. /**
  100346. * Called on pointer POINTERDOUBLETAP event.
  100347. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100348. */
  100349. protected onDoubleTap(type: string): void;
  100350. /**
  100351. * Called on pointer POINTERMOVE event if only a single touch is active.
  100352. * Override this method to provide functionality.
  100353. */
  100354. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100355. /**
  100356. * Called on pointer POINTERMOVE event if multiple touches are active.
  100357. * Override this method to provide functionality.
  100358. */
  100359. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100360. /**
  100361. * Called on JS contextmenu event.
  100362. * Override this method to provide functionality.
  100363. */
  100364. protected onContextMenu(evt: PointerEvent): void;
  100365. /**
  100366. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100367. * press.
  100368. * Override this method to provide functionality.
  100369. */
  100370. protected onButtonDown(evt: PointerEvent): void;
  100371. /**
  100372. * Called each time a new POINTERUP event occurs. Ie, for each button
  100373. * release.
  100374. * Override this method to provide functionality.
  100375. */
  100376. protected onButtonUp(evt: PointerEvent): void;
  100377. /**
  100378. * Called when window becomes inactive.
  100379. * Override this method to provide functionality.
  100380. */
  100381. protected onLostFocus(): void;
  100382. private _pointerInput;
  100383. private _observer;
  100384. private _onLostFocus;
  100385. private pointA;
  100386. private pointB;
  100387. }
  100388. }
  100389. declare module BABYLON {
  100390. /**
  100391. * Manage the pointers inputs to control an arc rotate camera.
  100392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100393. */
  100394. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100395. /**
  100396. * Defines the camera the input is attached to.
  100397. */
  100398. camera: ArcRotateCamera;
  100399. /**
  100400. * Gets the class name of the current input.
  100401. * @returns the class name
  100402. */
  100403. getClassName(): string;
  100404. /**
  100405. * Defines the buttons associated with the input to handle camera move.
  100406. */
  100407. buttons: number[];
  100408. /**
  100409. * Defines the pointer angular sensibility along the X axis or how fast is
  100410. * the camera rotating.
  100411. */
  100412. angularSensibilityX: number;
  100413. /**
  100414. * Defines the pointer angular sensibility along the Y axis or how fast is
  100415. * the camera rotating.
  100416. */
  100417. angularSensibilityY: number;
  100418. /**
  100419. * Defines the pointer pinch precision or how fast is the camera zooming.
  100420. */
  100421. pinchPrecision: number;
  100422. /**
  100423. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100424. * from 0.
  100425. * It defines the percentage of current camera.radius to use as delta when
  100426. * pinch zoom is used.
  100427. */
  100428. pinchDeltaPercentage: number;
  100429. /**
  100430. * Defines the pointer panning sensibility or how fast is the camera moving.
  100431. */
  100432. panningSensibility: number;
  100433. /**
  100434. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100435. */
  100436. multiTouchPanning: boolean;
  100437. /**
  100438. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100439. * zoom (pinch) through multitouch.
  100440. */
  100441. multiTouchPanAndZoom: boolean;
  100442. /**
  100443. * Revers pinch action direction.
  100444. */
  100445. pinchInwards: boolean;
  100446. private _isPanClick;
  100447. private _twoFingerActivityCount;
  100448. private _isPinching;
  100449. /**
  100450. * Called on pointer POINTERMOVE event if only a single touch is active.
  100451. */
  100452. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100453. /**
  100454. * Called on pointer POINTERDOUBLETAP event.
  100455. */
  100456. protected onDoubleTap(type: string): void;
  100457. /**
  100458. * Called on pointer POINTERMOVE event if multiple touches are active.
  100459. */
  100460. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100461. /**
  100462. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100463. * press.
  100464. */
  100465. protected onButtonDown(evt: PointerEvent): void;
  100466. /**
  100467. * Called each time a new POINTERUP event occurs. Ie, for each button
  100468. * release.
  100469. */
  100470. protected onButtonUp(evt: PointerEvent): void;
  100471. /**
  100472. * Called when window becomes inactive.
  100473. */
  100474. protected onLostFocus(): void;
  100475. }
  100476. }
  100477. declare module BABYLON {
  100478. /**
  100479. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100481. */
  100482. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100483. /**
  100484. * Defines the camera the input is attached to.
  100485. */
  100486. camera: ArcRotateCamera;
  100487. /**
  100488. * Defines the list of key codes associated with the up action (increase alpha)
  100489. */
  100490. keysUp: number[];
  100491. /**
  100492. * Defines the list of key codes associated with the down action (decrease alpha)
  100493. */
  100494. keysDown: number[];
  100495. /**
  100496. * Defines the list of key codes associated with the left action (increase beta)
  100497. */
  100498. keysLeft: number[];
  100499. /**
  100500. * Defines the list of key codes associated with the right action (decrease beta)
  100501. */
  100502. keysRight: number[];
  100503. /**
  100504. * Defines the list of key codes associated with the reset action.
  100505. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100506. */
  100507. keysReset: number[];
  100508. /**
  100509. * Defines the panning sensibility of the inputs.
  100510. * (How fast is the camera paning)
  100511. */
  100512. panningSensibility: number;
  100513. /**
  100514. * Defines the zooming sensibility of the inputs.
  100515. * (How fast is the camera zooming)
  100516. */
  100517. zoomingSensibility: number;
  100518. /**
  100519. * Defines wether maintaining the alt key down switch the movement mode from
  100520. * orientation to zoom.
  100521. */
  100522. useAltToZoom: boolean;
  100523. /**
  100524. * Rotation speed of the camera
  100525. */
  100526. angularSpeed: number;
  100527. private _keys;
  100528. private _ctrlPressed;
  100529. private _altPressed;
  100530. private _onCanvasBlurObserver;
  100531. private _onKeyboardObserver;
  100532. private _engine;
  100533. private _scene;
  100534. /**
  100535. * Attach the input controls to a specific dom element to get the input from.
  100536. * @param element Defines the element the controls should be listened from
  100537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100538. */
  100539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100540. /**
  100541. * Detach the current controls from the specified dom element.
  100542. * @param element Defines the element to stop listening the inputs from
  100543. */
  100544. detachControl(element: Nullable<HTMLElement>): void;
  100545. /**
  100546. * Update the current camera state depending on the inputs that have been used this frame.
  100547. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100548. */
  100549. checkInputs(): void;
  100550. /**
  100551. * Gets the class name of the current intput.
  100552. * @returns the class name
  100553. */
  100554. getClassName(): string;
  100555. /**
  100556. * Get the friendly name associated with the input class.
  100557. * @returns the input friendly name
  100558. */
  100559. getSimpleName(): string;
  100560. }
  100561. }
  100562. declare module BABYLON {
  100563. /**
  100564. * Manage the mouse wheel inputs to control an arc rotate camera.
  100565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100566. */
  100567. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100568. /**
  100569. * Defines the camera the input is attached to.
  100570. */
  100571. camera: ArcRotateCamera;
  100572. /**
  100573. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100574. */
  100575. wheelPrecision: number;
  100576. /**
  100577. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100578. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100579. */
  100580. wheelDeltaPercentage: number;
  100581. private _wheel;
  100582. private _observer;
  100583. private computeDeltaFromMouseWheelLegacyEvent;
  100584. /**
  100585. * Attach the input controls to a specific dom element to get the input from.
  100586. * @param element Defines the element the controls should be listened from
  100587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100588. */
  100589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100590. /**
  100591. * Detach the current controls from the specified dom element.
  100592. * @param element Defines the element to stop listening the inputs from
  100593. */
  100594. detachControl(element: Nullable<HTMLElement>): void;
  100595. /**
  100596. * Gets the class name of the current intput.
  100597. * @returns the class name
  100598. */
  100599. getClassName(): string;
  100600. /**
  100601. * Get the friendly name associated with the input class.
  100602. * @returns the input friendly name
  100603. */
  100604. getSimpleName(): string;
  100605. }
  100606. }
  100607. declare module BABYLON {
  100608. /**
  100609. * Default Inputs manager for the ArcRotateCamera.
  100610. * It groups all the default supported inputs for ease of use.
  100611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100612. */
  100613. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100614. /**
  100615. * Instantiates a new ArcRotateCameraInputsManager.
  100616. * @param camera Defines the camera the inputs belong to
  100617. */
  100618. constructor(camera: ArcRotateCamera);
  100619. /**
  100620. * Add mouse wheel input support to the input manager.
  100621. * @returns the current input manager
  100622. */
  100623. addMouseWheel(): ArcRotateCameraInputsManager;
  100624. /**
  100625. * Add pointers input support to the input manager.
  100626. * @returns the current input manager
  100627. */
  100628. addPointers(): ArcRotateCameraInputsManager;
  100629. /**
  100630. * Add keyboard input support to the input manager.
  100631. * @returns the current input manager
  100632. */
  100633. addKeyboard(): ArcRotateCameraInputsManager;
  100634. }
  100635. }
  100636. declare module BABYLON {
  100637. /**
  100638. * This represents an orbital type of camera.
  100639. *
  100640. * 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.
  100641. * 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.
  100642. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100643. */
  100644. export class ArcRotateCamera extends TargetCamera {
  100645. /**
  100646. * Defines the rotation angle of the camera along the longitudinal axis.
  100647. */
  100648. alpha: number;
  100649. /**
  100650. * Defines the rotation angle of the camera along the latitudinal axis.
  100651. */
  100652. beta: number;
  100653. /**
  100654. * Defines the radius of the camera from it s target point.
  100655. */
  100656. radius: number;
  100657. protected _target: Vector3;
  100658. protected _targetHost: Nullable<AbstractMesh>;
  100659. /**
  100660. * Defines the target point of the camera.
  100661. * The camera looks towards it form the radius distance.
  100662. */
  100663. target: Vector3;
  100664. /**
  100665. * Define the current local position of the camera in the scene
  100666. */
  100667. position: Vector3;
  100668. protected _upVector: Vector3;
  100669. protected _upToYMatrix: Matrix;
  100670. protected _YToUpMatrix: Matrix;
  100671. /**
  100672. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100673. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100674. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100675. */
  100676. upVector: Vector3;
  100677. /**
  100678. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100679. */
  100680. setMatUp(): void;
  100681. /**
  100682. * Current inertia value on the longitudinal axis.
  100683. * The bigger this number the longer it will take for the camera to stop.
  100684. */
  100685. inertialAlphaOffset: number;
  100686. /**
  100687. * Current inertia value on the latitudinal axis.
  100688. * The bigger this number the longer it will take for the camera to stop.
  100689. */
  100690. inertialBetaOffset: number;
  100691. /**
  100692. * Current inertia value on the radius axis.
  100693. * The bigger this number the longer it will take for the camera to stop.
  100694. */
  100695. inertialRadiusOffset: number;
  100696. /**
  100697. * Minimum allowed angle on the longitudinal axis.
  100698. * This can help limiting how the Camera is able to move in the scene.
  100699. */
  100700. lowerAlphaLimit: Nullable<number>;
  100701. /**
  100702. * Maximum allowed angle on the longitudinal axis.
  100703. * This can help limiting how the Camera is able to move in the scene.
  100704. */
  100705. upperAlphaLimit: Nullable<number>;
  100706. /**
  100707. * Minimum allowed angle on the latitudinal axis.
  100708. * This can help limiting how the Camera is able to move in the scene.
  100709. */
  100710. lowerBetaLimit: number;
  100711. /**
  100712. * Maximum allowed angle on the latitudinal axis.
  100713. * This can help limiting how the Camera is able to move in the scene.
  100714. */
  100715. upperBetaLimit: number;
  100716. /**
  100717. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100718. * This can help limiting how the Camera is able to move in the scene.
  100719. */
  100720. lowerRadiusLimit: Nullable<number>;
  100721. /**
  100722. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100723. * This can help limiting how the Camera is able to move in the scene.
  100724. */
  100725. upperRadiusLimit: Nullable<number>;
  100726. /**
  100727. * Defines the current inertia value used during panning of the camera along the X axis.
  100728. */
  100729. inertialPanningX: number;
  100730. /**
  100731. * Defines the current inertia value used during panning of the camera along the Y axis.
  100732. */
  100733. inertialPanningY: number;
  100734. /**
  100735. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100736. * Basically if your fingers moves away from more than this distance you will be considered
  100737. * in pinch mode.
  100738. */
  100739. pinchToPanMaxDistance: number;
  100740. /**
  100741. * Defines the maximum distance the camera can pan.
  100742. * This could help keeping the cammera always in your scene.
  100743. */
  100744. panningDistanceLimit: Nullable<number>;
  100745. /**
  100746. * Defines the target of the camera before paning.
  100747. */
  100748. panningOriginTarget: Vector3;
  100749. /**
  100750. * Defines the value of the inertia used during panning.
  100751. * 0 would mean stop inertia and one would mean no decelleration at all.
  100752. */
  100753. panningInertia: number;
  100754. /**
  100755. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100756. */
  100757. angularSensibilityX: number;
  100758. /**
  100759. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100760. */
  100761. angularSensibilityY: number;
  100762. /**
  100763. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100764. */
  100765. pinchPrecision: number;
  100766. /**
  100767. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100768. * It will be used instead of pinchDeltaPrecision if different from 0.
  100769. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100770. */
  100771. pinchDeltaPercentage: number;
  100772. /**
  100773. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100774. */
  100775. panningSensibility: number;
  100776. /**
  100777. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100778. */
  100779. keysUp: number[];
  100780. /**
  100781. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100782. */
  100783. keysDown: number[];
  100784. /**
  100785. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100786. */
  100787. keysLeft: number[];
  100788. /**
  100789. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100790. */
  100791. keysRight: number[];
  100792. /**
  100793. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100794. */
  100795. wheelPrecision: number;
  100796. /**
  100797. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100798. * It will be used instead of pinchDeltaPrecision if different from 0.
  100799. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100800. */
  100801. wheelDeltaPercentage: number;
  100802. /**
  100803. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100804. */
  100805. zoomOnFactor: number;
  100806. /**
  100807. * Defines a screen offset for the camera position.
  100808. */
  100809. targetScreenOffset: Vector2;
  100810. /**
  100811. * Allows the camera to be completely reversed.
  100812. * If false the camera can not arrive upside down.
  100813. */
  100814. allowUpsideDown: boolean;
  100815. /**
  100816. * Define if double tap/click is used to restore the previously saved state of the camera.
  100817. */
  100818. useInputToRestoreState: boolean;
  100819. /** @hidden */
  100820. _viewMatrix: Matrix;
  100821. /** @hidden */
  100822. _useCtrlForPanning: boolean;
  100823. /** @hidden */
  100824. _panningMouseButton: number;
  100825. /**
  100826. * Defines the input associated to the camera.
  100827. */
  100828. inputs: ArcRotateCameraInputsManager;
  100829. /** @hidden */
  100830. _reset: () => void;
  100831. /**
  100832. * Defines the allowed panning axis.
  100833. */
  100834. panningAxis: Vector3;
  100835. protected _localDirection: Vector3;
  100836. protected _transformedDirection: Vector3;
  100837. private _bouncingBehavior;
  100838. /**
  100839. * Gets the bouncing behavior of the camera if it has been enabled.
  100840. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100841. */
  100842. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100843. /**
  100844. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100845. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100846. */
  100847. useBouncingBehavior: boolean;
  100848. private _framingBehavior;
  100849. /**
  100850. * Gets the framing behavior of the camera if it has been enabled.
  100851. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100852. */
  100853. readonly framingBehavior: Nullable<FramingBehavior>;
  100854. /**
  100855. * Defines if the framing behavior of the camera is enabled on the camera.
  100856. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100857. */
  100858. useFramingBehavior: boolean;
  100859. private _autoRotationBehavior;
  100860. /**
  100861. * Gets the auto rotation behavior of the camera if it has been enabled.
  100862. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100863. */
  100864. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100865. /**
  100866. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100868. */
  100869. useAutoRotationBehavior: boolean;
  100870. /**
  100871. * Observable triggered when the mesh target has been changed on the camera.
  100872. */
  100873. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100874. /**
  100875. * Event raised when the camera is colliding with a mesh.
  100876. */
  100877. onCollide: (collidedMesh: AbstractMesh) => void;
  100878. /**
  100879. * Defines whether the camera should check collision with the objects oh the scene.
  100880. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100881. */
  100882. checkCollisions: boolean;
  100883. /**
  100884. * Defines the collision radius of the camera.
  100885. * This simulates a sphere around the camera.
  100886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100887. */
  100888. collisionRadius: Vector3;
  100889. protected _collider: Collider;
  100890. protected _previousPosition: Vector3;
  100891. protected _collisionVelocity: Vector3;
  100892. protected _newPosition: Vector3;
  100893. protected _previousAlpha: number;
  100894. protected _previousBeta: number;
  100895. protected _previousRadius: number;
  100896. protected _collisionTriggered: boolean;
  100897. protected _targetBoundingCenter: Nullable<Vector3>;
  100898. private _computationVector;
  100899. /**
  100900. * Instantiates a new ArcRotateCamera in a given scene
  100901. * @param name Defines the name of the camera
  100902. * @param alpha Defines the camera rotation along the logitudinal axis
  100903. * @param beta Defines the camera rotation along the latitudinal axis
  100904. * @param radius Defines the camera distance from its target
  100905. * @param target Defines the camera target
  100906. * @param scene Defines the scene the camera belongs to
  100907. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100908. */
  100909. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100910. /** @hidden */
  100911. _initCache(): void;
  100912. /** @hidden */
  100913. _updateCache(ignoreParentClass?: boolean): void;
  100914. protected _getTargetPosition(): Vector3;
  100915. private _storedAlpha;
  100916. private _storedBeta;
  100917. private _storedRadius;
  100918. private _storedTarget;
  100919. /**
  100920. * Stores the current state of the camera (alpha, beta, radius and target)
  100921. * @returns the camera itself
  100922. */
  100923. storeState(): Camera;
  100924. /**
  100925. * @hidden
  100926. * Restored camera state. You must call storeState() first
  100927. */
  100928. _restoreStateValues(): boolean;
  100929. /** @hidden */
  100930. _isSynchronizedViewMatrix(): boolean;
  100931. /**
  100932. * Attached controls to the current camera.
  100933. * @param element Defines the element the controls should be listened from
  100934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100935. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100936. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100937. */
  100938. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100939. /**
  100940. * Detach the current controls from the camera.
  100941. * The camera will stop reacting to inputs.
  100942. * @param element Defines the element to stop listening the inputs from
  100943. */
  100944. detachControl(element: HTMLElement): void;
  100945. /** @hidden */
  100946. _checkInputs(): void;
  100947. protected _checkLimits(): void;
  100948. /**
  100949. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100950. */
  100951. rebuildAnglesAndRadius(): void;
  100952. /**
  100953. * Use a position to define the current camera related information like aplha, beta and radius
  100954. * @param position Defines the position to set the camera at
  100955. */
  100956. setPosition(position: Vector3): void;
  100957. /**
  100958. * Defines the target the camera should look at.
  100959. * This will automatically adapt alpha beta and radius to fit within the new target.
  100960. * @param target Defines the new target as a Vector or a mesh
  100961. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100962. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100963. */
  100964. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100965. /** @hidden */
  100966. _getViewMatrix(): Matrix;
  100967. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100968. /**
  100969. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100970. * @param meshes Defines the mesh to zoom on
  100971. * @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)
  100972. */
  100973. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100974. /**
  100975. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100976. * The target will be changed but the radius
  100977. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100978. * @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)
  100979. */
  100980. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100981. min: Vector3;
  100982. max: Vector3;
  100983. distance: number;
  100984. }, doNotUpdateMaxZ?: boolean): void;
  100985. /**
  100986. * @override
  100987. * Override Camera.createRigCamera
  100988. */
  100989. createRigCamera(name: string, cameraIndex: number): Camera;
  100990. /**
  100991. * @hidden
  100992. * @override
  100993. * Override Camera._updateRigCameras
  100994. */
  100995. _updateRigCameras(): void;
  100996. /**
  100997. * Destroy the camera and release the current resources hold by it.
  100998. */
  100999. dispose(): void;
  101000. /**
  101001. * Gets the current object class name.
  101002. * @return the class name
  101003. */
  101004. getClassName(): string;
  101005. }
  101006. }
  101007. declare module BABYLON {
  101008. /**
  101009. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101010. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101011. */
  101012. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101013. /**
  101014. * Gets the name of the behavior.
  101015. */
  101016. readonly name: string;
  101017. private _zoomStopsAnimation;
  101018. private _idleRotationSpeed;
  101019. private _idleRotationWaitTime;
  101020. private _idleRotationSpinupTime;
  101021. /**
  101022. * Sets the flag that indicates if user zooming should stop animation.
  101023. */
  101024. /**
  101025. * Gets the flag that indicates if user zooming should stop animation.
  101026. */
  101027. zoomStopsAnimation: boolean;
  101028. /**
  101029. * Sets the default speed at which the camera rotates around the model.
  101030. */
  101031. /**
  101032. * Gets the default speed at which the camera rotates around the model.
  101033. */
  101034. idleRotationSpeed: number;
  101035. /**
  101036. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101037. */
  101038. /**
  101039. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101040. */
  101041. idleRotationWaitTime: number;
  101042. /**
  101043. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101044. */
  101045. /**
  101046. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101047. */
  101048. idleRotationSpinupTime: number;
  101049. /**
  101050. * Gets a value indicating if the camera is currently rotating because of this behavior
  101051. */
  101052. readonly rotationInProgress: boolean;
  101053. private _onPrePointerObservableObserver;
  101054. private _onAfterCheckInputsObserver;
  101055. private _attachedCamera;
  101056. private _isPointerDown;
  101057. private _lastFrameTime;
  101058. private _lastInteractionTime;
  101059. private _cameraRotationSpeed;
  101060. /**
  101061. * Initializes the behavior.
  101062. */
  101063. init(): void;
  101064. /**
  101065. * Attaches the behavior to its arc rotate camera.
  101066. * @param camera Defines the camera to attach the behavior to
  101067. */
  101068. attach(camera: ArcRotateCamera): void;
  101069. /**
  101070. * Detaches the behavior from its current arc rotate camera.
  101071. */
  101072. detach(): void;
  101073. /**
  101074. * Returns true if user is scrolling.
  101075. * @return true if user is scrolling.
  101076. */
  101077. private _userIsZooming;
  101078. private _lastFrameRadius;
  101079. private _shouldAnimationStopForInteraction;
  101080. /**
  101081. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101082. */
  101083. private _applyUserInteraction;
  101084. private _userIsMoving;
  101085. }
  101086. }
  101087. declare module BABYLON {
  101088. /**
  101089. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101090. */
  101091. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101092. private ui;
  101093. /**
  101094. * The name of the behavior
  101095. */
  101096. name: string;
  101097. /**
  101098. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101099. */
  101100. distanceAwayFromFace: number;
  101101. /**
  101102. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101103. */
  101104. distanceAwayFromBottomOfFace: number;
  101105. private _faceVectors;
  101106. private _target;
  101107. private _scene;
  101108. private _onRenderObserver;
  101109. private _tmpMatrix;
  101110. private _tmpVector;
  101111. /**
  101112. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101113. * @param ui The transform node that should be attched to the mesh
  101114. */
  101115. constructor(ui: TransformNode);
  101116. /**
  101117. * Initializes the behavior
  101118. */
  101119. init(): void;
  101120. private _closestFace;
  101121. private _zeroVector;
  101122. private _lookAtTmpMatrix;
  101123. private _lookAtToRef;
  101124. /**
  101125. * Attaches the AttachToBoxBehavior to the passed in mesh
  101126. * @param target The mesh that the specified node will be attached to
  101127. */
  101128. attach(target: Mesh): void;
  101129. /**
  101130. * Detaches the behavior from the mesh
  101131. */
  101132. detach(): void;
  101133. }
  101134. }
  101135. declare module BABYLON {
  101136. /**
  101137. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  101138. */
  101139. export class FadeInOutBehavior implements Behavior<Mesh> {
  101140. /**
  101141. * Time in milliseconds to delay before fading in (Default: 0)
  101142. */
  101143. delay: number;
  101144. /**
  101145. * Time in milliseconds for the mesh to fade in (Default: 300)
  101146. */
  101147. fadeInTime: number;
  101148. private _millisecondsPerFrame;
  101149. private _hovered;
  101150. private _hoverValue;
  101151. private _ownerNode;
  101152. /**
  101153. * Instatiates the FadeInOutBehavior
  101154. */
  101155. constructor();
  101156. /**
  101157. * The name of the behavior
  101158. */
  101159. readonly name: string;
  101160. /**
  101161. * Initializes the behavior
  101162. */
  101163. init(): void;
  101164. /**
  101165. * Attaches the fade behavior on the passed in mesh
  101166. * @param ownerNode The mesh that will be faded in/out once attached
  101167. */
  101168. attach(ownerNode: Mesh): void;
  101169. /**
  101170. * Detaches the behavior from the mesh
  101171. */
  101172. detach(): void;
  101173. /**
  101174. * Triggers the mesh to begin fading in or out
  101175. * @param value if the object should fade in or out (true to fade in)
  101176. */
  101177. fadeIn(value: boolean): void;
  101178. private _update;
  101179. private _setAllVisibility;
  101180. }
  101181. }
  101182. declare module BABYLON {
  101183. /**
  101184. * Class containing a set of static utilities functions for managing Pivots
  101185. * @hidden
  101186. */
  101187. export class PivotTools {
  101188. private static _PivotCached;
  101189. private static _OldPivotPoint;
  101190. private static _PivotTranslation;
  101191. private static _PivotTmpVector;
  101192. /** @hidden */
  101193. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101194. /** @hidden */
  101195. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101196. }
  101197. }
  101198. declare module BABYLON {
  101199. /**
  101200. * Class containing static functions to help procedurally build meshes
  101201. */
  101202. export class PlaneBuilder {
  101203. /**
  101204. * Creates a plane mesh
  101205. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101206. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101207. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101211. * @param name defines the name of the mesh
  101212. * @param options defines the options used to create the mesh
  101213. * @param scene defines the hosting scene
  101214. * @returns the plane mesh
  101215. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101216. */
  101217. static CreatePlane(name: string, options: {
  101218. size?: number;
  101219. width?: number;
  101220. height?: number;
  101221. sideOrientation?: number;
  101222. frontUVs?: Vector4;
  101223. backUVs?: Vector4;
  101224. updatable?: boolean;
  101225. sourcePlane?: Plane;
  101226. }, scene?: Nullable<Scene>): Mesh;
  101227. }
  101228. }
  101229. declare module BABYLON {
  101230. /**
  101231. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101232. */
  101233. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101234. private static _AnyMouseID;
  101235. /**
  101236. * Abstract mesh the behavior is set on
  101237. */
  101238. attachedNode: AbstractMesh;
  101239. private _dragPlane;
  101240. private _scene;
  101241. private _pointerObserver;
  101242. private _beforeRenderObserver;
  101243. private static _planeScene;
  101244. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101245. /**
  101246. * 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)
  101247. */
  101248. maxDragAngle: number;
  101249. /**
  101250. * @hidden
  101251. */
  101252. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101253. /**
  101254. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101255. */
  101256. currentDraggingPointerID: number;
  101257. /**
  101258. * The last position where the pointer hit the drag plane in world space
  101259. */
  101260. lastDragPosition: Vector3;
  101261. /**
  101262. * If the behavior is currently in a dragging state
  101263. */
  101264. dragging: boolean;
  101265. /**
  101266. * 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)
  101267. */
  101268. dragDeltaRatio: number;
  101269. /**
  101270. * If the drag plane orientation should be updated during the dragging (Default: true)
  101271. */
  101272. updateDragPlane: boolean;
  101273. private _debugMode;
  101274. private _moving;
  101275. /**
  101276. * Fires each time the attached mesh is dragged with the pointer
  101277. * * delta between last drag position and current drag position in world space
  101278. * * dragDistance along the drag axis
  101279. * * dragPlaneNormal normal of the current drag plane used during the drag
  101280. * * dragPlanePoint in world space where the drag intersects the drag plane
  101281. */
  101282. onDragObservable: Observable<{
  101283. delta: Vector3;
  101284. dragPlanePoint: Vector3;
  101285. dragPlaneNormal: Vector3;
  101286. dragDistance: number;
  101287. pointerId: number;
  101288. }>;
  101289. /**
  101290. * Fires each time a drag begins (eg. mouse down on mesh)
  101291. */
  101292. onDragStartObservable: Observable<{
  101293. dragPlanePoint: Vector3;
  101294. pointerId: number;
  101295. }>;
  101296. /**
  101297. * Fires each time a drag ends (eg. mouse release after drag)
  101298. */
  101299. onDragEndObservable: Observable<{
  101300. dragPlanePoint: Vector3;
  101301. pointerId: number;
  101302. }>;
  101303. /**
  101304. * If the attached mesh should be moved when dragged
  101305. */
  101306. moveAttached: boolean;
  101307. /**
  101308. * If the drag behavior will react to drag events (Default: true)
  101309. */
  101310. enabled: boolean;
  101311. /**
  101312. * If pointer events should start and release the drag (Default: true)
  101313. */
  101314. startAndReleaseDragOnPointerEvents: boolean;
  101315. /**
  101316. * If camera controls should be detached during the drag
  101317. */
  101318. detachCameraControls: boolean;
  101319. /**
  101320. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101321. */
  101322. useObjectOrienationForDragging: boolean;
  101323. private _options;
  101324. /**
  101325. * Creates a pointer drag behavior that can be attached to a mesh
  101326. * @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)
  101327. */
  101328. constructor(options?: {
  101329. dragAxis?: Vector3;
  101330. dragPlaneNormal?: Vector3;
  101331. });
  101332. /**
  101333. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101334. */
  101335. validateDrag: (targetPosition: Vector3) => boolean;
  101336. /**
  101337. * The name of the behavior
  101338. */
  101339. readonly name: string;
  101340. /**
  101341. * Initializes the behavior
  101342. */
  101343. init(): void;
  101344. private _tmpVector;
  101345. private _alternatePickedPoint;
  101346. private _worldDragAxis;
  101347. private _targetPosition;
  101348. private _attachedElement;
  101349. /**
  101350. * Attaches the drag behavior the passed in mesh
  101351. * @param ownerNode The mesh that will be dragged around once attached
  101352. */
  101353. attach(ownerNode: AbstractMesh): void;
  101354. /**
  101355. * Force relase the drag action by code.
  101356. */
  101357. releaseDrag(): void;
  101358. private _startDragRay;
  101359. private _lastPointerRay;
  101360. /**
  101361. * Simulates the start of a pointer drag event on the behavior
  101362. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101363. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101364. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101365. */
  101366. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101367. private _startDrag;
  101368. private _dragDelta;
  101369. private _moveDrag;
  101370. private _pickWithRayOnDragPlane;
  101371. private _pointA;
  101372. private _pointB;
  101373. private _pointC;
  101374. private _lineA;
  101375. private _lineB;
  101376. private _localAxis;
  101377. private _lookAt;
  101378. private _updateDragPlanePosition;
  101379. /**
  101380. * Detaches the behavior from the mesh
  101381. */
  101382. detach(): void;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101388. */
  101389. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101390. private _dragBehaviorA;
  101391. private _dragBehaviorB;
  101392. private _startDistance;
  101393. private _initialScale;
  101394. private _targetScale;
  101395. private _ownerNode;
  101396. private _sceneRenderObserver;
  101397. /**
  101398. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101399. */
  101400. constructor();
  101401. /**
  101402. * The name of the behavior
  101403. */
  101404. readonly name: string;
  101405. /**
  101406. * Initializes the behavior
  101407. */
  101408. init(): void;
  101409. private _getCurrentDistance;
  101410. /**
  101411. * Attaches the scale behavior the passed in mesh
  101412. * @param ownerNode The mesh that will be scaled around once attached
  101413. */
  101414. attach(ownerNode: Mesh): void;
  101415. /**
  101416. * Detaches the behavior from the mesh
  101417. */
  101418. detach(): void;
  101419. }
  101420. }
  101421. declare module BABYLON {
  101422. /**
  101423. * 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
  101424. */
  101425. export class SixDofDragBehavior implements Behavior<Mesh> {
  101426. private static _virtualScene;
  101427. private _ownerNode;
  101428. private _sceneRenderObserver;
  101429. private _scene;
  101430. private _targetPosition;
  101431. private _virtualOriginMesh;
  101432. private _virtualDragMesh;
  101433. private _pointerObserver;
  101434. private _moving;
  101435. private _startingOrientation;
  101436. /**
  101437. * 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)
  101438. */
  101439. private zDragFactor;
  101440. /**
  101441. * If the object should rotate to face the drag origin
  101442. */
  101443. rotateDraggedObject: boolean;
  101444. /**
  101445. * If the behavior is currently in a dragging state
  101446. */
  101447. dragging: boolean;
  101448. /**
  101449. * 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)
  101450. */
  101451. dragDeltaRatio: number;
  101452. /**
  101453. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101454. */
  101455. currentDraggingPointerID: number;
  101456. /**
  101457. * If camera controls should be detached during the drag
  101458. */
  101459. detachCameraControls: boolean;
  101460. /**
  101461. * Fires each time a drag starts
  101462. */
  101463. onDragStartObservable: Observable<{}>;
  101464. /**
  101465. * Fires each time a drag ends (eg. mouse release after drag)
  101466. */
  101467. onDragEndObservable: Observable<{}>;
  101468. /**
  101469. * 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
  101470. */
  101471. constructor();
  101472. /**
  101473. * The name of the behavior
  101474. */
  101475. readonly name: string;
  101476. /**
  101477. * Initializes the behavior
  101478. */
  101479. init(): void;
  101480. /**
  101481. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101482. */
  101483. private readonly _pointerCamera;
  101484. /**
  101485. * Attaches the scale behavior the passed in mesh
  101486. * @param ownerNode The mesh that will be scaled around once attached
  101487. */
  101488. attach(ownerNode: Mesh): void;
  101489. /**
  101490. * Detaches the behavior from the mesh
  101491. */
  101492. detach(): void;
  101493. }
  101494. }
  101495. declare module BABYLON {
  101496. /**
  101497. * Class used to apply inverse kinematics to bones
  101498. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101499. */
  101500. export class BoneIKController {
  101501. private static _tmpVecs;
  101502. private static _tmpQuat;
  101503. private static _tmpMats;
  101504. /**
  101505. * Gets or sets the target mesh
  101506. */
  101507. targetMesh: AbstractMesh;
  101508. /** Gets or sets the mesh used as pole */
  101509. poleTargetMesh: AbstractMesh;
  101510. /**
  101511. * Gets or sets the bone used as pole
  101512. */
  101513. poleTargetBone: Nullable<Bone>;
  101514. /**
  101515. * Gets or sets the target position
  101516. */
  101517. targetPosition: Vector3;
  101518. /**
  101519. * Gets or sets the pole target position
  101520. */
  101521. poleTargetPosition: Vector3;
  101522. /**
  101523. * Gets or sets the pole target local offset
  101524. */
  101525. poleTargetLocalOffset: Vector3;
  101526. /**
  101527. * Gets or sets the pole angle
  101528. */
  101529. poleAngle: number;
  101530. /**
  101531. * Gets or sets the mesh associated with the controller
  101532. */
  101533. mesh: AbstractMesh;
  101534. /**
  101535. * 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)
  101536. */
  101537. slerpAmount: number;
  101538. private _bone1Quat;
  101539. private _bone1Mat;
  101540. private _bone2Ang;
  101541. private _bone1;
  101542. private _bone2;
  101543. private _bone1Length;
  101544. private _bone2Length;
  101545. private _maxAngle;
  101546. private _maxReach;
  101547. private _rightHandedSystem;
  101548. private _bendAxis;
  101549. private _slerping;
  101550. private _adjustRoll;
  101551. /**
  101552. * Gets or sets maximum allowed angle
  101553. */
  101554. maxAngle: number;
  101555. /**
  101556. * Creates a new BoneIKController
  101557. * @param mesh defines the mesh to control
  101558. * @param bone defines the bone to control
  101559. * @param options defines options to set up the controller
  101560. */
  101561. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101562. targetMesh?: AbstractMesh;
  101563. poleTargetMesh?: AbstractMesh;
  101564. poleTargetBone?: Bone;
  101565. poleTargetLocalOffset?: Vector3;
  101566. poleAngle?: number;
  101567. bendAxis?: Vector3;
  101568. maxAngle?: number;
  101569. slerpAmount?: number;
  101570. });
  101571. private _setMaxAngle;
  101572. /**
  101573. * Force the controller to update the bones
  101574. */
  101575. update(): void;
  101576. }
  101577. }
  101578. declare module BABYLON {
  101579. /**
  101580. * Class used to make a bone look toward a point in space
  101581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101582. */
  101583. export class BoneLookController {
  101584. private static _tmpVecs;
  101585. private static _tmpQuat;
  101586. private static _tmpMats;
  101587. /**
  101588. * The target Vector3 that the bone will look at
  101589. */
  101590. target: Vector3;
  101591. /**
  101592. * The mesh that the bone is attached to
  101593. */
  101594. mesh: AbstractMesh;
  101595. /**
  101596. * The bone that will be looking to the target
  101597. */
  101598. bone: Bone;
  101599. /**
  101600. * The up axis of the coordinate system that is used when the bone is rotated
  101601. */
  101602. upAxis: Vector3;
  101603. /**
  101604. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101605. */
  101606. upAxisSpace: Space;
  101607. /**
  101608. * Used to make an adjustment to the yaw of the bone
  101609. */
  101610. adjustYaw: number;
  101611. /**
  101612. * Used to make an adjustment to the pitch of the bone
  101613. */
  101614. adjustPitch: number;
  101615. /**
  101616. * Used to make an adjustment to the roll of the bone
  101617. */
  101618. adjustRoll: number;
  101619. /**
  101620. * 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)
  101621. */
  101622. slerpAmount: number;
  101623. private _minYaw;
  101624. private _maxYaw;
  101625. private _minPitch;
  101626. private _maxPitch;
  101627. private _minYawSin;
  101628. private _minYawCos;
  101629. private _maxYawSin;
  101630. private _maxYawCos;
  101631. private _midYawConstraint;
  101632. private _minPitchTan;
  101633. private _maxPitchTan;
  101634. private _boneQuat;
  101635. private _slerping;
  101636. private _transformYawPitch;
  101637. private _transformYawPitchInv;
  101638. private _firstFrameSkipped;
  101639. private _yawRange;
  101640. private _fowardAxis;
  101641. /**
  101642. * Gets or sets the minimum yaw angle that the bone can look to
  101643. */
  101644. minYaw: number;
  101645. /**
  101646. * Gets or sets the maximum yaw angle that the bone can look to
  101647. */
  101648. maxYaw: number;
  101649. /**
  101650. * Gets or sets the minimum pitch angle that the bone can look to
  101651. */
  101652. minPitch: number;
  101653. /**
  101654. * Gets or sets the maximum pitch angle that the bone can look to
  101655. */
  101656. maxPitch: number;
  101657. /**
  101658. * Create a BoneLookController
  101659. * @param mesh the mesh that the bone belongs to
  101660. * @param bone the bone that will be looking to the target
  101661. * @param target the target Vector3 to look at
  101662. * @param options optional settings:
  101663. * * maxYaw: the maximum angle the bone will yaw to
  101664. * * minYaw: the minimum angle the bone will yaw to
  101665. * * maxPitch: the maximum angle the bone will pitch to
  101666. * * minPitch: the minimum angle the bone will yaw to
  101667. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101668. * * upAxis: the up axis of the coordinate system
  101669. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101670. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101671. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101672. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101673. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101674. * * adjustRoll: used to make an adjustment to the roll of the bone
  101675. **/
  101676. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101677. maxYaw?: number;
  101678. minYaw?: number;
  101679. maxPitch?: number;
  101680. minPitch?: number;
  101681. slerpAmount?: number;
  101682. upAxis?: Vector3;
  101683. upAxisSpace?: Space;
  101684. yawAxis?: Vector3;
  101685. pitchAxis?: Vector3;
  101686. adjustYaw?: number;
  101687. adjustPitch?: number;
  101688. adjustRoll?: number;
  101689. });
  101690. /**
  101691. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101692. */
  101693. update(): void;
  101694. private _getAngleDiff;
  101695. private _getAngleBetween;
  101696. private _isAngleBetween;
  101697. }
  101698. }
  101699. declare module BABYLON {
  101700. /**
  101701. * Manage the gamepad inputs to control an arc rotate camera.
  101702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101703. */
  101704. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101705. /**
  101706. * Defines the camera the input is attached to.
  101707. */
  101708. camera: ArcRotateCamera;
  101709. /**
  101710. * Defines the gamepad the input is gathering event from.
  101711. */
  101712. gamepad: Nullable<Gamepad>;
  101713. /**
  101714. * Defines the gamepad rotation sensiblity.
  101715. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101716. */
  101717. gamepadRotationSensibility: number;
  101718. /**
  101719. * Defines the gamepad move sensiblity.
  101720. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101721. */
  101722. gamepadMoveSensibility: number;
  101723. private _onGamepadConnectedObserver;
  101724. private _onGamepadDisconnectedObserver;
  101725. /**
  101726. * Attach the input controls to a specific dom element to get the input from.
  101727. * @param element Defines the element the controls should be listened from
  101728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101729. */
  101730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101731. /**
  101732. * Detach the current controls from the specified dom element.
  101733. * @param element Defines the element to stop listening the inputs from
  101734. */
  101735. detachControl(element: Nullable<HTMLElement>): void;
  101736. /**
  101737. * Update the current camera state depending on the inputs that have been used this frame.
  101738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101739. */
  101740. checkInputs(): void;
  101741. /**
  101742. * Gets the class name of the current intput.
  101743. * @returns the class name
  101744. */
  101745. getClassName(): string;
  101746. /**
  101747. * Get the friendly name associated with the input class.
  101748. * @returns the input friendly name
  101749. */
  101750. getSimpleName(): string;
  101751. }
  101752. }
  101753. declare module BABYLON {
  101754. interface ArcRotateCameraInputsManager {
  101755. /**
  101756. * Add orientation input support to the input manager.
  101757. * @returns the current input manager
  101758. */
  101759. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101760. }
  101761. /**
  101762. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101764. */
  101765. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101766. /**
  101767. * Defines the camera the input is attached to.
  101768. */
  101769. camera: ArcRotateCamera;
  101770. /**
  101771. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101772. */
  101773. alphaCorrection: number;
  101774. /**
  101775. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101776. */
  101777. gammaCorrection: number;
  101778. private _alpha;
  101779. private _gamma;
  101780. private _dirty;
  101781. private _deviceOrientationHandler;
  101782. /**
  101783. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101784. */
  101785. constructor();
  101786. /**
  101787. * Attach the input controls to a specific dom element to get the input from.
  101788. * @param element Defines the element the controls should be listened from
  101789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101790. */
  101791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101792. /** @hidden */
  101793. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101794. /**
  101795. * Update the current camera state depending on the inputs that have been used this frame.
  101796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101797. */
  101798. checkInputs(): void;
  101799. /**
  101800. * Detach the current controls from the specified dom element.
  101801. * @param element Defines the element to stop listening the inputs from
  101802. */
  101803. detachControl(element: Nullable<HTMLElement>): void;
  101804. /**
  101805. * Gets the class name of the current intput.
  101806. * @returns the class name
  101807. */
  101808. getClassName(): string;
  101809. /**
  101810. * Get the friendly name associated with the input class.
  101811. * @returns the input friendly name
  101812. */
  101813. getSimpleName(): string;
  101814. }
  101815. }
  101816. declare module BABYLON {
  101817. /**
  101818. * Listen to mouse events to control the camera.
  101819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101820. */
  101821. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101822. /**
  101823. * Defines the camera the input is attached to.
  101824. */
  101825. camera: FlyCamera;
  101826. /**
  101827. * Defines if touch is enabled. (Default is true.)
  101828. */
  101829. touchEnabled: boolean;
  101830. /**
  101831. * Defines the buttons associated with the input to handle camera rotation.
  101832. */
  101833. buttons: number[];
  101834. /**
  101835. * Assign buttons for Yaw control.
  101836. */
  101837. buttonsYaw: number[];
  101838. /**
  101839. * Assign buttons for Pitch control.
  101840. */
  101841. buttonsPitch: number[];
  101842. /**
  101843. * Assign buttons for Roll control.
  101844. */
  101845. buttonsRoll: number[];
  101846. /**
  101847. * Detect if any button is being pressed while mouse is moved.
  101848. * -1 = Mouse locked.
  101849. * 0 = Left button.
  101850. * 1 = Middle Button.
  101851. * 2 = Right Button.
  101852. */
  101853. activeButton: number;
  101854. /**
  101855. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101856. * Higher values reduce its sensitivity.
  101857. */
  101858. angularSensibility: number;
  101859. private _mousemoveCallback;
  101860. private _observer;
  101861. private _rollObserver;
  101862. private previousPosition;
  101863. private noPreventDefault;
  101864. private element;
  101865. /**
  101866. * Listen to mouse events to control the camera.
  101867. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101869. */
  101870. constructor(touchEnabled?: boolean);
  101871. /**
  101872. * Attach the mouse control to the HTML DOM element.
  101873. * @param element Defines the element that listens to the input events.
  101874. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101875. */
  101876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101877. /**
  101878. * Detach the current controls from the specified dom element.
  101879. * @param element Defines the element to stop listening the inputs from
  101880. */
  101881. detachControl(element: Nullable<HTMLElement>): void;
  101882. /**
  101883. * Gets the class name of the current input.
  101884. * @returns the class name.
  101885. */
  101886. getClassName(): string;
  101887. /**
  101888. * Get the friendly name associated with the input class.
  101889. * @returns the input's friendly name.
  101890. */
  101891. getSimpleName(): string;
  101892. private _pointerInput;
  101893. private _onMouseMove;
  101894. /**
  101895. * Rotate camera by mouse offset.
  101896. */
  101897. private rotateCamera;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * Default Inputs manager for the FlyCamera.
  101903. * It groups all the default supported inputs for ease of use.
  101904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101905. */
  101906. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101907. /**
  101908. * Instantiates a new FlyCameraInputsManager.
  101909. * @param camera Defines the camera the inputs belong to.
  101910. */
  101911. constructor(camera: FlyCamera);
  101912. /**
  101913. * Add keyboard input support to the input manager.
  101914. * @returns the new FlyCameraKeyboardMoveInput().
  101915. */
  101916. addKeyboard(): FlyCameraInputsManager;
  101917. /**
  101918. * Add mouse input support to the input manager.
  101919. * @param touchEnabled Enable touch screen support.
  101920. * @returns the new FlyCameraMouseInput().
  101921. */
  101922. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101923. }
  101924. }
  101925. declare module BABYLON {
  101926. /**
  101927. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101928. * such as in a 3D Space Shooter or a Flight Simulator.
  101929. */
  101930. export class FlyCamera extends TargetCamera {
  101931. /**
  101932. * Define the collision ellipsoid of the camera.
  101933. * This is helpful for simulating a camera body, like a player's body.
  101934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101935. */
  101936. ellipsoid: Vector3;
  101937. /**
  101938. * Define an offset for the position of the ellipsoid around the camera.
  101939. * This can be helpful if the camera is attached away from the player's body center,
  101940. * such as at its head.
  101941. */
  101942. ellipsoidOffset: Vector3;
  101943. /**
  101944. * Enable or disable collisions of the camera with the rest of the scene objects.
  101945. */
  101946. checkCollisions: boolean;
  101947. /**
  101948. * Enable or disable gravity on the camera.
  101949. */
  101950. applyGravity: boolean;
  101951. /**
  101952. * Define the current direction the camera is moving to.
  101953. */
  101954. cameraDirection: Vector3;
  101955. /**
  101956. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101957. * This overrides and empties cameraRotation.
  101958. */
  101959. rotationQuaternion: Quaternion;
  101960. /**
  101961. * Track Roll to maintain the wanted Rolling when looking around.
  101962. */
  101963. _trackRoll: number;
  101964. /**
  101965. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101966. */
  101967. rollCorrect: number;
  101968. /**
  101969. * Mimic a banked turn, Rolling the camera when Yawing.
  101970. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101971. */
  101972. bankedTurn: boolean;
  101973. /**
  101974. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101975. */
  101976. bankedTurnLimit: number;
  101977. /**
  101978. * Value of 0 disables the banked Roll.
  101979. * Value of 1 is equal to the Yaw angle in radians.
  101980. */
  101981. bankedTurnMultiplier: number;
  101982. /**
  101983. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101984. */
  101985. inputs: FlyCameraInputsManager;
  101986. /**
  101987. * Gets the input sensibility for mouse input.
  101988. * Higher values reduce sensitivity.
  101989. */
  101990. /**
  101991. * Sets the input sensibility for a mouse input.
  101992. * Higher values reduce sensitivity.
  101993. */
  101994. angularSensibility: number;
  101995. /**
  101996. * Get the keys for camera movement forward.
  101997. */
  101998. /**
  101999. * Set the keys for camera movement forward.
  102000. */
  102001. keysForward: number[];
  102002. /**
  102003. * Get the keys for camera movement backward.
  102004. */
  102005. keysBackward: number[];
  102006. /**
  102007. * Get the keys for camera movement up.
  102008. */
  102009. /**
  102010. * Set the keys for camera movement up.
  102011. */
  102012. keysUp: number[];
  102013. /**
  102014. * Get the keys for camera movement down.
  102015. */
  102016. /**
  102017. * Set the keys for camera movement down.
  102018. */
  102019. keysDown: number[];
  102020. /**
  102021. * Get the keys for camera movement left.
  102022. */
  102023. /**
  102024. * Set the keys for camera movement left.
  102025. */
  102026. keysLeft: number[];
  102027. /**
  102028. * Set the keys for camera movement right.
  102029. */
  102030. /**
  102031. * Set the keys for camera movement right.
  102032. */
  102033. keysRight: number[];
  102034. /**
  102035. * Event raised when the camera collides with a mesh in the scene.
  102036. */
  102037. onCollide: (collidedMesh: AbstractMesh) => void;
  102038. private _collider;
  102039. private _needMoveForGravity;
  102040. private _oldPosition;
  102041. private _diffPosition;
  102042. private _newPosition;
  102043. /** @hidden */
  102044. _localDirection: Vector3;
  102045. /** @hidden */
  102046. _transformedDirection: Vector3;
  102047. /**
  102048. * Instantiates a FlyCamera.
  102049. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102050. * such as in a 3D Space Shooter or a Flight Simulator.
  102051. * @param name Define the name of the camera in the scene.
  102052. * @param position Define the starting position of the camera in the scene.
  102053. * @param scene Define the scene the camera belongs to.
  102054. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102055. */
  102056. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102057. /**
  102058. * Attach a control to the HTML DOM element.
  102059. * @param element Defines the element that listens to the input events.
  102060. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102061. */
  102062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102063. /**
  102064. * Detach a control from the HTML DOM element.
  102065. * The camera will stop reacting to that input.
  102066. * @param element Defines the element that listens to the input events.
  102067. */
  102068. detachControl(element: HTMLElement): void;
  102069. private _collisionMask;
  102070. /**
  102071. * Get the mask that the camera ignores in collision events.
  102072. */
  102073. /**
  102074. * Set the mask that the camera ignores in collision events.
  102075. */
  102076. collisionMask: number;
  102077. /** @hidden */
  102078. _collideWithWorld(displacement: Vector3): void;
  102079. /** @hidden */
  102080. private _onCollisionPositionChange;
  102081. /** @hidden */
  102082. _checkInputs(): void;
  102083. /** @hidden */
  102084. _decideIfNeedsToMove(): boolean;
  102085. /** @hidden */
  102086. _updatePosition(): void;
  102087. /**
  102088. * Restore the Roll to its target value at the rate specified.
  102089. * @param rate - Higher means slower restoring.
  102090. * @hidden
  102091. */
  102092. restoreRoll(rate: number): void;
  102093. /**
  102094. * Destroy the camera and release the current resources held by it.
  102095. */
  102096. dispose(): void;
  102097. /**
  102098. * Get the current object class name.
  102099. * @returns the class name.
  102100. */
  102101. getClassName(): string;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /**
  102106. * Listen to keyboard events to control the camera.
  102107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102108. */
  102109. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102110. /**
  102111. * Defines the camera the input is attached to.
  102112. */
  102113. camera: FlyCamera;
  102114. /**
  102115. * The list of keyboard keys used to control the forward move of the camera.
  102116. */
  102117. keysForward: number[];
  102118. /**
  102119. * The list of keyboard keys used to control the backward move of the camera.
  102120. */
  102121. keysBackward: number[];
  102122. /**
  102123. * The list of keyboard keys used to control the forward move of the camera.
  102124. */
  102125. keysUp: number[];
  102126. /**
  102127. * The list of keyboard keys used to control the backward move of the camera.
  102128. */
  102129. keysDown: number[];
  102130. /**
  102131. * The list of keyboard keys used to control the right strafe move of the camera.
  102132. */
  102133. keysRight: number[];
  102134. /**
  102135. * The list of keyboard keys used to control the left strafe move of the camera.
  102136. */
  102137. keysLeft: number[];
  102138. private _keys;
  102139. private _onCanvasBlurObserver;
  102140. private _onKeyboardObserver;
  102141. private _engine;
  102142. private _scene;
  102143. /**
  102144. * Attach the input controls to a specific dom element to get the input from.
  102145. * @param element Defines the element the controls should be listened from
  102146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102147. */
  102148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102149. /**
  102150. * Detach the current controls from the specified dom element.
  102151. * @param element Defines the element to stop listening the inputs from
  102152. */
  102153. detachControl(element: Nullable<HTMLElement>): void;
  102154. /**
  102155. * Gets the class name of the current intput.
  102156. * @returns the class name
  102157. */
  102158. getClassName(): string;
  102159. /** @hidden */
  102160. _onLostFocus(e: FocusEvent): void;
  102161. /**
  102162. * Get the friendly name associated with the input class.
  102163. * @returns the input friendly name
  102164. */
  102165. getSimpleName(): string;
  102166. /**
  102167. * Update the current camera state depending on the inputs that have been used this frame.
  102168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102169. */
  102170. checkInputs(): void;
  102171. }
  102172. }
  102173. declare module BABYLON {
  102174. /**
  102175. * Manage the mouse wheel inputs to control a follow camera.
  102176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102177. */
  102178. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102179. /**
  102180. * Defines the camera the input is attached to.
  102181. */
  102182. camera: FollowCamera;
  102183. /**
  102184. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102185. */
  102186. axisControlRadius: boolean;
  102187. /**
  102188. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102189. */
  102190. axisControlHeight: boolean;
  102191. /**
  102192. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102193. */
  102194. axisControlRotation: boolean;
  102195. /**
  102196. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102197. * relation to mouseWheel events.
  102198. */
  102199. wheelPrecision: number;
  102200. /**
  102201. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102202. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102203. */
  102204. wheelDeltaPercentage: number;
  102205. private _wheel;
  102206. private _observer;
  102207. /**
  102208. * Attach the input controls to a specific dom element to get the input from.
  102209. * @param element Defines the element the controls should be listened from
  102210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102211. */
  102212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102213. /**
  102214. * Detach the current controls from the specified dom element.
  102215. * @param element Defines the element to stop listening the inputs from
  102216. */
  102217. detachControl(element: Nullable<HTMLElement>): void;
  102218. /**
  102219. * Gets the class name of the current intput.
  102220. * @returns the class name
  102221. */
  102222. getClassName(): string;
  102223. /**
  102224. * Get the friendly name associated with the input class.
  102225. * @returns the input friendly name
  102226. */
  102227. getSimpleName(): string;
  102228. }
  102229. }
  102230. declare module BABYLON {
  102231. /**
  102232. * Manage the pointers inputs to control an follow camera.
  102233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102234. */
  102235. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102236. /**
  102237. * Defines the camera the input is attached to.
  102238. */
  102239. camera: FollowCamera;
  102240. /**
  102241. * Gets the class name of the current input.
  102242. * @returns the class name
  102243. */
  102244. getClassName(): string;
  102245. /**
  102246. * Defines the pointer angular sensibility along the X axis or how fast is
  102247. * the camera rotating.
  102248. * A negative number will reverse the axis direction.
  102249. */
  102250. angularSensibilityX: number;
  102251. /**
  102252. * Defines the pointer angular sensibility along the Y axis or how fast is
  102253. * the camera rotating.
  102254. * A negative number will reverse the axis direction.
  102255. */
  102256. angularSensibilityY: number;
  102257. /**
  102258. * Defines the pointer pinch precision or how fast is the camera zooming.
  102259. * A negative number will reverse the axis direction.
  102260. */
  102261. pinchPrecision: number;
  102262. /**
  102263. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102264. * from 0.
  102265. * It defines the percentage of current camera.radius to use as delta when
  102266. * pinch zoom is used.
  102267. */
  102268. pinchDeltaPercentage: number;
  102269. /**
  102270. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102271. */
  102272. axisXControlRadius: boolean;
  102273. /**
  102274. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102275. */
  102276. axisXControlHeight: boolean;
  102277. /**
  102278. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102279. */
  102280. axisXControlRotation: boolean;
  102281. /**
  102282. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102283. */
  102284. axisYControlRadius: boolean;
  102285. /**
  102286. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102287. */
  102288. axisYControlHeight: boolean;
  102289. /**
  102290. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102291. */
  102292. axisYControlRotation: boolean;
  102293. /**
  102294. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102295. */
  102296. axisPinchControlRadius: boolean;
  102297. /**
  102298. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102299. */
  102300. axisPinchControlHeight: boolean;
  102301. /**
  102302. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102303. */
  102304. axisPinchControlRotation: boolean;
  102305. /**
  102306. * Log error messages if basic misconfiguration has occurred.
  102307. */
  102308. warningEnable: boolean;
  102309. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102310. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102311. private _warningCounter;
  102312. private _warning;
  102313. }
  102314. }
  102315. declare module BABYLON {
  102316. /**
  102317. * Default Inputs manager for the FollowCamera.
  102318. * It groups all the default supported inputs for ease of use.
  102319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102320. */
  102321. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102322. /**
  102323. * Instantiates a new FollowCameraInputsManager.
  102324. * @param camera Defines the camera the inputs belong to
  102325. */
  102326. constructor(camera: FollowCamera);
  102327. /**
  102328. * Add keyboard input support to the input manager.
  102329. * @returns the current input manager
  102330. */
  102331. addKeyboard(): FollowCameraInputsManager;
  102332. /**
  102333. * Add mouse wheel input support to the input manager.
  102334. * @returns the current input manager
  102335. */
  102336. addMouseWheel(): FollowCameraInputsManager;
  102337. /**
  102338. * Add pointers input support to the input manager.
  102339. * @returns the current input manager
  102340. */
  102341. addPointers(): FollowCameraInputsManager;
  102342. /**
  102343. * Add orientation input support to the input manager.
  102344. * @returns the current input manager
  102345. */
  102346. addVRDeviceOrientation(): FollowCameraInputsManager;
  102347. }
  102348. }
  102349. declare module BABYLON {
  102350. /**
  102351. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102352. * an arc rotate version arcFollowCamera are available.
  102353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102354. */
  102355. export class FollowCamera extends TargetCamera {
  102356. /**
  102357. * Distance the follow camera should follow an object at
  102358. */
  102359. radius: number;
  102360. /**
  102361. * Minimum allowed distance of the camera to the axis of rotation
  102362. * (The camera can not get closer).
  102363. * This can help limiting how the Camera is able to move in the scene.
  102364. */
  102365. lowerRadiusLimit: Nullable<number>;
  102366. /**
  102367. * Maximum allowed distance of the camera to the axis of rotation
  102368. * (The camera can not get further).
  102369. * This can help limiting how the Camera is able to move in the scene.
  102370. */
  102371. upperRadiusLimit: Nullable<number>;
  102372. /**
  102373. * Define a rotation offset between the camera and the object it follows
  102374. */
  102375. rotationOffset: number;
  102376. /**
  102377. * Minimum allowed angle to camera position relative to target object.
  102378. * This can help limiting how the Camera is able to move in the scene.
  102379. */
  102380. lowerRotationOffsetLimit: Nullable<number>;
  102381. /**
  102382. * Maximum allowed angle to camera position relative to target object.
  102383. * This can help limiting how the Camera is able to move in the scene.
  102384. */
  102385. upperRotationOffsetLimit: Nullable<number>;
  102386. /**
  102387. * Define a height offset between the camera and the object it follows.
  102388. * It can help following an object from the top (like a car chaing a plane)
  102389. */
  102390. heightOffset: number;
  102391. /**
  102392. * Minimum allowed height of camera position relative to target object.
  102393. * This can help limiting how the Camera is able to move in the scene.
  102394. */
  102395. lowerHeightOffsetLimit: Nullable<number>;
  102396. /**
  102397. * Maximum allowed height of camera position relative to target object.
  102398. * This can help limiting how the Camera is able to move in the scene.
  102399. */
  102400. upperHeightOffsetLimit: Nullable<number>;
  102401. /**
  102402. * Define how fast the camera can accelerate to follow it s target.
  102403. */
  102404. cameraAcceleration: number;
  102405. /**
  102406. * Define the speed limit of the camera following an object.
  102407. */
  102408. maxCameraSpeed: number;
  102409. /**
  102410. * Define the target of the camera.
  102411. */
  102412. lockedTarget: Nullable<AbstractMesh>;
  102413. /**
  102414. * Defines the input associated with the camera.
  102415. */
  102416. inputs: FollowCameraInputsManager;
  102417. /**
  102418. * Instantiates the follow camera.
  102419. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102420. * @param name Define the name of the camera in the scene
  102421. * @param position Define the position of the camera
  102422. * @param scene Define the scene the camera belong to
  102423. * @param lockedTarget Define the target of the camera
  102424. */
  102425. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102426. private _follow;
  102427. /**
  102428. * Attached controls to the current camera.
  102429. * @param element Defines the element the controls should be listened from
  102430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102431. */
  102432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102433. /**
  102434. * Detach the current controls from the camera.
  102435. * The camera will stop reacting to inputs.
  102436. * @param element Defines the element to stop listening the inputs from
  102437. */
  102438. detachControl(element: HTMLElement): void;
  102439. /** @hidden */
  102440. _checkInputs(): void;
  102441. private _checkLimits;
  102442. /**
  102443. * Gets the camera class name.
  102444. * @returns the class name
  102445. */
  102446. getClassName(): string;
  102447. }
  102448. /**
  102449. * Arc Rotate version of the follow camera.
  102450. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102451. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102452. */
  102453. export class ArcFollowCamera extends TargetCamera {
  102454. /** The longitudinal angle of the camera */
  102455. alpha: number;
  102456. /** The latitudinal angle of the camera */
  102457. beta: number;
  102458. /** The radius of the camera from its target */
  102459. radius: number;
  102460. /** Define the camera target (the messh it should follow) */
  102461. target: Nullable<AbstractMesh>;
  102462. private _cartesianCoordinates;
  102463. /**
  102464. * Instantiates a new ArcFollowCamera
  102465. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102466. * @param name Define the name of the camera
  102467. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102468. * @param beta Define the rotation angle of the camera around the elevation axis
  102469. * @param radius Define the radius of the camera from its target point
  102470. * @param target Define the target of the camera
  102471. * @param scene Define the scene the camera belongs to
  102472. */
  102473. constructor(name: string,
  102474. /** The longitudinal angle of the camera */
  102475. alpha: number,
  102476. /** The latitudinal angle of the camera */
  102477. beta: number,
  102478. /** The radius of the camera from its target */
  102479. radius: number,
  102480. /** Define the camera target (the messh it should follow) */
  102481. target: Nullable<AbstractMesh>, scene: Scene);
  102482. private _follow;
  102483. /** @hidden */
  102484. _checkInputs(): void;
  102485. /**
  102486. * Returns the class name of the object.
  102487. * It is mostly used internally for serialization purposes.
  102488. */
  102489. getClassName(): string;
  102490. }
  102491. }
  102492. declare module BABYLON {
  102493. /**
  102494. * Manage the keyboard inputs to control the movement of a follow camera.
  102495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102496. */
  102497. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102498. /**
  102499. * Defines the camera the input is attached to.
  102500. */
  102501. camera: FollowCamera;
  102502. /**
  102503. * Defines the list of key codes associated with the up action (increase heightOffset)
  102504. */
  102505. keysHeightOffsetIncr: number[];
  102506. /**
  102507. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102508. */
  102509. keysHeightOffsetDecr: number[];
  102510. /**
  102511. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102512. */
  102513. keysHeightOffsetModifierAlt: boolean;
  102514. /**
  102515. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102516. */
  102517. keysHeightOffsetModifierCtrl: boolean;
  102518. /**
  102519. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102520. */
  102521. keysHeightOffsetModifierShift: boolean;
  102522. /**
  102523. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102524. */
  102525. keysRotationOffsetIncr: number[];
  102526. /**
  102527. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102528. */
  102529. keysRotationOffsetDecr: number[];
  102530. /**
  102531. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102532. */
  102533. keysRotationOffsetModifierAlt: boolean;
  102534. /**
  102535. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102536. */
  102537. keysRotationOffsetModifierCtrl: boolean;
  102538. /**
  102539. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102540. */
  102541. keysRotationOffsetModifierShift: boolean;
  102542. /**
  102543. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102544. */
  102545. keysRadiusIncr: number[];
  102546. /**
  102547. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102548. */
  102549. keysRadiusDecr: number[];
  102550. /**
  102551. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102552. */
  102553. keysRadiusModifierAlt: boolean;
  102554. /**
  102555. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102556. */
  102557. keysRadiusModifierCtrl: boolean;
  102558. /**
  102559. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102560. */
  102561. keysRadiusModifierShift: boolean;
  102562. /**
  102563. * Defines the rate of change of heightOffset.
  102564. */
  102565. heightSensibility: number;
  102566. /**
  102567. * Defines the rate of change of rotationOffset.
  102568. */
  102569. rotationSensibility: number;
  102570. /**
  102571. * Defines the rate of change of radius.
  102572. */
  102573. radiusSensibility: number;
  102574. private _keys;
  102575. private _ctrlPressed;
  102576. private _altPressed;
  102577. private _shiftPressed;
  102578. private _onCanvasBlurObserver;
  102579. private _onKeyboardObserver;
  102580. private _engine;
  102581. private _scene;
  102582. /**
  102583. * Attach the input controls to a specific dom element to get the input from.
  102584. * @param element Defines the element the controls should be listened from
  102585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102586. */
  102587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102588. /**
  102589. * Detach the current controls from the specified dom element.
  102590. * @param element Defines the element to stop listening the inputs from
  102591. */
  102592. detachControl(element: Nullable<HTMLElement>): void;
  102593. /**
  102594. * Update the current camera state depending on the inputs that have been used this frame.
  102595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102596. */
  102597. checkInputs(): void;
  102598. /**
  102599. * Gets the class name of the current input.
  102600. * @returns the class name
  102601. */
  102602. getClassName(): string;
  102603. /**
  102604. * Get the friendly name associated with the input class.
  102605. * @returns the input friendly name
  102606. */
  102607. getSimpleName(): string;
  102608. /**
  102609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102610. * allow modification of the heightOffset value.
  102611. */
  102612. private _modifierHeightOffset;
  102613. /**
  102614. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102615. * allow modification of the rotationOffset value.
  102616. */
  102617. private _modifierRotationOffset;
  102618. /**
  102619. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102620. * allow modification of the radius value.
  102621. */
  102622. private _modifierRadius;
  102623. }
  102624. }
  102625. declare module BABYLON {
  102626. interface FreeCameraInputsManager {
  102627. /**
  102628. * @hidden
  102629. */
  102630. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102631. /**
  102632. * Add orientation input support to the input manager.
  102633. * @returns the current input manager
  102634. */
  102635. addDeviceOrientation(): FreeCameraInputsManager;
  102636. }
  102637. /**
  102638. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102639. * Screen rotation is taken into account.
  102640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102641. */
  102642. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102643. private _camera;
  102644. private _screenOrientationAngle;
  102645. private _constantTranform;
  102646. private _screenQuaternion;
  102647. private _alpha;
  102648. private _beta;
  102649. private _gamma;
  102650. /**
  102651. * Can be used to detect if a device orientation sensor is availible on a device
  102652. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102653. * @returns a promise that will resolve on orientation change
  102654. */
  102655. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102656. /**
  102657. * @hidden
  102658. */
  102659. _onDeviceOrientationChangedObservable: Observable<void>;
  102660. /**
  102661. * Instantiates a new input
  102662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102663. */
  102664. constructor();
  102665. /**
  102666. * Define the camera controlled by the input.
  102667. */
  102668. camera: FreeCamera;
  102669. /**
  102670. * Attach the input controls to a specific dom element to get the input from.
  102671. * @param element Defines the element the controls should be listened from
  102672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102673. */
  102674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102675. private _orientationChanged;
  102676. private _deviceOrientation;
  102677. /**
  102678. * Detach the current controls from the specified dom element.
  102679. * @param element Defines the element to stop listening the inputs from
  102680. */
  102681. detachControl(element: Nullable<HTMLElement>): void;
  102682. /**
  102683. * Update the current camera state depending on the inputs that have been used this frame.
  102684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102685. */
  102686. checkInputs(): void;
  102687. /**
  102688. * Gets the class name of the current intput.
  102689. * @returns the class name
  102690. */
  102691. getClassName(): string;
  102692. /**
  102693. * Get the friendly name associated with the input class.
  102694. * @returns the input friendly name
  102695. */
  102696. getSimpleName(): string;
  102697. }
  102698. }
  102699. declare module BABYLON {
  102700. /**
  102701. * Manage the gamepad inputs to control a free camera.
  102702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102703. */
  102704. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102705. /**
  102706. * Define the camera the input is attached to.
  102707. */
  102708. camera: FreeCamera;
  102709. /**
  102710. * Define the Gamepad controlling the input
  102711. */
  102712. gamepad: Nullable<Gamepad>;
  102713. /**
  102714. * Defines the gamepad rotation sensiblity.
  102715. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102716. */
  102717. gamepadAngularSensibility: number;
  102718. /**
  102719. * Defines the gamepad move sensiblity.
  102720. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102721. */
  102722. gamepadMoveSensibility: number;
  102723. private _onGamepadConnectedObserver;
  102724. private _onGamepadDisconnectedObserver;
  102725. private _cameraTransform;
  102726. private _deltaTransform;
  102727. private _vector3;
  102728. private _vector2;
  102729. /**
  102730. * Attach the input controls to a specific dom element to get the input from.
  102731. * @param element Defines the element the controls should be listened from
  102732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102733. */
  102734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102735. /**
  102736. * Detach the current controls from the specified dom element.
  102737. * @param element Defines the element to stop listening the inputs from
  102738. */
  102739. detachControl(element: Nullable<HTMLElement>): void;
  102740. /**
  102741. * Update the current camera state depending on the inputs that have been used this frame.
  102742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102743. */
  102744. checkInputs(): void;
  102745. /**
  102746. * Gets the class name of the current intput.
  102747. * @returns the class name
  102748. */
  102749. getClassName(): string;
  102750. /**
  102751. * Get the friendly name associated with the input class.
  102752. * @returns the input friendly name
  102753. */
  102754. getSimpleName(): string;
  102755. }
  102756. }
  102757. declare module BABYLON {
  102758. /**
  102759. * Defines the potential axis of a Joystick
  102760. */
  102761. export enum JoystickAxis {
  102762. /** X axis */
  102763. X = 0,
  102764. /** Y axis */
  102765. Y = 1,
  102766. /** Z axis */
  102767. Z = 2
  102768. }
  102769. /**
  102770. * Class used to define virtual joystick (used in touch mode)
  102771. */
  102772. export class VirtualJoystick {
  102773. /**
  102774. * Gets or sets a boolean indicating that left and right values must be inverted
  102775. */
  102776. reverseLeftRight: boolean;
  102777. /**
  102778. * Gets or sets a boolean indicating that up and down values must be inverted
  102779. */
  102780. reverseUpDown: boolean;
  102781. /**
  102782. * Gets the offset value for the position (ie. the change of the position value)
  102783. */
  102784. deltaPosition: Vector3;
  102785. /**
  102786. * Gets a boolean indicating if the virtual joystick was pressed
  102787. */
  102788. pressed: boolean;
  102789. /**
  102790. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102791. */
  102792. static Canvas: Nullable<HTMLCanvasElement>;
  102793. private static _globalJoystickIndex;
  102794. private static vjCanvasContext;
  102795. private static vjCanvasWidth;
  102796. private static vjCanvasHeight;
  102797. private static halfWidth;
  102798. private _action;
  102799. private _axisTargetedByLeftAndRight;
  102800. private _axisTargetedByUpAndDown;
  102801. private _joystickSensibility;
  102802. private _inversedSensibility;
  102803. private _joystickPointerID;
  102804. private _joystickColor;
  102805. private _joystickPointerPos;
  102806. private _joystickPreviousPointerPos;
  102807. private _joystickPointerStartPos;
  102808. private _deltaJoystickVector;
  102809. private _leftJoystick;
  102810. private _touches;
  102811. private _onPointerDownHandlerRef;
  102812. private _onPointerMoveHandlerRef;
  102813. private _onPointerUpHandlerRef;
  102814. private _onResize;
  102815. /**
  102816. * Creates a new virtual joystick
  102817. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102818. */
  102819. constructor(leftJoystick?: boolean);
  102820. /**
  102821. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102822. * @param newJoystickSensibility defines the new sensibility
  102823. */
  102824. setJoystickSensibility(newJoystickSensibility: number): void;
  102825. private _onPointerDown;
  102826. private _onPointerMove;
  102827. private _onPointerUp;
  102828. /**
  102829. * Change the color of the virtual joystick
  102830. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102831. */
  102832. setJoystickColor(newColor: string): void;
  102833. /**
  102834. * Defines a callback to call when the joystick is touched
  102835. * @param action defines the callback
  102836. */
  102837. setActionOnTouch(action: () => any): void;
  102838. /**
  102839. * Defines which axis you'd like to control for left & right
  102840. * @param axis defines the axis to use
  102841. */
  102842. setAxisForLeftRight(axis: JoystickAxis): void;
  102843. /**
  102844. * Defines which axis you'd like to control for up & down
  102845. * @param axis defines the axis to use
  102846. */
  102847. setAxisForUpDown(axis: JoystickAxis): void;
  102848. private _drawVirtualJoystick;
  102849. /**
  102850. * Release internal HTML canvas
  102851. */
  102852. releaseCanvas(): void;
  102853. }
  102854. }
  102855. declare module BABYLON {
  102856. interface FreeCameraInputsManager {
  102857. /**
  102858. * Add virtual joystick input support to the input manager.
  102859. * @returns the current input manager
  102860. */
  102861. addVirtualJoystick(): FreeCameraInputsManager;
  102862. }
  102863. /**
  102864. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102866. */
  102867. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102868. /**
  102869. * Defines the camera the input is attached to.
  102870. */
  102871. camera: FreeCamera;
  102872. private _leftjoystick;
  102873. private _rightjoystick;
  102874. /**
  102875. * Gets the left stick of the virtual joystick.
  102876. * @returns The virtual Joystick
  102877. */
  102878. getLeftJoystick(): VirtualJoystick;
  102879. /**
  102880. * Gets the right stick of the virtual joystick.
  102881. * @returns The virtual Joystick
  102882. */
  102883. getRightJoystick(): VirtualJoystick;
  102884. /**
  102885. * Update the current camera state depending on the inputs that have been used this frame.
  102886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102887. */
  102888. checkInputs(): void;
  102889. /**
  102890. * Attach the input controls to a specific dom element to get the input from.
  102891. * @param element Defines the element the controls should be listened from
  102892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102893. */
  102894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102895. /**
  102896. * Detach the current controls from the specified dom element.
  102897. * @param element Defines the element to stop listening the inputs from
  102898. */
  102899. detachControl(element: Nullable<HTMLElement>): void;
  102900. /**
  102901. * Gets the class name of the current intput.
  102902. * @returns the class name
  102903. */
  102904. getClassName(): string;
  102905. /**
  102906. * Get the friendly name associated with the input class.
  102907. * @returns the input friendly name
  102908. */
  102909. getSimpleName(): string;
  102910. }
  102911. }
  102912. declare module BABYLON {
  102913. /**
  102914. * This represents a FPS type of camera controlled by touch.
  102915. * This is like a universal camera minus the Gamepad controls.
  102916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102917. */
  102918. export class TouchCamera extends FreeCamera {
  102919. /**
  102920. * Defines the touch sensibility for rotation.
  102921. * The higher the faster.
  102922. */
  102923. touchAngularSensibility: number;
  102924. /**
  102925. * Defines the touch sensibility for move.
  102926. * The higher the faster.
  102927. */
  102928. touchMoveSensibility: number;
  102929. /**
  102930. * Instantiates a new touch camera.
  102931. * This represents a FPS type of camera controlled by touch.
  102932. * This is like a universal camera minus the Gamepad controls.
  102933. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102934. * @param name Define the name of the camera in the scene
  102935. * @param position Define the start position of the camera in the scene
  102936. * @param scene Define the scene the camera belongs to
  102937. */
  102938. constructor(name: string, position: Vector3, scene: Scene);
  102939. /**
  102940. * Gets the current object class name.
  102941. * @return the class name
  102942. */
  102943. getClassName(): string;
  102944. /** @hidden */
  102945. _setupInputs(): void;
  102946. }
  102947. }
  102948. declare module BABYLON {
  102949. /**
  102950. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102951. * being tilted forward or back and left or right.
  102952. */
  102953. export class DeviceOrientationCamera extends FreeCamera {
  102954. private _initialQuaternion;
  102955. private _quaternionCache;
  102956. private _tmpDragQuaternion;
  102957. private _disablePointerInputWhenUsingDeviceOrientation;
  102958. /**
  102959. * Creates a new device orientation camera
  102960. * @param name The name of the camera
  102961. * @param position The start position camera
  102962. * @param scene The scene the camera belongs to
  102963. */
  102964. constructor(name: string, position: Vector3, scene: Scene);
  102965. /**
  102966. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  102967. */
  102968. disablePointerInputWhenUsingDeviceOrientation: boolean;
  102969. private _dragFactor;
  102970. /**
  102971. * Enabled turning on the y axis when the orientation sensor is active
  102972. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102973. */
  102974. enableHorizontalDragging(dragFactor?: number): void;
  102975. /**
  102976. * Gets the current instance class name ("DeviceOrientationCamera").
  102977. * This helps avoiding instanceof at run time.
  102978. * @returns the class name
  102979. */
  102980. getClassName(): string;
  102981. /**
  102982. * @hidden
  102983. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102984. */
  102985. _checkInputs(): void;
  102986. /**
  102987. * Reset the camera to its default orientation on the specified axis only.
  102988. * @param axis The axis to reset
  102989. */
  102990. resetToCurrentRotation(axis?: Axis): void;
  102991. }
  102992. }
  102993. declare module BABYLON {
  102994. /**
  102995. * Defines supported buttons for XBox360 compatible gamepads
  102996. */
  102997. export enum Xbox360Button {
  102998. /** A */
  102999. A = 0,
  103000. /** B */
  103001. B = 1,
  103002. /** X */
  103003. X = 2,
  103004. /** Y */
  103005. Y = 3,
  103006. /** Start */
  103007. Start = 4,
  103008. /** Back */
  103009. Back = 5,
  103010. /** Left button */
  103011. LB = 6,
  103012. /** Right button */
  103013. RB = 7,
  103014. /** Left stick */
  103015. LeftStick = 8,
  103016. /** Right stick */
  103017. RightStick = 9
  103018. }
  103019. /** Defines values for XBox360 DPad */
  103020. export enum Xbox360Dpad {
  103021. /** Up */
  103022. Up = 0,
  103023. /** Down */
  103024. Down = 1,
  103025. /** Left */
  103026. Left = 2,
  103027. /** Right */
  103028. Right = 3
  103029. }
  103030. /**
  103031. * Defines a XBox360 gamepad
  103032. */
  103033. export class Xbox360Pad extends Gamepad {
  103034. private _leftTrigger;
  103035. private _rightTrigger;
  103036. private _onlefttriggerchanged;
  103037. private _onrighttriggerchanged;
  103038. private _onbuttondown;
  103039. private _onbuttonup;
  103040. private _ondpaddown;
  103041. private _ondpadup;
  103042. /** Observable raised when a button is pressed */
  103043. onButtonDownObservable: Observable<Xbox360Button>;
  103044. /** Observable raised when a button is released */
  103045. onButtonUpObservable: Observable<Xbox360Button>;
  103046. /** Observable raised when a pad is pressed */
  103047. onPadDownObservable: Observable<Xbox360Dpad>;
  103048. /** Observable raised when a pad is released */
  103049. onPadUpObservable: Observable<Xbox360Dpad>;
  103050. private _buttonA;
  103051. private _buttonB;
  103052. private _buttonX;
  103053. private _buttonY;
  103054. private _buttonBack;
  103055. private _buttonStart;
  103056. private _buttonLB;
  103057. private _buttonRB;
  103058. private _buttonLeftStick;
  103059. private _buttonRightStick;
  103060. private _dPadUp;
  103061. private _dPadDown;
  103062. private _dPadLeft;
  103063. private _dPadRight;
  103064. private _isXboxOnePad;
  103065. /**
  103066. * Creates a new XBox360 gamepad object
  103067. * @param id defines the id of this gamepad
  103068. * @param index defines its index
  103069. * @param gamepad defines the internal HTML gamepad object
  103070. * @param xboxOne defines if it is a XBox One gamepad
  103071. */
  103072. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103073. /**
  103074. * Defines the callback to call when left trigger is pressed
  103075. * @param callback defines the callback to use
  103076. */
  103077. onlefttriggerchanged(callback: (value: number) => void): void;
  103078. /**
  103079. * Defines the callback to call when right trigger is pressed
  103080. * @param callback defines the callback to use
  103081. */
  103082. onrighttriggerchanged(callback: (value: number) => void): void;
  103083. /**
  103084. * Gets the left trigger value
  103085. */
  103086. /**
  103087. * Sets the left trigger value
  103088. */
  103089. leftTrigger: number;
  103090. /**
  103091. * Gets the right trigger value
  103092. */
  103093. /**
  103094. * Sets the right trigger value
  103095. */
  103096. rightTrigger: number;
  103097. /**
  103098. * Defines the callback to call when a button is pressed
  103099. * @param callback defines the callback to use
  103100. */
  103101. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103102. /**
  103103. * Defines the callback to call when a button is released
  103104. * @param callback defines the callback to use
  103105. */
  103106. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103107. /**
  103108. * Defines the callback to call when a pad is pressed
  103109. * @param callback defines the callback to use
  103110. */
  103111. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103112. /**
  103113. * Defines the callback to call when a pad is released
  103114. * @param callback defines the callback to use
  103115. */
  103116. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  103117. private _setButtonValue;
  103118. private _setDPadValue;
  103119. /**
  103120. * Gets the value of the `A` button
  103121. */
  103122. /**
  103123. * Sets the value of the `A` button
  103124. */
  103125. buttonA: number;
  103126. /**
  103127. * Gets the value of the `B` button
  103128. */
  103129. /**
  103130. * Sets the value of the `B` button
  103131. */
  103132. buttonB: number;
  103133. /**
  103134. * Gets the value of the `X` button
  103135. */
  103136. /**
  103137. * Sets the value of the `X` button
  103138. */
  103139. buttonX: number;
  103140. /**
  103141. * Gets the value of the `Y` button
  103142. */
  103143. /**
  103144. * Sets the value of the `Y` button
  103145. */
  103146. buttonY: number;
  103147. /**
  103148. * Gets the value of the `Start` button
  103149. */
  103150. /**
  103151. * Sets the value of the `Start` button
  103152. */
  103153. buttonStart: number;
  103154. /**
  103155. * Gets the value of the `Back` button
  103156. */
  103157. /**
  103158. * Sets the value of the `Back` button
  103159. */
  103160. buttonBack: number;
  103161. /**
  103162. * Gets the value of the `Left` button
  103163. */
  103164. /**
  103165. * Sets the value of the `Left` button
  103166. */
  103167. buttonLB: number;
  103168. /**
  103169. * Gets the value of the `Right` button
  103170. */
  103171. /**
  103172. * Sets the value of the `Right` button
  103173. */
  103174. buttonRB: number;
  103175. /**
  103176. * Gets the value of the Left joystick
  103177. */
  103178. /**
  103179. * Sets the value of the Left joystick
  103180. */
  103181. buttonLeftStick: number;
  103182. /**
  103183. * Gets the value of the Right joystick
  103184. */
  103185. /**
  103186. * Sets the value of the Right joystick
  103187. */
  103188. buttonRightStick: number;
  103189. /**
  103190. * Gets the value of D-pad up
  103191. */
  103192. /**
  103193. * Sets the value of D-pad up
  103194. */
  103195. dPadUp: number;
  103196. /**
  103197. * Gets the value of D-pad down
  103198. */
  103199. /**
  103200. * Sets the value of D-pad down
  103201. */
  103202. dPadDown: number;
  103203. /**
  103204. * Gets the value of D-pad left
  103205. */
  103206. /**
  103207. * Sets the value of D-pad left
  103208. */
  103209. dPadLeft: number;
  103210. /**
  103211. * Gets the value of D-pad right
  103212. */
  103213. /**
  103214. * Sets the value of D-pad right
  103215. */
  103216. dPadRight: number;
  103217. /**
  103218. * Force the gamepad to synchronize with device values
  103219. */
  103220. update(): void;
  103221. /**
  103222. * Disposes the gamepad
  103223. */
  103224. dispose(): void;
  103225. }
  103226. }
  103227. declare module BABYLON {
  103228. /**
  103229. * Defines supported buttons for DualShock compatible gamepads
  103230. */
  103231. export enum DualShockButton {
  103232. /** Cross */
  103233. Cross = 0,
  103234. /** Circle */
  103235. Circle = 1,
  103236. /** Square */
  103237. Square = 2,
  103238. /** Triangle */
  103239. Triangle = 3,
  103240. /** Options */
  103241. Options = 4,
  103242. /** Share */
  103243. Share = 5,
  103244. /** L1 */
  103245. L1 = 6,
  103246. /** R1 */
  103247. R1 = 7,
  103248. /** Left stick */
  103249. LeftStick = 8,
  103250. /** Right stick */
  103251. RightStick = 9
  103252. }
  103253. /** Defines values for DualShock DPad */
  103254. export enum DualShockDpad {
  103255. /** Up */
  103256. Up = 0,
  103257. /** Down */
  103258. Down = 1,
  103259. /** Left */
  103260. Left = 2,
  103261. /** Right */
  103262. Right = 3
  103263. }
  103264. /**
  103265. * Defines a DualShock gamepad
  103266. */
  103267. export class DualShockPad extends Gamepad {
  103268. private _leftTrigger;
  103269. private _rightTrigger;
  103270. private _onlefttriggerchanged;
  103271. private _onrighttriggerchanged;
  103272. private _onbuttondown;
  103273. private _onbuttonup;
  103274. private _ondpaddown;
  103275. private _ondpadup;
  103276. /** Observable raised when a button is pressed */
  103277. onButtonDownObservable: Observable<DualShockButton>;
  103278. /** Observable raised when a button is released */
  103279. onButtonUpObservable: Observable<DualShockButton>;
  103280. /** Observable raised when a pad is pressed */
  103281. onPadDownObservable: Observable<DualShockDpad>;
  103282. /** Observable raised when a pad is released */
  103283. onPadUpObservable: Observable<DualShockDpad>;
  103284. private _buttonCross;
  103285. private _buttonCircle;
  103286. private _buttonSquare;
  103287. private _buttonTriangle;
  103288. private _buttonShare;
  103289. private _buttonOptions;
  103290. private _buttonL1;
  103291. private _buttonR1;
  103292. private _buttonLeftStick;
  103293. private _buttonRightStick;
  103294. private _dPadUp;
  103295. private _dPadDown;
  103296. private _dPadLeft;
  103297. private _dPadRight;
  103298. /**
  103299. * Creates a new DualShock gamepad object
  103300. * @param id defines the id of this gamepad
  103301. * @param index defines its index
  103302. * @param gamepad defines the internal HTML gamepad object
  103303. */
  103304. constructor(id: string, index: number, gamepad: any);
  103305. /**
  103306. * Defines the callback to call when left trigger is pressed
  103307. * @param callback defines the callback to use
  103308. */
  103309. onlefttriggerchanged(callback: (value: number) => void): void;
  103310. /**
  103311. * Defines the callback to call when right trigger is pressed
  103312. * @param callback defines the callback to use
  103313. */
  103314. onrighttriggerchanged(callback: (value: number) => void): void;
  103315. /**
  103316. * Gets the left trigger value
  103317. */
  103318. /**
  103319. * Sets the left trigger value
  103320. */
  103321. leftTrigger: number;
  103322. /**
  103323. * Gets the right trigger value
  103324. */
  103325. /**
  103326. * Sets the right trigger value
  103327. */
  103328. rightTrigger: number;
  103329. /**
  103330. * Defines the callback to call when a button is pressed
  103331. * @param callback defines the callback to use
  103332. */
  103333. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103334. /**
  103335. * Defines the callback to call when a button is released
  103336. * @param callback defines the callback to use
  103337. */
  103338. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103339. /**
  103340. * Defines the callback to call when a pad is pressed
  103341. * @param callback defines the callback to use
  103342. */
  103343. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103344. /**
  103345. * Defines the callback to call when a pad is released
  103346. * @param callback defines the callback to use
  103347. */
  103348. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103349. private _setButtonValue;
  103350. private _setDPadValue;
  103351. /**
  103352. * Gets the value of the `Cross` button
  103353. */
  103354. /**
  103355. * Sets the value of the `Cross` button
  103356. */
  103357. buttonCross: number;
  103358. /**
  103359. * Gets the value of the `Circle` button
  103360. */
  103361. /**
  103362. * Sets the value of the `Circle` button
  103363. */
  103364. buttonCircle: number;
  103365. /**
  103366. * Gets the value of the `Square` button
  103367. */
  103368. /**
  103369. * Sets the value of the `Square` button
  103370. */
  103371. buttonSquare: number;
  103372. /**
  103373. * Gets the value of the `Triangle` button
  103374. */
  103375. /**
  103376. * Sets the value of the `Triangle` button
  103377. */
  103378. buttonTriangle: number;
  103379. /**
  103380. * Gets the value of the `Options` button
  103381. */
  103382. /**
  103383. * Sets the value of the `Options` button
  103384. */
  103385. buttonOptions: number;
  103386. /**
  103387. * Gets the value of the `Share` button
  103388. */
  103389. /**
  103390. * Sets the value of the `Share` button
  103391. */
  103392. buttonShare: number;
  103393. /**
  103394. * Gets the value of the `L1` button
  103395. */
  103396. /**
  103397. * Sets the value of the `L1` button
  103398. */
  103399. buttonL1: number;
  103400. /**
  103401. * Gets the value of the `R1` button
  103402. */
  103403. /**
  103404. * Sets the value of the `R1` button
  103405. */
  103406. buttonR1: number;
  103407. /**
  103408. * Gets the value of the Left joystick
  103409. */
  103410. /**
  103411. * Sets the value of the Left joystick
  103412. */
  103413. buttonLeftStick: number;
  103414. /**
  103415. * Gets the value of the Right joystick
  103416. */
  103417. /**
  103418. * Sets the value of the Right joystick
  103419. */
  103420. buttonRightStick: number;
  103421. /**
  103422. * Gets the value of D-pad up
  103423. */
  103424. /**
  103425. * Sets the value of D-pad up
  103426. */
  103427. dPadUp: number;
  103428. /**
  103429. * Gets the value of D-pad down
  103430. */
  103431. /**
  103432. * Sets the value of D-pad down
  103433. */
  103434. dPadDown: number;
  103435. /**
  103436. * Gets the value of D-pad left
  103437. */
  103438. /**
  103439. * Sets the value of D-pad left
  103440. */
  103441. dPadLeft: number;
  103442. /**
  103443. * Gets the value of D-pad right
  103444. */
  103445. /**
  103446. * Sets the value of D-pad right
  103447. */
  103448. dPadRight: number;
  103449. /**
  103450. * Force the gamepad to synchronize with device values
  103451. */
  103452. update(): void;
  103453. /**
  103454. * Disposes the gamepad
  103455. */
  103456. dispose(): void;
  103457. }
  103458. }
  103459. declare module BABYLON {
  103460. /**
  103461. * Manager for handling gamepads
  103462. */
  103463. export class GamepadManager {
  103464. private _scene?;
  103465. private _babylonGamepads;
  103466. private _oneGamepadConnected;
  103467. /** @hidden */
  103468. _isMonitoring: boolean;
  103469. private _gamepadEventSupported;
  103470. private _gamepadSupport;
  103471. /**
  103472. * observable to be triggered when the gamepad controller has been connected
  103473. */
  103474. onGamepadConnectedObservable: Observable<Gamepad>;
  103475. /**
  103476. * observable to be triggered when the gamepad controller has been disconnected
  103477. */
  103478. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103479. private _onGamepadConnectedEvent;
  103480. private _onGamepadDisconnectedEvent;
  103481. /**
  103482. * Initializes the gamepad manager
  103483. * @param _scene BabylonJS scene
  103484. */
  103485. constructor(_scene?: Scene | undefined);
  103486. /**
  103487. * The gamepads in the game pad manager
  103488. */
  103489. readonly gamepads: Gamepad[];
  103490. /**
  103491. * Get the gamepad controllers based on type
  103492. * @param type The type of gamepad controller
  103493. * @returns Nullable gamepad
  103494. */
  103495. getGamepadByType(type?: number): Nullable<Gamepad>;
  103496. /**
  103497. * Disposes the gamepad manager
  103498. */
  103499. dispose(): void;
  103500. private _addNewGamepad;
  103501. private _startMonitoringGamepads;
  103502. private _stopMonitoringGamepads;
  103503. /** @hidden */
  103504. _checkGamepadsStatus(): void;
  103505. private _updateGamepadObjects;
  103506. }
  103507. }
  103508. declare module BABYLON {
  103509. interface Scene {
  103510. /** @hidden */
  103511. _gamepadManager: Nullable<GamepadManager>;
  103512. /**
  103513. * Gets the gamepad manager associated with the scene
  103514. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103515. */
  103516. gamepadManager: GamepadManager;
  103517. }
  103518. /**
  103519. * Interface representing a free camera inputs manager
  103520. */
  103521. interface FreeCameraInputsManager {
  103522. /**
  103523. * Adds gamepad input support to the FreeCameraInputsManager.
  103524. * @returns the FreeCameraInputsManager
  103525. */
  103526. addGamepad(): FreeCameraInputsManager;
  103527. }
  103528. /**
  103529. * Interface representing an arc rotate camera inputs manager
  103530. */
  103531. interface ArcRotateCameraInputsManager {
  103532. /**
  103533. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103534. * @returns the camera inputs manager
  103535. */
  103536. addGamepad(): ArcRotateCameraInputsManager;
  103537. }
  103538. /**
  103539. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103540. */
  103541. export class GamepadSystemSceneComponent implements ISceneComponent {
  103542. /**
  103543. * The component name helpfull to identify the component in the list of scene components.
  103544. */
  103545. readonly name: string;
  103546. /**
  103547. * The scene the component belongs to.
  103548. */
  103549. scene: Scene;
  103550. /**
  103551. * Creates a new instance of the component for the given scene
  103552. * @param scene Defines the scene to register the component in
  103553. */
  103554. constructor(scene: Scene);
  103555. /**
  103556. * Registers the component in a given scene
  103557. */
  103558. register(): void;
  103559. /**
  103560. * Rebuilds the elements related to this component in case of
  103561. * context lost for instance.
  103562. */
  103563. rebuild(): void;
  103564. /**
  103565. * Disposes the component and the associated ressources
  103566. */
  103567. dispose(): void;
  103568. private _beforeCameraUpdate;
  103569. }
  103570. }
  103571. declare module BABYLON {
  103572. /**
  103573. * 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,
  103574. * which still works and will still be found in many Playgrounds.
  103575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103576. */
  103577. export class UniversalCamera extends TouchCamera {
  103578. /**
  103579. * Defines the gamepad rotation sensiblity.
  103580. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103581. */
  103582. gamepadAngularSensibility: number;
  103583. /**
  103584. * Defines the gamepad move sensiblity.
  103585. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103586. */
  103587. gamepadMoveSensibility: number;
  103588. /**
  103589. * 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,
  103590. * which still works and will still be found in many Playgrounds.
  103591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103592. * @param name Define the name of the camera in the scene
  103593. * @param position Define the start position of the camera in the scene
  103594. * @param scene Define the scene the camera belongs to
  103595. */
  103596. constructor(name: string, position: Vector3, scene: Scene);
  103597. /**
  103598. * Gets the current object class name.
  103599. * @return the class name
  103600. */
  103601. getClassName(): string;
  103602. }
  103603. }
  103604. declare module BABYLON {
  103605. /**
  103606. * This represents a FPS type of camera. This is only here for back compat purpose.
  103607. * Please use the UniversalCamera instead as both are identical.
  103608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103609. */
  103610. export class GamepadCamera extends UniversalCamera {
  103611. /**
  103612. * Instantiates a new Gamepad Camera
  103613. * This represents a FPS type of camera. This is only here for back compat purpose.
  103614. * Please use the UniversalCamera instead as both are identical.
  103615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103616. * @param name Define the name of the camera in the scene
  103617. * @param position Define the start position of the camera in the scene
  103618. * @param scene Define the scene the camera belongs to
  103619. */
  103620. constructor(name: string, position: Vector3, scene: Scene);
  103621. /**
  103622. * Gets the current object class name.
  103623. * @return the class name
  103624. */
  103625. getClassName(): string;
  103626. }
  103627. }
  103628. declare module BABYLON {
  103629. /** @hidden */
  103630. export var passPixelShader: {
  103631. name: string;
  103632. shader: string;
  103633. };
  103634. }
  103635. declare module BABYLON {
  103636. /** @hidden */
  103637. export var passCubePixelShader: {
  103638. name: string;
  103639. shader: string;
  103640. };
  103641. }
  103642. declare module BABYLON {
  103643. /**
  103644. * PassPostProcess which produces an output the same as it's input
  103645. */
  103646. export class PassPostProcess extends PostProcess {
  103647. /**
  103648. * Creates the PassPostProcess
  103649. * @param name The name of the effect.
  103650. * @param options The required width/height ratio to downsize to before computing the render pass.
  103651. * @param camera The camera to apply the render pass to.
  103652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103653. * @param engine The engine which the post process will be applied. (default: current engine)
  103654. * @param reusable If the post process can be reused on the same frame. (default: false)
  103655. * @param textureType The type of texture to be used when performing the post processing.
  103656. * @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)
  103657. */
  103658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103659. }
  103660. /**
  103661. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103662. */
  103663. export class PassCubePostProcess extends PostProcess {
  103664. private _face;
  103665. /**
  103666. * Gets or sets the cube face to display.
  103667. * * 0 is +X
  103668. * * 1 is -X
  103669. * * 2 is +Y
  103670. * * 3 is -Y
  103671. * * 4 is +Z
  103672. * * 5 is -Z
  103673. */
  103674. face: number;
  103675. /**
  103676. * Creates the PassCubePostProcess
  103677. * @param name The name of the effect.
  103678. * @param options The required width/height ratio to downsize to before computing the render pass.
  103679. * @param camera The camera to apply the render pass to.
  103680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103681. * @param engine The engine which the post process will be applied. (default: current engine)
  103682. * @param reusable If the post process can be reused on the same frame. (default: false)
  103683. * @param textureType The type of texture to be used when performing the post processing.
  103684. * @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)
  103685. */
  103686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103687. }
  103688. }
  103689. declare module BABYLON {
  103690. /** @hidden */
  103691. export var anaglyphPixelShader: {
  103692. name: string;
  103693. shader: string;
  103694. };
  103695. }
  103696. declare module BABYLON {
  103697. /**
  103698. * Postprocess used to generate anaglyphic rendering
  103699. */
  103700. export class AnaglyphPostProcess extends PostProcess {
  103701. private _passedProcess;
  103702. /**
  103703. * Creates a new AnaglyphPostProcess
  103704. * @param name defines postprocess name
  103705. * @param options defines creation options or target ratio scale
  103706. * @param rigCameras defines cameras using this postprocess
  103707. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103708. * @param engine defines hosting engine
  103709. * @param reusable defines if the postprocess will be reused multiple times per frame
  103710. */
  103711. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103712. }
  103713. }
  103714. declare module BABYLON {
  103715. /**
  103716. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103717. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103718. */
  103719. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103720. /**
  103721. * Creates a new AnaglyphArcRotateCamera
  103722. * @param name defines camera name
  103723. * @param alpha defines alpha angle (in radians)
  103724. * @param beta defines beta angle (in radians)
  103725. * @param radius defines radius
  103726. * @param target defines camera target
  103727. * @param interaxialDistance defines distance between each color axis
  103728. * @param scene defines the hosting scene
  103729. */
  103730. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103731. /**
  103732. * Gets camera class name
  103733. * @returns AnaglyphArcRotateCamera
  103734. */
  103735. getClassName(): string;
  103736. }
  103737. }
  103738. declare module BABYLON {
  103739. /**
  103740. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103741. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103742. */
  103743. export class AnaglyphFreeCamera extends FreeCamera {
  103744. /**
  103745. * Creates a new AnaglyphFreeCamera
  103746. * @param name defines camera name
  103747. * @param position defines initial position
  103748. * @param interaxialDistance defines distance between each color axis
  103749. * @param scene defines the hosting scene
  103750. */
  103751. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103752. /**
  103753. * Gets camera class name
  103754. * @returns AnaglyphFreeCamera
  103755. */
  103756. getClassName(): string;
  103757. }
  103758. }
  103759. declare module BABYLON {
  103760. /**
  103761. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103763. */
  103764. export class AnaglyphGamepadCamera extends GamepadCamera {
  103765. /**
  103766. * Creates a new AnaglyphGamepadCamera
  103767. * @param name defines camera name
  103768. * @param position defines initial position
  103769. * @param interaxialDistance defines distance between each color axis
  103770. * @param scene defines the hosting scene
  103771. */
  103772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103773. /**
  103774. * Gets camera class name
  103775. * @returns AnaglyphGamepadCamera
  103776. */
  103777. getClassName(): string;
  103778. }
  103779. }
  103780. declare module BABYLON {
  103781. /**
  103782. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103783. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103784. */
  103785. export class AnaglyphUniversalCamera extends UniversalCamera {
  103786. /**
  103787. * Creates a new AnaglyphUniversalCamera
  103788. * @param name defines camera name
  103789. * @param position defines initial position
  103790. * @param interaxialDistance defines distance between each color axis
  103791. * @param scene defines the hosting scene
  103792. */
  103793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103794. /**
  103795. * Gets camera class name
  103796. * @returns AnaglyphUniversalCamera
  103797. */
  103798. getClassName(): string;
  103799. }
  103800. }
  103801. declare module BABYLON {
  103802. /** @hidden */
  103803. export var stereoscopicInterlacePixelShader: {
  103804. name: string;
  103805. shader: string;
  103806. };
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103811. */
  103812. export class StereoscopicInterlacePostProcess extends PostProcess {
  103813. private _stepSize;
  103814. private _passedProcess;
  103815. /**
  103816. * Initializes a StereoscopicInterlacePostProcess
  103817. * @param name The name of the effect.
  103818. * @param rigCameras The rig cameras to be appled to the post process
  103819. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103821. * @param engine The engine which the post process will be applied. (default: current engine)
  103822. * @param reusable If the post process can be reused on the same frame. (default: false)
  103823. */
  103824. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103825. }
  103826. }
  103827. declare module BABYLON {
  103828. /**
  103829. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103830. * @see http://doc.babylonjs.com/features/cameras
  103831. */
  103832. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103833. /**
  103834. * Creates a new StereoscopicArcRotateCamera
  103835. * @param name defines camera name
  103836. * @param alpha defines alpha angle (in radians)
  103837. * @param beta defines beta angle (in radians)
  103838. * @param radius defines radius
  103839. * @param target defines camera target
  103840. * @param interaxialDistance defines distance between each color axis
  103841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103842. * @param scene defines the hosting scene
  103843. */
  103844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103845. /**
  103846. * Gets camera class name
  103847. * @returns StereoscopicArcRotateCamera
  103848. */
  103849. getClassName(): string;
  103850. }
  103851. }
  103852. declare module BABYLON {
  103853. /**
  103854. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103855. * @see http://doc.babylonjs.com/features/cameras
  103856. */
  103857. export class StereoscopicFreeCamera extends FreeCamera {
  103858. /**
  103859. * Creates a new StereoscopicFreeCamera
  103860. * @param name defines camera name
  103861. * @param position defines initial position
  103862. * @param interaxialDistance defines distance between each color axis
  103863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103864. * @param scene defines the hosting scene
  103865. */
  103866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103867. /**
  103868. * Gets camera class name
  103869. * @returns StereoscopicFreeCamera
  103870. */
  103871. getClassName(): string;
  103872. }
  103873. }
  103874. declare module BABYLON {
  103875. /**
  103876. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103877. * @see http://doc.babylonjs.com/features/cameras
  103878. */
  103879. export class StereoscopicGamepadCamera extends GamepadCamera {
  103880. /**
  103881. * Creates a new StereoscopicGamepadCamera
  103882. * @param name defines camera name
  103883. * @param position defines initial position
  103884. * @param interaxialDistance defines distance between each color axis
  103885. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103886. * @param scene defines the hosting scene
  103887. */
  103888. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103889. /**
  103890. * Gets camera class name
  103891. * @returns StereoscopicGamepadCamera
  103892. */
  103893. getClassName(): string;
  103894. }
  103895. }
  103896. declare module BABYLON {
  103897. /**
  103898. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103899. * @see http://doc.babylonjs.com/features/cameras
  103900. */
  103901. export class StereoscopicUniversalCamera extends UniversalCamera {
  103902. /**
  103903. * Creates a new StereoscopicUniversalCamera
  103904. * @param name defines camera name
  103905. * @param position defines initial position
  103906. * @param interaxialDistance defines distance between each color axis
  103907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103908. * @param scene defines the hosting scene
  103909. */
  103910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103911. /**
  103912. * Gets camera class name
  103913. * @returns StereoscopicUniversalCamera
  103914. */
  103915. getClassName(): string;
  103916. }
  103917. }
  103918. declare module BABYLON {
  103919. /**
  103920. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103921. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103922. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103923. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103924. */
  103925. export class VirtualJoysticksCamera extends FreeCamera {
  103926. /**
  103927. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103928. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103929. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103930. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103931. * @param name Define the name of the camera in the scene
  103932. * @param position Define the start position of the camera in the scene
  103933. * @param scene Define the scene the camera belongs to
  103934. */
  103935. constructor(name: string, position: Vector3, scene: Scene);
  103936. /**
  103937. * Gets the current object class name.
  103938. * @return the class name
  103939. */
  103940. getClassName(): string;
  103941. }
  103942. }
  103943. declare module BABYLON {
  103944. /**
  103945. * This represents all the required metrics to create a VR camera.
  103946. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103947. */
  103948. export class VRCameraMetrics {
  103949. /**
  103950. * Define the horizontal resolution off the screen.
  103951. */
  103952. hResolution: number;
  103953. /**
  103954. * Define the vertical resolution off the screen.
  103955. */
  103956. vResolution: number;
  103957. /**
  103958. * Define the horizontal screen size.
  103959. */
  103960. hScreenSize: number;
  103961. /**
  103962. * Define the vertical screen size.
  103963. */
  103964. vScreenSize: number;
  103965. /**
  103966. * Define the vertical screen center position.
  103967. */
  103968. vScreenCenter: number;
  103969. /**
  103970. * Define the distance of the eyes to the screen.
  103971. */
  103972. eyeToScreenDistance: number;
  103973. /**
  103974. * Define the distance between both lenses
  103975. */
  103976. lensSeparationDistance: number;
  103977. /**
  103978. * Define the distance between both viewer's eyes.
  103979. */
  103980. interpupillaryDistance: number;
  103981. /**
  103982. * Define the distortion factor of the VR postprocess.
  103983. * Please, touch with care.
  103984. */
  103985. distortionK: number[];
  103986. /**
  103987. * Define the chromatic aberration correction factors for the VR post process.
  103988. */
  103989. chromaAbCorrection: number[];
  103990. /**
  103991. * Define the scale factor of the post process.
  103992. * The smaller the better but the slower.
  103993. */
  103994. postProcessScaleFactor: number;
  103995. /**
  103996. * Define an offset for the lens center.
  103997. */
  103998. lensCenterOffset: number;
  103999. /**
  104000. * Define if the current vr camera should compensate the distortion of the lense or not.
  104001. */
  104002. compensateDistortion: boolean;
  104003. /**
  104004. * Defines if multiview should be enabled when rendering (Default: false)
  104005. */
  104006. multiviewEnabled: boolean;
  104007. /**
  104008. * Gets the rendering aspect ratio based on the provided resolutions.
  104009. */
  104010. readonly aspectRatio: number;
  104011. /**
  104012. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104013. */
  104014. readonly aspectRatioFov: number;
  104015. /**
  104016. * @hidden
  104017. */
  104018. readonly leftHMatrix: Matrix;
  104019. /**
  104020. * @hidden
  104021. */
  104022. readonly rightHMatrix: Matrix;
  104023. /**
  104024. * @hidden
  104025. */
  104026. readonly leftPreViewMatrix: Matrix;
  104027. /**
  104028. * @hidden
  104029. */
  104030. readonly rightPreViewMatrix: Matrix;
  104031. /**
  104032. * Get the default VRMetrics based on the most generic setup.
  104033. * @returns the default vr metrics
  104034. */
  104035. static GetDefault(): VRCameraMetrics;
  104036. }
  104037. }
  104038. declare module BABYLON {
  104039. /** @hidden */
  104040. export var vrDistortionCorrectionPixelShader: {
  104041. name: string;
  104042. shader: string;
  104043. };
  104044. }
  104045. declare module BABYLON {
  104046. /**
  104047. * VRDistortionCorrectionPostProcess used for mobile VR
  104048. */
  104049. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104050. private _isRightEye;
  104051. private _distortionFactors;
  104052. private _postProcessScaleFactor;
  104053. private _lensCenterOffset;
  104054. private _scaleIn;
  104055. private _scaleFactor;
  104056. private _lensCenter;
  104057. /**
  104058. * Initializes the VRDistortionCorrectionPostProcess
  104059. * @param name The name of the effect.
  104060. * @param camera The camera to apply the render pass to.
  104061. * @param isRightEye If this is for the right eye distortion
  104062. * @param vrMetrics All the required metrics for the VR camera
  104063. */
  104064. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104065. }
  104066. }
  104067. declare module BABYLON {
  104068. /**
  104069. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104071. */
  104072. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104073. /**
  104074. * Creates a new VRDeviceOrientationArcRotateCamera
  104075. * @param name defines camera name
  104076. * @param alpha defines the camera rotation along the logitudinal axis
  104077. * @param beta defines the camera rotation along the latitudinal axis
  104078. * @param radius defines the camera distance from its target
  104079. * @param target defines the camera target
  104080. * @param scene defines the scene the camera belongs to
  104081. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104082. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104083. */
  104084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104085. /**
  104086. * Gets camera class name
  104087. * @returns VRDeviceOrientationArcRotateCamera
  104088. */
  104089. getClassName(): string;
  104090. }
  104091. }
  104092. declare module BABYLON {
  104093. /**
  104094. * Camera used to simulate VR rendering (based on FreeCamera)
  104095. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104096. */
  104097. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104098. /**
  104099. * Creates a new VRDeviceOrientationFreeCamera
  104100. * @param name defines camera name
  104101. * @param position defines the start position of the camera
  104102. * @param scene defines the scene the camera belongs to
  104103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104105. */
  104106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104107. /**
  104108. * Gets camera class name
  104109. * @returns VRDeviceOrientationFreeCamera
  104110. */
  104111. getClassName(): string;
  104112. }
  104113. }
  104114. declare module BABYLON {
  104115. /**
  104116. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  104117. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104118. */
  104119. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  104120. /**
  104121. * Creates a new VRDeviceOrientationGamepadCamera
  104122. * @param name defines camera name
  104123. * @param position defines the start position of the camera
  104124. * @param scene defines the scene the camera belongs to
  104125. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104126. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104127. */
  104128. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104129. /**
  104130. * Gets camera class name
  104131. * @returns VRDeviceOrientationGamepadCamera
  104132. */
  104133. getClassName(): string;
  104134. }
  104135. }
  104136. declare module BABYLON {
  104137. /**
  104138. * Base class of materials working in push mode in babylon JS
  104139. * @hidden
  104140. */
  104141. export class PushMaterial extends Material {
  104142. protected _activeEffect: Effect;
  104143. protected _normalMatrix: Matrix;
  104144. /**
  104145. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  104146. * This means that the material can keep using a previous shader while a new one is being compiled.
  104147. * This is mostly used when shader parallel compilation is supported (true by default)
  104148. */
  104149. allowShaderHotSwapping: boolean;
  104150. constructor(name: string, scene: Scene);
  104151. getEffect(): Effect;
  104152. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104153. /**
  104154. * Binds the given world matrix to the active effect
  104155. *
  104156. * @param world the matrix to bind
  104157. */
  104158. bindOnlyWorldMatrix(world: Matrix): void;
  104159. /**
  104160. * Binds the given normal matrix to the active effect
  104161. *
  104162. * @param normalMatrix the matrix to bind
  104163. */
  104164. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104165. bind(world: Matrix, mesh?: Mesh): void;
  104166. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104167. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104168. }
  104169. }
  104170. declare module BABYLON {
  104171. /**
  104172. * This groups all the flags used to control the materials channel.
  104173. */
  104174. export class MaterialFlags {
  104175. private static _DiffuseTextureEnabled;
  104176. /**
  104177. * Are diffuse textures enabled in the application.
  104178. */
  104179. static DiffuseTextureEnabled: boolean;
  104180. private static _AmbientTextureEnabled;
  104181. /**
  104182. * Are ambient textures enabled in the application.
  104183. */
  104184. static AmbientTextureEnabled: boolean;
  104185. private static _OpacityTextureEnabled;
  104186. /**
  104187. * Are opacity textures enabled in the application.
  104188. */
  104189. static OpacityTextureEnabled: boolean;
  104190. private static _ReflectionTextureEnabled;
  104191. /**
  104192. * Are reflection textures enabled in the application.
  104193. */
  104194. static ReflectionTextureEnabled: boolean;
  104195. private static _EmissiveTextureEnabled;
  104196. /**
  104197. * Are emissive textures enabled in the application.
  104198. */
  104199. static EmissiveTextureEnabled: boolean;
  104200. private static _SpecularTextureEnabled;
  104201. /**
  104202. * Are specular textures enabled in the application.
  104203. */
  104204. static SpecularTextureEnabled: boolean;
  104205. private static _BumpTextureEnabled;
  104206. /**
  104207. * Are bump textures enabled in the application.
  104208. */
  104209. static BumpTextureEnabled: boolean;
  104210. private static _LightmapTextureEnabled;
  104211. /**
  104212. * Are lightmap textures enabled in the application.
  104213. */
  104214. static LightmapTextureEnabled: boolean;
  104215. private static _RefractionTextureEnabled;
  104216. /**
  104217. * Are refraction textures enabled in the application.
  104218. */
  104219. static RefractionTextureEnabled: boolean;
  104220. private static _ColorGradingTextureEnabled;
  104221. /**
  104222. * Are color grading textures enabled in the application.
  104223. */
  104224. static ColorGradingTextureEnabled: boolean;
  104225. private static _FresnelEnabled;
  104226. /**
  104227. * Are fresnels enabled in the application.
  104228. */
  104229. static FresnelEnabled: boolean;
  104230. private static _ClearCoatTextureEnabled;
  104231. /**
  104232. * Are clear coat textures enabled in the application.
  104233. */
  104234. static ClearCoatTextureEnabled: boolean;
  104235. private static _ClearCoatBumpTextureEnabled;
  104236. /**
  104237. * Are clear coat bump textures enabled in the application.
  104238. */
  104239. static ClearCoatBumpTextureEnabled: boolean;
  104240. private static _ClearCoatTintTextureEnabled;
  104241. /**
  104242. * Are clear coat tint textures enabled in the application.
  104243. */
  104244. static ClearCoatTintTextureEnabled: boolean;
  104245. private static _SheenTextureEnabled;
  104246. /**
  104247. * Are sheen textures enabled in the application.
  104248. */
  104249. static SheenTextureEnabled: boolean;
  104250. private static _AnisotropicTextureEnabled;
  104251. /**
  104252. * Are anisotropic textures enabled in the application.
  104253. */
  104254. static AnisotropicTextureEnabled: boolean;
  104255. private static _ThicknessTextureEnabled;
  104256. /**
  104257. * Are thickness textures enabled in the application.
  104258. */
  104259. static ThicknessTextureEnabled: boolean;
  104260. }
  104261. }
  104262. declare module BABYLON {
  104263. /** @hidden */
  104264. export var defaultFragmentDeclaration: {
  104265. name: string;
  104266. shader: string;
  104267. };
  104268. }
  104269. declare module BABYLON {
  104270. /** @hidden */
  104271. export var defaultUboDeclaration: {
  104272. name: string;
  104273. shader: string;
  104274. };
  104275. }
  104276. declare module BABYLON {
  104277. /** @hidden */
  104278. export var lightFragmentDeclaration: {
  104279. name: string;
  104280. shader: string;
  104281. };
  104282. }
  104283. declare module BABYLON {
  104284. /** @hidden */
  104285. export var lightUboDeclaration: {
  104286. name: string;
  104287. shader: string;
  104288. };
  104289. }
  104290. declare module BABYLON {
  104291. /** @hidden */
  104292. export var lightsFragmentFunctions: {
  104293. name: string;
  104294. shader: string;
  104295. };
  104296. }
  104297. declare module BABYLON {
  104298. /** @hidden */
  104299. export var shadowsFragmentFunctions: {
  104300. name: string;
  104301. shader: string;
  104302. };
  104303. }
  104304. declare module BABYLON {
  104305. /** @hidden */
  104306. export var fresnelFunction: {
  104307. name: string;
  104308. shader: string;
  104309. };
  104310. }
  104311. declare module BABYLON {
  104312. /** @hidden */
  104313. export var reflectionFunction: {
  104314. name: string;
  104315. shader: string;
  104316. };
  104317. }
  104318. declare module BABYLON {
  104319. /** @hidden */
  104320. export var bumpFragmentFunctions: {
  104321. name: string;
  104322. shader: string;
  104323. };
  104324. }
  104325. declare module BABYLON {
  104326. /** @hidden */
  104327. export var logDepthDeclaration: {
  104328. name: string;
  104329. shader: string;
  104330. };
  104331. }
  104332. declare module BABYLON {
  104333. /** @hidden */
  104334. export var bumpFragment: {
  104335. name: string;
  104336. shader: string;
  104337. };
  104338. }
  104339. declare module BABYLON {
  104340. /** @hidden */
  104341. export var depthPrePass: {
  104342. name: string;
  104343. shader: string;
  104344. };
  104345. }
  104346. declare module BABYLON {
  104347. /** @hidden */
  104348. export var lightFragment: {
  104349. name: string;
  104350. shader: string;
  104351. };
  104352. }
  104353. declare module BABYLON {
  104354. /** @hidden */
  104355. export var logDepthFragment: {
  104356. name: string;
  104357. shader: string;
  104358. };
  104359. }
  104360. declare module BABYLON {
  104361. /** @hidden */
  104362. export var defaultPixelShader: {
  104363. name: string;
  104364. shader: string;
  104365. };
  104366. }
  104367. declare module BABYLON {
  104368. /** @hidden */
  104369. export var defaultVertexDeclaration: {
  104370. name: string;
  104371. shader: string;
  104372. };
  104373. }
  104374. declare module BABYLON {
  104375. /** @hidden */
  104376. export var bumpVertexDeclaration: {
  104377. name: string;
  104378. shader: string;
  104379. };
  104380. }
  104381. declare module BABYLON {
  104382. /** @hidden */
  104383. export var bumpVertex: {
  104384. name: string;
  104385. shader: string;
  104386. };
  104387. }
  104388. declare module BABYLON {
  104389. /** @hidden */
  104390. export var fogVertex: {
  104391. name: string;
  104392. shader: string;
  104393. };
  104394. }
  104395. declare module BABYLON {
  104396. /** @hidden */
  104397. export var shadowsVertex: {
  104398. name: string;
  104399. shader: string;
  104400. };
  104401. }
  104402. declare module BABYLON {
  104403. /** @hidden */
  104404. export var pointCloudVertex: {
  104405. name: string;
  104406. shader: string;
  104407. };
  104408. }
  104409. declare module BABYLON {
  104410. /** @hidden */
  104411. export var logDepthVertex: {
  104412. name: string;
  104413. shader: string;
  104414. };
  104415. }
  104416. declare module BABYLON {
  104417. /** @hidden */
  104418. export var defaultVertexShader: {
  104419. name: string;
  104420. shader: string;
  104421. };
  104422. }
  104423. declare module BABYLON {
  104424. /** @hidden */
  104425. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104426. MAINUV1: boolean;
  104427. MAINUV2: boolean;
  104428. DIFFUSE: boolean;
  104429. DIFFUSEDIRECTUV: number;
  104430. AMBIENT: boolean;
  104431. AMBIENTDIRECTUV: number;
  104432. OPACITY: boolean;
  104433. OPACITYDIRECTUV: number;
  104434. OPACITYRGB: boolean;
  104435. REFLECTION: boolean;
  104436. EMISSIVE: boolean;
  104437. EMISSIVEDIRECTUV: number;
  104438. SPECULAR: boolean;
  104439. SPECULARDIRECTUV: number;
  104440. BUMP: boolean;
  104441. BUMPDIRECTUV: number;
  104442. PARALLAX: boolean;
  104443. PARALLAXOCCLUSION: boolean;
  104444. SPECULAROVERALPHA: boolean;
  104445. CLIPPLANE: boolean;
  104446. CLIPPLANE2: boolean;
  104447. CLIPPLANE3: boolean;
  104448. CLIPPLANE4: boolean;
  104449. ALPHATEST: boolean;
  104450. DEPTHPREPASS: boolean;
  104451. ALPHAFROMDIFFUSE: boolean;
  104452. POINTSIZE: boolean;
  104453. FOG: boolean;
  104454. SPECULARTERM: boolean;
  104455. DIFFUSEFRESNEL: boolean;
  104456. OPACITYFRESNEL: boolean;
  104457. REFLECTIONFRESNEL: boolean;
  104458. REFRACTIONFRESNEL: boolean;
  104459. EMISSIVEFRESNEL: boolean;
  104460. FRESNEL: boolean;
  104461. NORMAL: boolean;
  104462. UV1: boolean;
  104463. UV2: boolean;
  104464. VERTEXCOLOR: boolean;
  104465. VERTEXALPHA: boolean;
  104466. NUM_BONE_INFLUENCERS: number;
  104467. BonesPerMesh: number;
  104468. BONETEXTURE: boolean;
  104469. INSTANCES: boolean;
  104470. GLOSSINESS: boolean;
  104471. ROUGHNESS: boolean;
  104472. EMISSIVEASILLUMINATION: boolean;
  104473. LINKEMISSIVEWITHDIFFUSE: boolean;
  104474. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104475. LIGHTMAP: boolean;
  104476. LIGHTMAPDIRECTUV: number;
  104477. OBJECTSPACE_NORMALMAP: boolean;
  104478. USELIGHTMAPASSHADOWMAP: boolean;
  104479. REFLECTIONMAP_3D: boolean;
  104480. REFLECTIONMAP_SPHERICAL: boolean;
  104481. REFLECTIONMAP_PLANAR: boolean;
  104482. REFLECTIONMAP_CUBIC: boolean;
  104483. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104484. REFLECTIONMAP_PROJECTION: boolean;
  104485. REFLECTIONMAP_SKYBOX: boolean;
  104486. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104487. REFLECTIONMAP_EXPLICIT: boolean;
  104488. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104489. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104490. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104491. INVERTCUBICMAP: boolean;
  104492. LOGARITHMICDEPTH: boolean;
  104493. REFRACTION: boolean;
  104494. REFRACTIONMAP_3D: boolean;
  104495. REFLECTIONOVERALPHA: boolean;
  104496. TWOSIDEDLIGHTING: boolean;
  104497. SHADOWFLOAT: boolean;
  104498. MORPHTARGETS: boolean;
  104499. MORPHTARGETS_NORMAL: boolean;
  104500. MORPHTARGETS_TANGENT: boolean;
  104501. MORPHTARGETS_UV: boolean;
  104502. NUM_MORPH_INFLUENCERS: number;
  104503. NONUNIFORMSCALING: boolean;
  104504. PREMULTIPLYALPHA: boolean;
  104505. IMAGEPROCESSING: boolean;
  104506. VIGNETTE: boolean;
  104507. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104508. VIGNETTEBLENDMODEOPAQUE: boolean;
  104509. TONEMAPPING: boolean;
  104510. TONEMAPPING_ACES: boolean;
  104511. CONTRAST: boolean;
  104512. COLORCURVES: boolean;
  104513. COLORGRADING: boolean;
  104514. COLORGRADING3D: boolean;
  104515. SAMPLER3DGREENDEPTH: boolean;
  104516. SAMPLER3DBGRMAP: boolean;
  104517. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104518. MULTIVIEW: boolean;
  104519. /**
  104520. * If the reflection texture on this material is in linear color space
  104521. * @hidden
  104522. */
  104523. IS_REFLECTION_LINEAR: boolean;
  104524. /**
  104525. * If the refraction texture on this material is in linear color space
  104526. * @hidden
  104527. */
  104528. IS_REFRACTION_LINEAR: boolean;
  104529. EXPOSURE: boolean;
  104530. constructor();
  104531. setReflectionMode(modeToEnable: string): void;
  104532. }
  104533. /**
  104534. * This is the default material used in Babylon. It is the best trade off between quality
  104535. * and performances.
  104536. * @see http://doc.babylonjs.com/babylon101/materials
  104537. */
  104538. export class StandardMaterial extends PushMaterial {
  104539. private _diffuseTexture;
  104540. /**
  104541. * The basic texture of the material as viewed under a light.
  104542. */
  104543. diffuseTexture: Nullable<BaseTexture>;
  104544. private _ambientTexture;
  104545. /**
  104546. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104547. */
  104548. ambientTexture: Nullable<BaseTexture>;
  104549. private _opacityTexture;
  104550. /**
  104551. * Define the transparency of the material from a texture.
  104552. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104553. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104554. */
  104555. opacityTexture: Nullable<BaseTexture>;
  104556. private _reflectionTexture;
  104557. /**
  104558. * Define the texture used to display the reflection.
  104559. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104560. */
  104561. reflectionTexture: Nullable<BaseTexture>;
  104562. private _emissiveTexture;
  104563. /**
  104564. * Define texture of the material as if self lit.
  104565. * This will be mixed in the final result even in the absence of light.
  104566. */
  104567. emissiveTexture: Nullable<BaseTexture>;
  104568. private _specularTexture;
  104569. /**
  104570. * Define how the color and intensity of the highlight given by the light in the material.
  104571. */
  104572. specularTexture: Nullable<BaseTexture>;
  104573. private _bumpTexture;
  104574. /**
  104575. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104576. * 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.
  104577. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104578. */
  104579. bumpTexture: Nullable<BaseTexture>;
  104580. private _lightmapTexture;
  104581. /**
  104582. * Complex lighting can be computationally expensive to compute at runtime.
  104583. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104584. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104585. */
  104586. lightmapTexture: Nullable<BaseTexture>;
  104587. private _refractionTexture;
  104588. /**
  104589. * Define the texture used to display the refraction.
  104590. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104591. */
  104592. refractionTexture: Nullable<BaseTexture>;
  104593. /**
  104594. * The color of the material lit by the environmental background lighting.
  104595. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104596. */
  104597. ambientColor: Color3;
  104598. /**
  104599. * The basic color of the material as viewed under a light.
  104600. */
  104601. diffuseColor: Color3;
  104602. /**
  104603. * Define how the color and intensity of the highlight given by the light in the material.
  104604. */
  104605. specularColor: Color3;
  104606. /**
  104607. * Define the color of the material as if self lit.
  104608. * This will be mixed in the final result even in the absence of light.
  104609. */
  104610. emissiveColor: Color3;
  104611. /**
  104612. * Defines how sharp are the highlights in the material.
  104613. * The bigger the value the sharper giving a more glossy feeling to the result.
  104614. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104615. */
  104616. specularPower: number;
  104617. private _useAlphaFromDiffuseTexture;
  104618. /**
  104619. * Does the transparency come from the diffuse texture alpha channel.
  104620. */
  104621. useAlphaFromDiffuseTexture: boolean;
  104622. private _useEmissiveAsIllumination;
  104623. /**
  104624. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104625. */
  104626. useEmissiveAsIllumination: boolean;
  104627. private _linkEmissiveWithDiffuse;
  104628. /**
  104629. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104630. * the emissive level when the final color is close to one.
  104631. */
  104632. linkEmissiveWithDiffuse: boolean;
  104633. private _useSpecularOverAlpha;
  104634. /**
  104635. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104636. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104637. */
  104638. useSpecularOverAlpha: boolean;
  104639. private _useReflectionOverAlpha;
  104640. /**
  104641. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104642. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104643. */
  104644. useReflectionOverAlpha: boolean;
  104645. private _disableLighting;
  104646. /**
  104647. * Does lights from the scene impacts this material.
  104648. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104649. */
  104650. disableLighting: boolean;
  104651. private _useObjectSpaceNormalMap;
  104652. /**
  104653. * Allows using an object space normal map (instead of tangent space).
  104654. */
  104655. useObjectSpaceNormalMap: boolean;
  104656. private _useParallax;
  104657. /**
  104658. * Is parallax enabled or not.
  104659. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104660. */
  104661. useParallax: boolean;
  104662. private _useParallaxOcclusion;
  104663. /**
  104664. * Is parallax occlusion enabled or not.
  104665. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104666. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104667. */
  104668. useParallaxOcclusion: boolean;
  104669. /**
  104670. * 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.
  104671. */
  104672. parallaxScaleBias: number;
  104673. private _roughness;
  104674. /**
  104675. * Helps to define how blurry the reflections should appears in the material.
  104676. */
  104677. roughness: number;
  104678. /**
  104679. * In case of refraction, define the value of the index of refraction.
  104680. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104681. */
  104682. indexOfRefraction: number;
  104683. /**
  104684. * Invert the refraction texture alongside the y axis.
  104685. * It can be useful with procedural textures or probe for instance.
  104686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104687. */
  104688. invertRefractionY: boolean;
  104689. /**
  104690. * Defines the alpha limits in alpha test mode.
  104691. */
  104692. alphaCutOff: number;
  104693. private _useLightmapAsShadowmap;
  104694. /**
  104695. * In case of light mapping, define whether the map contains light or shadow informations.
  104696. */
  104697. useLightmapAsShadowmap: boolean;
  104698. private _diffuseFresnelParameters;
  104699. /**
  104700. * Define the diffuse fresnel parameters of the material.
  104701. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104702. */
  104703. diffuseFresnelParameters: FresnelParameters;
  104704. private _opacityFresnelParameters;
  104705. /**
  104706. * Define the opacity fresnel parameters of the material.
  104707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104708. */
  104709. opacityFresnelParameters: FresnelParameters;
  104710. private _reflectionFresnelParameters;
  104711. /**
  104712. * Define the reflection fresnel parameters of the material.
  104713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104714. */
  104715. reflectionFresnelParameters: FresnelParameters;
  104716. private _refractionFresnelParameters;
  104717. /**
  104718. * Define the refraction fresnel parameters of the material.
  104719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104720. */
  104721. refractionFresnelParameters: FresnelParameters;
  104722. private _emissiveFresnelParameters;
  104723. /**
  104724. * Define the emissive fresnel parameters of the material.
  104725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104726. */
  104727. emissiveFresnelParameters: FresnelParameters;
  104728. private _useReflectionFresnelFromSpecular;
  104729. /**
  104730. * If true automatically deducts the fresnels values from the material specularity.
  104731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104732. */
  104733. useReflectionFresnelFromSpecular: boolean;
  104734. private _useGlossinessFromSpecularMapAlpha;
  104735. /**
  104736. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104737. */
  104738. useGlossinessFromSpecularMapAlpha: boolean;
  104739. private _maxSimultaneousLights;
  104740. /**
  104741. * Defines the maximum number of lights that can be used in the material
  104742. */
  104743. maxSimultaneousLights: number;
  104744. private _invertNormalMapX;
  104745. /**
  104746. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104747. */
  104748. invertNormalMapX: boolean;
  104749. private _invertNormalMapY;
  104750. /**
  104751. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104752. */
  104753. invertNormalMapY: boolean;
  104754. private _twoSidedLighting;
  104755. /**
  104756. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104757. */
  104758. twoSidedLighting: boolean;
  104759. /**
  104760. * Default configuration related to image processing available in the standard Material.
  104761. */
  104762. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104763. /**
  104764. * Gets the image processing configuration used either in this material.
  104765. */
  104766. /**
  104767. * Sets the Default image processing configuration used either in the this material.
  104768. *
  104769. * If sets to null, the scene one is in use.
  104770. */
  104771. imageProcessingConfiguration: ImageProcessingConfiguration;
  104772. /**
  104773. * Keep track of the image processing observer to allow dispose and replace.
  104774. */
  104775. private _imageProcessingObserver;
  104776. /**
  104777. * Attaches a new image processing configuration to the Standard Material.
  104778. * @param configuration
  104779. */
  104780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104781. /**
  104782. * Gets wether the color curves effect is enabled.
  104783. */
  104784. /**
  104785. * Sets wether the color curves effect is enabled.
  104786. */
  104787. cameraColorCurvesEnabled: boolean;
  104788. /**
  104789. * Gets wether the color grading effect is enabled.
  104790. */
  104791. /**
  104792. * Gets wether the color grading effect is enabled.
  104793. */
  104794. cameraColorGradingEnabled: boolean;
  104795. /**
  104796. * Gets wether tonemapping is enabled or not.
  104797. */
  104798. /**
  104799. * Sets wether tonemapping is enabled or not
  104800. */
  104801. cameraToneMappingEnabled: boolean;
  104802. /**
  104803. * The camera exposure used on this material.
  104804. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104805. * This corresponds to a photographic exposure.
  104806. */
  104807. /**
  104808. * The camera exposure used on this material.
  104809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104810. * This corresponds to a photographic exposure.
  104811. */
  104812. cameraExposure: number;
  104813. /**
  104814. * Gets The camera contrast used on this material.
  104815. */
  104816. /**
  104817. * Sets The camera contrast used on this material.
  104818. */
  104819. cameraContrast: number;
  104820. /**
  104821. * Gets the Color Grading 2D Lookup Texture.
  104822. */
  104823. /**
  104824. * Sets the Color Grading 2D Lookup Texture.
  104825. */
  104826. cameraColorGradingTexture: Nullable<BaseTexture>;
  104827. /**
  104828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104830. * 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;
  104831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104832. */
  104833. /**
  104834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104836. * 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;
  104837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104838. */
  104839. cameraColorCurves: Nullable<ColorCurves>;
  104840. /**
  104841. * Custom callback helping to override the default shader used in the material.
  104842. */
  104843. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104844. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104845. protected _worldViewProjectionMatrix: Matrix;
  104846. protected _globalAmbientColor: Color3;
  104847. protected _useLogarithmicDepth: boolean;
  104848. /**
  104849. * Instantiates a new standard material.
  104850. * This is the default material used in Babylon. It is the best trade off between quality
  104851. * and performances.
  104852. * @see http://doc.babylonjs.com/babylon101/materials
  104853. * @param name Define the name of the material in the scene
  104854. * @param scene Define the scene the material belong to
  104855. */
  104856. constructor(name: string, scene: Scene);
  104857. /**
  104858. * Gets a boolean indicating that current material needs to register RTT
  104859. */
  104860. readonly hasRenderTargetTextures: boolean;
  104861. /**
  104862. * Gets the current class name of the material e.g. "StandardMaterial"
  104863. * Mainly use in serialization.
  104864. * @returns the class name
  104865. */
  104866. getClassName(): string;
  104867. /**
  104868. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104869. * You can try switching to logarithmic depth.
  104870. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104871. */
  104872. useLogarithmicDepth: boolean;
  104873. /**
  104874. * Specifies if the material will require alpha blending
  104875. * @returns a boolean specifying if alpha blending is needed
  104876. */
  104877. needAlphaBlending(): boolean;
  104878. /**
  104879. * Specifies if this material should be rendered in alpha test mode
  104880. * @returns a boolean specifying if an alpha test is needed.
  104881. */
  104882. needAlphaTesting(): boolean;
  104883. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104884. /**
  104885. * Get the texture used for alpha test purpose.
  104886. * @returns the diffuse texture in case of the standard material.
  104887. */
  104888. getAlphaTestTexture(): Nullable<BaseTexture>;
  104889. /**
  104890. * Get if the submesh is ready to be used and all its information available.
  104891. * Child classes can use it to update shaders
  104892. * @param mesh defines the mesh to check
  104893. * @param subMesh defines which submesh to check
  104894. * @param useInstances specifies that instances should be used
  104895. * @returns a boolean indicating that the submesh is ready or not
  104896. */
  104897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104898. /**
  104899. * Builds the material UBO layouts.
  104900. * Used internally during the effect preparation.
  104901. */
  104902. buildUniformLayout(): void;
  104903. /**
  104904. * Unbinds the material from the mesh
  104905. */
  104906. unbind(): void;
  104907. /**
  104908. * Binds the submesh to this material by preparing the effect and shader to draw
  104909. * @param world defines the world transformation matrix
  104910. * @param mesh defines the mesh containing the submesh
  104911. * @param subMesh defines the submesh to bind the material to
  104912. */
  104913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104914. /**
  104915. * Get the list of animatables in the material.
  104916. * @returns the list of animatables object used in the material
  104917. */
  104918. getAnimatables(): IAnimatable[];
  104919. /**
  104920. * Gets the active textures from the material
  104921. * @returns an array of textures
  104922. */
  104923. getActiveTextures(): BaseTexture[];
  104924. /**
  104925. * Specifies if the material uses a texture
  104926. * @param texture defines the texture to check against the material
  104927. * @returns a boolean specifying if the material uses the texture
  104928. */
  104929. hasTexture(texture: BaseTexture): boolean;
  104930. /**
  104931. * Disposes the material
  104932. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104933. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104934. */
  104935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104936. /**
  104937. * Makes a duplicate of the material, and gives it a new name
  104938. * @param name defines the new name for the duplicated material
  104939. * @returns the cloned material
  104940. */
  104941. clone(name: string): StandardMaterial;
  104942. /**
  104943. * Serializes this material in a JSON representation
  104944. * @returns the serialized material object
  104945. */
  104946. serialize(): any;
  104947. /**
  104948. * Creates a standard material from parsed material data
  104949. * @param source defines the JSON representation of the material
  104950. * @param scene defines the hosting scene
  104951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104952. * @returns a new standard material
  104953. */
  104954. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104955. /**
  104956. * Are diffuse textures enabled in the application.
  104957. */
  104958. static DiffuseTextureEnabled: boolean;
  104959. /**
  104960. * Are ambient textures enabled in the application.
  104961. */
  104962. static AmbientTextureEnabled: boolean;
  104963. /**
  104964. * Are opacity textures enabled in the application.
  104965. */
  104966. static OpacityTextureEnabled: boolean;
  104967. /**
  104968. * Are reflection textures enabled in the application.
  104969. */
  104970. static ReflectionTextureEnabled: boolean;
  104971. /**
  104972. * Are emissive textures enabled in the application.
  104973. */
  104974. static EmissiveTextureEnabled: boolean;
  104975. /**
  104976. * Are specular textures enabled in the application.
  104977. */
  104978. static SpecularTextureEnabled: boolean;
  104979. /**
  104980. * Are bump textures enabled in the application.
  104981. */
  104982. static BumpTextureEnabled: boolean;
  104983. /**
  104984. * Are lightmap textures enabled in the application.
  104985. */
  104986. static LightmapTextureEnabled: boolean;
  104987. /**
  104988. * Are refraction textures enabled in the application.
  104989. */
  104990. static RefractionTextureEnabled: boolean;
  104991. /**
  104992. * Are color grading textures enabled in the application.
  104993. */
  104994. static ColorGradingTextureEnabled: boolean;
  104995. /**
  104996. * Are fresnels enabled in the application.
  104997. */
  104998. static FresnelEnabled: boolean;
  104999. }
  105000. }
  105001. declare module BABYLON {
  105002. /**
  105003. * A class extending Texture allowing drawing on a texture
  105004. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105005. */
  105006. export class DynamicTexture extends Texture {
  105007. private _generateMipMaps;
  105008. private _canvas;
  105009. private _context;
  105010. private _engine;
  105011. /**
  105012. * Creates a DynamicTexture
  105013. * @param name defines the name of the texture
  105014. * @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
  105015. * @param scene defines the scene where you want the texture
  105016. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105017. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105018. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105019. */
  105020. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105021. /**
  105022. * Get the current class name of the texture useful for serialization or dynamic coding.
  105023. * @returns "DynamicTexture"
  105024. */
  105025. getClassName(): string;
  105026. /**
  105027. * Gets the current state of canRescale
  105028. */
  105029. readonly canRescale: boolean;
  105030. private _recreate;
  105031. /**
  105032. * Scales the texture
  105033. * @param ratio the scale factor to apply to both width and height
  105034. */
  105035. scale(ratio: number): void;
  105036. /**
  105037. * Resizes the texture
  105038. * @param width the new width
  105039. * @param height the new height
  105040. */
  105041. scaleTo(width: number, height: number): void;
  105042. /**
  105043. * Gets the context of the canvas used by the texture
  105044. * @returns the canvas context of the dynamic texture
  105045. */
  105046. getContext(): CanvasRenderingContext2D;
  105047. /**
  105048. * Clears the texture
  105049. */
  105050. clear(): void;
  105051. /**
  105052. * Updates the texture
  105053. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105054. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105055. */
  105056. update(invertY?: boolean, premulAlpha?: boolean): void;
  105057. /**
  105058. * Draws text onto the texture
  105059. * @param text defines the text to be drawn
  105060. * @param x defines the placement of the text from the left
  105061. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105062. * @param font defines the font to be used with font-style, font-size, font-name
  105063. * @param color defines the color used for the text
  105064. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105065. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105066. * @param update defines whether texture is immediately update (default is true)
  105067. */
  105068. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105069. /**
  105070. * Clones the texture
  105071. * @returns the clone of the texture.
  105072. */
  105073. clone(): DynamicTexture;
  105074. /**
  105075. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105076. * @returns a serialized dynamic texture object
  105077. */
  105078. serialize(): any;
  105079. /** @hidden */
  105080. _rebuild(): void;
  105081. }
  105082. }
  105083. declare module BABYLON {
  105084. /** @hidden */
  105085. export var imageProcessingPixelShader: {
  105086. name: string;
  105087. shader: string;
  105088. };
  105089. }
  105090. declare module BABYLON {
  105091. /**
  105092. * ImageProcessingPostProcess
  105093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105094. */
  105095. export class ImageProcessingPostProcess extends PostProcess {
  105096. /**
  105097. * Default configuration related to image processing available in the PBR Material.
  105098. */
  105099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105100. /**
  105101. * Gets the image processing configuration used either in this material.
  105102. */
  105103. /**
  105104. * Sets the Default image processing configuration used either in the this material.
  105105. *
  105106. * If sets to null, the scene one is in use.
  105107. */
  105108. imageProcessingConfiguration: ImageProcessingConfiguration;
  105109. /**
  105110. * Keep track of the image processing observer to allow dispose and replace.
  105111. */
  105112. private _imageProcessingObserver;
  105113. /**
  105114. * Attaches a new image processing configuration to the PBR Material.
  105115. * @param configuration
  105116. */
  105117. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  105118. /**
  105119. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105120. */
  105121. /**
  105122. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105123. */
  105124. colorCurves: Nullable<ColorCurves>;
  105125. /**
  105126. * Gets wether the color curves effect is enabled.
  105127. */
  105128. /**
  105129. * Sets wether the color curves effect is enabled.
  105130. */
  105131. colorCurvesEnabled: boolean;
  105132. /**
  105133. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105134. */
  105135. /**
  105136. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105137. */
  105138. colorGradingTexture: Nullable<BaseTexture>;
  105139. /**
  105140. * Gets wether the color grading effect is enabled.
  105141. */
  105142. /**
  105143. * Gets wether the color grading effect is enabled.
  105144. */
  105145. colorGradingEnabled: boolean;
  105146. /**
  105147. * Gets exposure used in the effect.
  105148. */
  105149. /**
  105150. * Sets exposure used in the effect.
  105151. */
  105152. exposure: number;
  105153. /**
  105154. * Gets wether tonemapping is enabled or not.
  105155. */
  105156. /**
  105157. * Sets wether tonemapping is enabled or not
  105158. */
  105159. toneMappingEnabled: boolean;
  105160. /**
  105161. * Gets the type of tone mapping effect.
  105162. */
  105163. /**
  105164. * Sets the type of tone mapping effect.
  105165. */
  105166. toneMappingType: number;
  105167. /**
  105168. * Gets contrast used in the effect.
  105169. */
  105170. /**
  105171. * Sets contrast used in the effect.
  105172. */
  105173. contrast: number;
  105174. /**
  105175. * Gets Vignette stretch size.
  105176. */
  105177. /**
  105178. * Sets Vignette stretch size.
  105179. */
  105180. vignetteStretch: number;
  105181. /**
  105182. * Gets Vignette centre X Offset.
  105183. */
  105184. /**
  105185. * Sets Vignette centre X Offset.
  105186. */
  105187. vignetteCentreX: number;
  105188. /**
  105189. * Gets Vignette centre Y Offset.
  105190. */
  105191. /**
  105192. * Sets Vignette centre Y Offset.
  105193. */
  105194. vignetteCentreY: number;
  105195. /**
  105196. * Gets Vignette weight or intensity of the vignette effect.
  105197. */
  105198. /**
  105199. * Sets Vignette weight or intensity of the vignette effect.
  105200. */
  105201. vignetteWeight: number;
  105202. /**
  105203. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105204. * if vignetteEnabled is set to true.
  105205. */
  105206. /**
  105207. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105208. * if vignetteEnabled is set to true.
  105209. */
  105210. vignetteColor: Color4;
  105211. /**
  105212. * Gets Camera field of view used by the Vignette effect.
  105213. */
  105214. /**
  105215. * Sets Camera field of view used by the Vignette effect.
  105216. */
  105217. vignetteCameraFov: number;
  105218. /**
  105219. * Gets the vignette blend mode allowing different kind of effect.
  105220. */
  105221. /**
  105222. * Sets the vignette blend mode allowing different kind of effect.
  105223. */
  105224. vignetteBlendMode: number;
  105225. /**
  105226. * Gets wether the vignette effect is enabled.
  105227. */
  105228. /**
  105229. * Sets wether the vignette effect is enabled.
  105230. */
  105231. vignetteEnabled: boolean;
  105232. private _fromLinearSpace;
  105233. /**
  105234. * Gets wether the input of the processing is in Gamma or Linear Space.
  105235. */
  105236. /**
  105237. * Sets wether the input of the processing is in Gamma or Linear Space.
  105238. */
  105239. fromLinearSpace: boolean;
  105240. /**
  105241. * Defines cache preventing GC.
  105242. */
  105243. private _defines;
  105244. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105245. /**
  105246. * "ImageProcessingPostProcess"
  105247. * @returns "ImageProcessingPostProcess"
  105248. */
  105249. getClassName(): string;
  105250. protected _updateParameters(): void;
  105251. dispose(camera?: Camera): void;
  105252. }
  105253. }
  105254. declare module BABYLON {
  105255. /**
  105256. * Class containing static functions to help procedurally build meshes
  105257. */
  105258. export class GroundBuilder {
  105259. /**
  105260. * Creates a ground mesh
  105261. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105262. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105264. * @param name defines the name of the mesh
  105265. * @param options defines the options used to create the mesh
  105266. * @param scene defines the hosting scene
  105267. * @returns the ground mesh
  105268. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105269. */
  105270. static CreateGround(name: string, options: {
  105271. width?: number;
  105272. height?: number;
  105273. subdivisions?: number;
  105274. subdivisionsX?: number;
  105275. subdivisionsY?: number;
  105276. updatable?: boolean;
  105277. }, scene: any): Mesh;
  105278. /**
  105279. * Creates a tiled ground mesh
  105280. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105281. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105282. * * 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
  105283. * * 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
  105284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105285. * @param name defines the name of the mesh
  105286. * @param options defines the options used to create the mesh
  105287. * @param scene defines the hosting scene
  105288. * @returns the tiled ground mesh
  105289. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105290. */
  105291. static CreateTiledGround(name: string, options: {
  105292. xmin: number;
  105293. zmin: number;
  105294. xmax: number;
  105295. zmax: number;
  105296. subdivisions?: {
  105297. w: number;
  105298. h: number;
  105299. };
  105300. precision?: {
  105301. w: number;
  105302. h: number;
  105303. };
  105304. updatable?: boolean;
  105305. }, scene?: Nullable<Scene>): Mesh;
  105306. /**
  105307. * Creates a ground mesh from a height map
  105308. * * The parameter `url` sets the URL of the height map image resource.
  105309. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105310. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105311. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105312. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105313. * * 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.
  105314. * * 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).
  105315. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105317. * @param name defines the name of the mesh
  105318. * @param url defines the url to the height map
  105319. * @param options defines the options used to create the mesh
  105320. * @param scene defines the hosting scene
  105321. * @returns the ground mesh
  105322. * @see https://doc.babylonjs.com/babylon101/height_map
  105323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105324. */
  105325. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105326. width?: number;
  105327. height?: number;
  105328. subdivisions?: number;
  105329. minHeight?: number;
  105330. maxHeight?: number;
  105331. colorFilter?: Color3;
  105332. alphaFilter?: number;
  105333. updatable?: boolean;
  105334. onReady?: (mesh: GroundMesh) => void;
  105335. }, scene?: Nullable<Scene>): GroundMesh;
  105336. }
  105337. }
  105338. declare module BABYLON {
  105339. /**
  105340. * Class containing static functions to help procedurally build meshes
  105341. */
  105342. export class TorusBuilder {
  105343. /**
  105344. * Creates a torus mesh
  105345. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105346. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105347. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105351. * @param name defines the name of the mesh
  105352. * @param options defines the options used to create the mesh
  105353. * @param scene defines the hosting scene
  105354. * @returns the torus mesh
  105355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105356. */
  105357. static CreateTorus(name: string, options: {
  105358. diameter?: number;
  105359. thickness?: number;
  105360. tessellation?: number;
  105361. updatable?: boolean;
  105362. sideOrientation?: number;
  105363. frontUVs?: Vector4;
  105364. backUVs?: Vector4;
  105365. }, scene: any): Mesh;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * Class containing static functions to help procedurally build meshes
  105371. */
  105372. export class CylinderBuilder {
  105373. /**
  105374. * Creates a cylinder or a cone mesh
  105375. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105376. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105377. * * 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.
  105378. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105379. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105380. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105381. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105382. * * 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).
  105383. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105384. * * 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).
  105385. * * 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
  105386. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105387. * * 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
  105388. * * 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.
  105389. * * If `enclose` is false, a ring surface is one element.
  105390. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105391. * * 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
  105392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105395. * @param name defines the name of the mesh
  105396. * @param options defines the options used to create the mesh
  105397. * @param scene defines the hosting scene
  105398. * @returns the cylinder mesh
  105399. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105400. */
  105401. static CreateCylinder(name: string, options: {
  105402. height?: number;
  105403. diameterTop?: number;
  105404. diameterBottom?: number;
  105405. diameter?: number;
  105406. tessellation?: number;
  105407. subdivisions?: number;
  105408. arc?: number;
  105409. faceColors?: Color4[];
  105410. faceUV?: Vector4[];
  105411. updatable?: boolean;
  105412. hasRings?: boolean;
  105413. enclose?: boolean;
  105414. cap?: number;
  105415. sideOrientation?: number;
  105416. frontUVs?: Vector4;
  105417. backUVs?: Vector4;
  105418. }, scene: any): Mesh;
  105419. }
  105420. }
  105421. declare module BABYLON {
  105422. /**
  105423. * Options to modify the vr teleportation behavior.
  105424. */
  105425. export interface VRTeleportationOptions {
  105426. /**
  105427. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105428. */
  105429. floorMeshName?: string;
  105430. /**
  105431. * A list of meshes to be used as the teleportation floor. (default: empty)
  105432. */
  105433. floorMeshes?: Mesh[];
  105434. }
  105435. /**
  105436. * Options to modify the vr experience helper's behavior.
  105437. */
  105438. export interface VRExperienceHelperOptions extends WebVROptions {
  105439. /**
  105440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105441. */
  105442. createDeviceOrientationCamera?: boolean;
  105443. /**
  105444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105445. */
  105446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105447. /**
  105448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105449. */
  105450. laserToggle?: boolean;
  105451. /**
  105452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105453. */
  105454. floorMeshes?: Mesh[];
  105455. /**
  105456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105457. */
  105458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105459. }
  105460. /**
  105461. * Event containing information after VR has been entered
  105462. */
  105463. export class OnAfterEnteringVRObservableEvent {
  105464. /**
  105465. * If entering vr was successful
  105466. */
  105467. success: boolean;
  105468. }
  105469. /**
  105470. * Helps to quickly add VR support to an existing scene.
  105471. * See http://doc.babylonjs.com/how_to/webvr_helper
  105472. */
  105473. export class VRExperienceHelper {
  105474. /** Options to modify the vr experience helper's behavior. */
  105475. webVROptions: VRExperienceHelperOptions;
  105476. private _scene;
  105477. private _position;
  105478. private _btnVR;
  105479. private _btnVRDisplayed;
  105480. private _webVRsupported;
  105481. private _webVRready;
  105482. private _webVRrequesting;
  105483. private _webVRpresenting;
  105484. private _hasEnteredVR;
  105485. private _fullscreenVRpresenting;
  105486. private _canvas;
  105487. private _webVRCamera;
  105488. private _vrDeviceOrientationCamera;
  105489. private _deviceOrientationCamera;
  105490. private _existingCamera;
  105491. private _onKeyDown;
  105492. private _onVrDisplayPresentChange;
  105493. private _onVRDisplayChanged;
  105494. private _onVRRequestPresentStart;
  105495. private _onVRRequestPresentComplete;
  105496. /**
  105497. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  105498. */
  105499. enableGazeEvenWhenNoPointerLock: boolean;
  105500. /**
  105501. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105502. */
  105503. exitVROnDoubleTap: boolean;
  105504. /**
  105505. * Observable raised right before entering VR.
  105506. */
  105507. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105508. /**
  105509. * Observable raised when entering VR has completed.
  105510. */
  105511. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105512. /**
  105513. * Observable raised when exiting VR.
  105514. */
  105515. onExitingVRObservable: Observable<VRExperienceHelper>;
  105516. /**
  105517. * Observable raised when controller mesh is loaded.
  105518. */
  105519. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105520. /** Return this.onEnteringVRObservable
  105521. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105522. */
  105523. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105524. /** Return this.onExitingVRObservable
  105525. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105526. */
  105527. readonly onExitingVR: Observable<VRExperienceHelper>;
  105528. /** Return this.onControllerMeshLoadedObservable
  105529. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105530. */
  105531. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105532. private _rayLength;
  105533. private _useCustomVRButton;
  105534. private _teleportationRequested;
  105535. private _teleportActive;
  105536. private _floorMeshName;
  105537. private _floorMeshesCollection;
  105538. private _rotationAllowed;
  105539. private _teleportBackwardsVector;
  105540. private _teleportationTarget;
  105541. private _isDefaultTeleportationTarget;
  105542. private _postProcessMove;
  105543. private _teleportationFillColor;
  105544. private _teleportationBorderColor;
  105545. private _rotationAngle;
  105546. private _haloCenter;
  105547. private _cameraGazer;
  105548. private _padSensibilityUp;
  105549. private _padSensibilityDown;
  105550. private _leftController;
  105551. private _rightController;
  105552. /**
  105553. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105554. */
  105555. onNewMeshSelected: Observable<AbstractMesh>;
  105556. /**
  105557. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  105558. * This observable will provide the mesh and the controller used to select the mesh
  105559. */
  105560. onMeshSelectedWithController: Observable<{
  105561. mesh: AbstractMesh;
  105562. controller: WebVRController;
  105563. }>;
  105564. /**
  105565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105566. */
  105567. onNewMeshPicked: Observable<PickingInfo>;
  105568. private _circleEase;
  105569. /**
  105570. * Observable raised before camera teleportation
  105571. */
  105572. onBeforeCameraTeleport: Observable<Vector3>;
  105573. /**
  105574. * Observable raised after camera teleportation
  105575. */
  105576. onAfterCameraTeleport: Observable<Vector3>;
  105577. /**
  105578. * Observable raised when current selected mesh gets unselected
  105579. */
  105580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105581. private _raySelectionPredicate;
  105582. /**
  105583. * To be optionaly changed by user to define custom ray selection
  105584. */
  105585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105586. /**
  105587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105588. */
  105589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105590. /**
  105591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105592. */
  105593. teleportationEnabled: boolean;
  105594. private _defaultHeight;
  105595. private _teleportationInitialized;
  105596. private _interactionsEnabled;
  105597. private _interactionsRequested;
  105598. private _displayGaze;
  105599. private _displayLaserPointer;
  105600. /**
  105601. * The mesh used to display where the user is going to teleport.
  105602. */
  105603. /**
  105604. * Sets the mesh to be used to display where the user is going to teleport.
  105605. */
  105606. teleportationTarget: Mesh;
  105607. /**
  105608. * 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
  105609. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105610. * See http://doc.babylonjs.com/resources/baking_transformations
  105611. */
  105612. gazeTrackerMesh: Mesh;
  105613. /**
  105614. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105615. */
  105616. updateGazeTrackerScale: boolean;
  105617. /**
  105618. * If the gaze trackers color should be updated when selecting meshes
  105619. */
  105620. updateGazeTrackerColor: boolean;
  105621. /**
  105622. * The gaze tracking mesh corresponding to the left controller
  105623. */
  105624. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105625. /**
  105626. * The gaze tracking mesh corresponding to the right controller
  105627. */
  105628. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105629. /**
  105630. * If the ray of the gaze should be displayed.
  105631. */
  105632. /**
  105633. * Sets if the ray of the gaze should be displayed.
  105634. */
  105635. displayGaze: boolean;
  105636. /**
  105637. * If the ray of the LaserPointer should be displayed.
  105638. */
  105639. /**
  105640. * Sets if the ray of the LaserPointer should be displayed.
  105641. */
  105642. displayLaserPointer: boolean;
  105643. /**
  105644. * The deviceOrientationCamera used as the camera when not in VR.
  105645. */
  105646. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105647. /**
  105648. * Based on the current WebVR support, returns the current VR camera used.
  105649. */
  105650. readonly currentVRCamera: Nullable<Camera>;
  105651. /**
  105652. * The webVRCamera which is used when in VR.
  105653. */
  105654. readonly webVRCamera: WebVRFreeCamera;
  105655. /**
  105656. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105657. */
  105658. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105659. /**
  105660. * The html button that is used to trigger entering into VR.
  105661. */
  105662. readonly vrButton: Nullable<HTMLButtonElement>;
  105663. private readonly _teleportationRequestInitiated;
  105664. /**
  105665. * Defines wether or not Pointer lock should be requested when switching to
  105666. * full screen.
  105667. */
  105668. requestPointerLockOnFullScreen: boolean;
  105669. /**
  105670. * Instantiates a VRExperienceHelper.
  105671. * Helps to quickly add VR support to an existing scene.
  105672. * @param scene The scene the VRExperienceHelper belongs to.
  105673. * @param webVROptions Options to modify the vr experience helper's behavior.
  105674. */
  105675. constructor(scene: Scene,
  105676. /** Options to modify the vr experience helper's behavior. */
  105677. webVROptions?: VRExperienceHelperOptions);
  105678. private _onDefaultMeshLoaded;
  105679. private _onResize;
  105680. private _onFullscreenChange;
  105681. /**
  105682. * Gets a value indicating if we are currently in VR mode.
  105683. */
  105684. readonly isInVRMode: boolean;
  105685. private onVrDisplayPresentChange;
  105686. private onVRDisplayChanged;
  105687. private moveButtonToBottomRight;
  105688. private displayVRButton;
  105689. private updateButtonVisibility;
  105690. private _cachedAngularSensibility;
  105691. /**
  105692. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105693. * Otherwise, will use the fullscreen API.
  105694. */
  105695. enterVR(): void;
  105696. /**
  105697. * Attempt to exit VR, or fullscreen.
  105698. */
  105699. exitVR(): void;
  105700. /**
  105701. * The position of the vr experience helper.
  105702. */
  105703. /**
  105704. * Sets the position of the vr experience helper.
  105705. */
  105706. position: Vector3;
  105707. /**
  105708. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105709. */
  105710. enableInteractions(): void;
  105711. private readonly _noControllerIsActive;
  105712. private beforeRender;
  105713. private _isTeleportationFloor;
  105714. /**
  105715. * Adds a floor mesh to be used for teleportation.
  105716. * @param floorMesh the mesh to be used for teleportation.
  105717. */
  105718. addFloorMesh(floorMesh: Mesh): void;
  105719. /**
  105720. * Removes a floor mesh from being used for teleportation.
  105721. * @param floorMesh the mesh to be removed.
  105722. */
  105723. removeFloorMesh(floorMesh: Mesh): void;
  105724. /**
  105725. * Enables interactions and teleportation using the VR controllers and gaze.
  105726. * @param vrTeleportationOptions options to modify teleportation behavior.
  105727. */
  105728. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105729. private _onNewGamepadConnected;
  105730. private _tryEnableInteractionOnController;
  105731. private _onNewGamepadDisconnected;
  105732. private _enableInteractionOnController;
  105733. private _checkTeleportWithRay;
  105734. private _checkRotate;
  105735. private _checkTeleportBackwards;
  105736. private _enableTeleportationOnController;
  105737. private _createTeleportationCircles;
  105738. private _displayTeleportationTarget;
  105739. private _hideTeleportationTarget;
  105740. private _rotateCamera;
  105741. private _moveTeleportationSelectorTo;
  105742. private _workingVector;
  105743. private _workingQuaternion;
  105744. private _workingMatrix;
  105745. /**
  105746. * Teleports the users feet to the desired location
  105747. * @param location The location where the user's feet should be placed
  105748. */
  105749. teleportCamera(location: Vector3): void;
  105750. private _convertNormalToDirectionOfRay;
  105751. private _castRayAndSelectObject;
  105752. private _notifySelectedMeshUnselected;
  105753. /**
  105754. * Sets the color of the laser ray from the vr controllers.
  105755. * @param color new color for the ray.
  105756. */
  105757. changeLaserColor(color: Color3): void;
  105758. /**
  105759. * Sets the color of the ray from the vr headsets gaze.
  105760. * @param color new color for the ray.
  105761. */
  105762. changeGazeColor(color: Color3): void;
  105763. /**
  105764. * Exits VR and disposes of the vr experience helper
  105765. */
  105766. dispose(): void;
  105767. /**
  105768. * Gets the name of the VRExperienceHelper class
  105769. * @returns "VRExperienceHelper"
  105770. */
  105771. getClassName(): string;
  105772. }
  105773. }
  105774. declare module BABYLON {
  105775. /**
  105776. * Manages an XRSession to work with Babylon's engine
  105777. * @see https://doc.babylonjs.com/how_to/webxr
  105778. */
  105779. export class WebXRSessionManager implements IDisposable {
  105780. private scene;
  105781. /**
  105782. * Fires every time a new xrFrame arrives which can be used to update the camera
  105783. */
  105784. onXRFrameObservable: Observable<any>;
  105785. /**
  105786. * Fires when the xr session is ended either by the device or manually done
  105787. */
  105788. onXRSessionEnded: Observable<any>;
  105789. /**
  105790. * Underlying xr session
  105791. */
  105792. session: XRSession;
  105793. /**
  105794. * Type of reference space used when creating the session
  105795. */
  105796. referenceSpace: XRReferenceSpace;
  105797. /** @hidden */
  105798. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105799. /**
  105800. * Current XR frame
  105801. */
  105802. currentFrame: Nullable<XRFrame>;
  105803. private _xrNavigator;
  105804. private baseLayer;
  105805. /**
  105806. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105807. * @param scene The scene which the session should be created for
  105808. */
  105809. constructor(scene: Scene);
  105810. /**
  105811. * Initializes the manager
  105812. * After initialization enterXR can be called to start an XR session
  105813. * @returns Promise which resolves after it is initialized
  105814. */
  105815. initializeAsync(): Promise<void>;
  105816. /**
  105817. * Initializes an xr session
  105818. * @param xrSessionMode mode to initialize
  105819. * @returns a promise which will resolve once the session has been initialized
  105820. */
  105821. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105822. /**
  105823. * Sets the reference space on the xr session
  105824. * @param referenceSpace space to set
  105825. * @returns a promise that will resolve once the reference space has been set
  105826. */
  105827. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105828. /**
  105829. * Updates the render state of the session
  105830. * @param state state to set
  105831. * @returns a promise that resolves once the render state has been updated
  105832. */
  105833. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105834. /**
  105835. * Starts rendering to the xr layer
  105836. * @returns a promise that will resolve once rendering has started
  105837. */
  105838. startRenderingToXRAsync(): Promise<void>;
  105839. /**
  105840. * Stops the xrSession and restores the renderloop
  105841. * @returns Promise which resolves after it exits XR
  105842. */
  105843. exitXRAsync(): Promise<unknown>;
  105844. /**
  105845. * Checks if a session would be supported for the creation options specified
  105846. * @param sessionMode session mode to check if supported eg. immersive-vr
  105847. * @returns true if supported
  105848. */
  105849. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105850. /**
  105851. * @hidden
  105852. * Converts the render layer of xrSession to a render target
  105853. * @param session session to create render target for
  105854. * @param scene scene the new render target should be created for
  105855. */
  105856. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105857. /**
  105858. * Disposes of the session manager
  105859. */
  105860. dispose(): void;
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /**
  105865. * WebXR Camera which holds the views for the xrSession
  105866. * @see https://doc.babylonjs.com/how_to/webxr
  105867. */
  105868. export class WebXRCamera extends FreeCamera {
  105869. private static _TmpMatrix;
  105870. /**
  105871. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105872. * @param name the name of the camera
  105873. * @param scene the scene to add the camera to
  105874. */
  105875. constructor(name: string, scene: Scene);
  105876. private _updateNumberOfRigCameras;
  105877. /** @hidden */
  105878. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105879. /**
  105880. * Updates the cameras position from the current pose information of the XR session
  105881. * @param xrSessionManager the session containing pose information
  105882. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105883. */
  105884. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105885. }
  105886. }
  105887. declare module BABYLON {
  105888. /**
  105889. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105890. */
  105891. export class WebXRManagedOutputCanvas implements IDisposable {
  105892. private helper;
  105893. private _canvas;
  105894. /**
  105895. * xrpresent context of the canvas which can be used to display/mirror xr content
  105896. */
  105897. canvasContext: WebGLRenderingContext;
  105898. /**
  105899. * xr layer for the canvas
  105900. */
  105901. xrLayer: Nullable<XRWebGLLayer>;
  105902. /**
  105903. * Initializes the xr layer for the session
  105904. * @param xrSession xr session
  105905. * @returns a promise that will resolve once the XR Layer has been created
  105906. */
  105907. initializeXRLayerAsync(xrSession: any): any;
  105908. /**
  105909. * Initializes the canvas to be added/removed upon entering/exiting xr
  105910. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105911. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105912. */
  105913. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105914. /**
  105915. * Disposes of the object
  105916. */
  105917. dispose(): void;
  105918. private _setManagedOutputCanvas;
  105919. private _addCanvas;
  105920. private _removeCanvas;
  105921. }
  105922. }
  105923. declare module BABYLON {
  105924. /**
  105925. * States of the webXR experience
  105926. */
  105927. export enum WebXRState {
  105928. /**
  105929. * Transitioning to being in XR mode
  105930. */
  105931. ENTERING_XR = 0,
  105932. /**
  105933. * Transitioning to non XR mode
  105934. */
  105935. EXITING_XR = 1,
  105936. /**
  105937. * In XR mode and presenting
  105938. */
  105939. IN_XR = 2,
  105940. /**
  105941. * Not entered XR mode
  105942. */
  105943. NOT_IN_XR = 3
  105944. }
  105945. /**
  105946. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105947. * @see https://doc.babylonjs.com/how_to/webxr
  105948. */
  105949. export class WebXRExperienceHelper implements IDisposable {
  105950. private scene;
  105951. /**
  105952. * 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
  105953. */
  105954. container: AbstractMesh;
  105955. /**
  105956. * Camera used to render xr content
  105957. */
  105958. camera: WebXRCamera;
  105959. /**
  105960. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105961. */
  105962. state: WebXRState;
  105963. private _setState;
  105964. private static _TmpVector;
  105965. /**
  105966. * Fires when the state of the experience helper has changed
  105967. */
  105968. onStateChangedObservable: Observable<WebXRState>;
  105969. /** Session manager used to keep track of xr session */
  105970. sessionManager: WebXRSessionManager;
  105971. private _nonVRCamera;
  105972. private _originalSceneAutoClear;
  105973. private _supported;
  105974. /**
  105975. * Creates the experience helper
  105976. * @param scene the scene to attach the experience helper to
  105977. * @returns a promise for the experience helper
  105978. */
  105979. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105980. /**
  105981. * Creates a WebXRExperienceHelper
  105982. * @param scene The scene the helper should be created in
  105983. */
  105984. private constructor();
  105985. /**
  105986. * Exits XR mode and returns the scene to its original state
  105987. * @returns promise that resolves after xr mode has exited
  105988. */
  105989. exitXRAsync(): Promise<unknown>;
  105990. /**
  105991. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105992. * @param sessionCreationOptions options for the XR session
  105993. * @param referenceSpaceType frame of reference of the XR session
  105994. * @param outputCanvas the output canvas that will be used to enter XR mode
  105995. * @returns promise that resolves after xr mode has entered
  105996. */
  105997. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105998. /**
  105999. * Updates the global position of the camera by moving the camera's container
  106000. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106001. * @param position The desired global position of the camera
  106002. */
  106003. setPositionOfCameraUsingContainer(position: Vector3): void;
  106004. /**
  106005. * Rotates the xr camera by rotating the camera's container around the camera's position
  106006. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106007. * @param rotation the desired quaternion rotation to apply to the camera
  106008. */
  106009. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106010. /**
  106011. * Disposes of the experience helper
  106012. */
  106013. dispose(): void;
  106014. }
  106015. }
  106016. declare module BABYLON {
  106017. /**
  106018. * Button which can be used to enter a different mode of XR
  106019. */
  106020. export class WebXREnterExitUIButton {
  106021. /** button element */
  106022. element: HTMLElement;
  106023. /** XR initialization options for the button */
  106024. sessionMode: XRSessionMode;
  106025. /** Reference space type */
  106026. referenceSpaceType: XRReferenceSpaceType;
  106027. /**
  106028. * Creates a WebXREnterExitUIButton
  106029. * @param element button element
  106030. * @param sessionMode XR initialization session mode
  106031. * @param referenceSpaceType the type of reference space to be used
  106032. */
  106033. constructor(
  106034. /** button element */
  106035. element: HTMLElement,
  106036. /** XR initialization options for the button */
  106037. sessionMode: XRSessionMode,
  106038. /** Reference space type */
  106039. referenceSpaceType: XRReferenceSpaceType);
  106040. /**
  106041. * Overwritable function which can be used to update the button's visuals when the state changes
  106042. * @param activeButton the current active button in the UI
  106043. */
  106044. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106045. }
  106046. /**
  106047. * Options to create the webXR UI
  106048. */
  106049. export class WebXREnterExitUIOptions {
  106050. /**
  106051. * Context to enter xr with
  106052. */
  106053. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106054. /**
  106055. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106056. */
  106057. customButtons?: Array<WebXREnterExitUIButton>;
  106058. }
  106059. /**
  106060. * UI to allow the user to enter/exit XR mode
  106061. */
  106062. export class WebXREnterExitUI implements IDisposable {
  106063. private scene;
  106064. private _overlay;
  106065. private _buttons;
  106066. private _activeButton;
  106067. /**
  106068. * Fired every time the active button is changed.
  106069. *
  106070. * When xr is entered via a button that launches xr that button will be the callback parameter
  106071. *
  106072. * When exiting xr the callback parameter will be null)
  106073. */
  106074. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106075. /**
  106076. * Creates UI to allow the user to enter/exit XR mode
  106077. * @param scene the scene to add the ui to
  106078. * @param helper the xr experience helper to enter/exit xr with
  106079. * @param options options to configure the UI
  106080. * @returns the created ui
  106081. */
  106082. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106083. private constructor();
  106084. private _updateButtons;
  106085. /**
  106086. * Disposes of the object
  106087. */
  106088. dispose(): void;
  106089. }
  106090. }
  106091. declare module BABYLON {
  106092. /**
  106093. * Represents an XR input
  106094. */
  106095. export class WebXRController {
  106096. private scene;
  106097. /** The underlying input source for the controller */
  106098. inputSource: XRInputSource;
  106099. private parentContainer;
  106100. /**
  106101. * 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
  106102. */
  106103. grip?: AbstractMesh;
  106104. /**
  106105. * Pointer which can be used to select objects or attach a visible laser to
  106106. */
  106107. pointer: AbstractMesh;
  106108. /**
  106109. * Event that fires when the controller is removed/disposed
  106110. */
  106111. onDisposeObservable: Observable<{}>;
  106112. private _tmpMatrix;
  106113. private _tmpQuaternion;
  106114. private _tmpVector;
  106115. /**
  106116. * Creates the controller
  106117. * @see https://doc.babylonjs.com/how_to/webxr
  106118. * @param scene the scene which the controller should be associated to
  106119. * @param inputSource the underlying input source for the controller
  106120. * @param parentContainer parent that the controller meshes should be children of
  106121. */
  106122. constructor(scene: Scene,
  106123. /** The underlying input source for the controller */
  106124. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  106125. /**
  106126. * Updates the controller pose based on the given XRFrame
  106127. * @param xrFrame xr frame to update the pose with
  106128. * @param referenceSpace reference space to use
  106129. */
  106130. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  106131. /**
  106132. * Gets a world space ray coming from the controller
  106133. * @param result the resulting ray
  106134. */
  106135. getWorldPointerRayToRef(result: Ray): void;
  106136. /**
  106137. * Disposes of the object
  106138. */
  106139. dispose(): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * XR input used to track XR inputs such as controllers/rays
  106145. */
  106146. export class WebXRInput implements IDisposable {
  106147. /**
  106148. * Base experience the input listens to
  106149. */
  106150. baseExperience: WebXRExperienceHelper;
  106151. /**
  106152. * XR controllers being tracked
  106153. */
  106154. controllers: Array<WebXRController>;
  106155. private _frameObserver;
  106156. private _stateObserver;
  106157. /**
  106158. * Event when a controller has been connected/added
  106159. */
  106160. onControllerAddedObservable: Observable<WebXRController>;
  106161. /**
  106162. * Event when a controller has been removed/disconnected
  106163. */
  106164. onControllerRemovedObservable: Observable<WebXRController>;
  106165. /**
  106166. * Initializes the WebXRInput
  106167. * @param baseExperience experience helper which the input should be created for
  106168. */
  106169. constructor(
  106170. /**
  106171. * Base experience the input listens to
  106172. */
  106173. baseExperience: WebXRExperienceHelper);
  106174. private _onInputSourcesChange;
  106175. private _addAndRemoveControllers;
  106176. /**
  106177. * Disposes of the object
  106178. */
  106179. dispose(): void;
  106180. }
  106181. }
  106182. declare module BABYLON {
  106183. /**
  106184. * Enables teleportation
  106185. */
  106186. export class WebXRControllerTeleportation {
  106187. private _teleportationFillColor;
  106188. private _teleportationBorderColor;
  106189. private _tmpRay;
  106190. private _tmpVector;
  106191. /**
  106192. * Creates a WebXRControllerTeleportation
  106193. * @param input input manager to add teleportation to
  106194. * @param floorMeshes floormeshes which can be teleported to
  106195. */
  106196. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106197. }
  106198. }
  106199. declare module BABYLON {
  106200. /**
  106201. * Handles pointer input automatically for the pointer of XR controllers
  106202. */
  106203. export class WebXRControllerPointerSelection {
  106204. private static _idCounter;
  106205. private _tmpRay;
  106206. /**
  106207. * Creates a WebXRControllerPointerSelection
  106208. * @param input input manager to setup pointer selection
  106209. */
  106210. constructor(input: WebXRInput);
  106211. private _convertNormalToDirectionOfRay;
  106212. private _updatePointerDistance;
  106213. }
  106214. }
  106215. declare module BABYLON {
  106216. /**
  106217. * Class used to represent data loading progression
  106218. */
  106219. export class SceneLoaderProgressEvent {
  106220. /** defines if data length to load can be evaluated */
  106221. readonly lengthComputable: boolean;
  106222. /** defines the loaded data length */
  106223. readonly loaded: number;
  106224. /** defines the data length to load */
  106225. readonly total: number;
  106226. /**
  106227. * Create a new progress event
  106228. * @param lengthComputable defines if data length to load can be evaluated
  106229. * @param loaded defines the loaded data length
  106230. * @param total defines the data length to load
  106231. */
  106232. constructor(
  106233. /** defines if data length to load can be evaluated */
  106234. lengthComputable: boolean,
  106235. /** defines the loaded data length */
  106236. loaded: number,
  106237. /** defines the data length to load */
  106238. total: number);
  106239. /**
  106240. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106241. * @param event defines the source event
  106242. * @returns a new SceneLoaderProgressEvent
  106243. */
  106244. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106245. }
  106246. /**
  106247. * Interface used by SceneLoader plugins to define supported file extensions
  106248. */
  106249. export interface ISceneLoaderPluginExtensions {
  106250. /**
  106251. * Defines the list of supported extensions
  106252. */
  106253. [extension: string]: {
  106254. isBinary: boolean;
  106255. };
  106256. }
  106257. /**
  106258. * Interface used by SceneLoader plugin factory
  106259. */
  106260. export interface ISceneLoaderPluginFactory {
  106261. /**
  106262. * Defines the name of the factory
  106263. */
  106264. name: string;
  106265. /**
  106266. * Function called to create a new plugin
  106267. * @return the new plugin
  106268. */
  106269. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106270. /**
  106271. * Boolean indicating if the plugin can direct load specific data
  106272. */
  106273. canDirectLoad?: (data: string) => boolean;
  106274. }
  106275. /**
  106276. * Interface used to define a SceneLoader plugin
  106277. */
  106278. export interface ISceneLoaderPlugin {
  106279. /**
  106280. * The friendly name of this plugin.
  106281. */
  106282. name: string;
  106283. /**
  106284. * The file extensions supported by this plugin.
  106285. */
  106286. extensions: string | ISceneLoaderPluginExtensions;
  106287. /**
  106288. * Import meshes into a scene.
  106289. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106290. * @param scene The scene to import into
  106291. * @param data The data to import
  106292. * @param rootUrl The root url for scene and resources
  106293. * @param meshes The meshes array to import into
  106294. * @param particleSystems The particle systems array to import into
  106295. * @param skeletons The skeletons array to import into
  106296. * @param onError The callback when import fails
  106297. * @returns True if successful or false otherwise
  106298. */
  106299. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106300. /**
  106301. * Load into a scene.
  106302. * @param scene The scene to load into
  106303. * @param data The data to import
  106304. * @param rootUrl The root url for scene and resources
  106305. * @param onError The callback when import fails
  106306. * @returns true if successful or false otherwise
  106307. */
  106308. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106309. /**
  106310. * The callback that returns true if the data can be directly loaded.
  106311. */
  106312. canDirectLoad?: (data: string) => boolean;
  106313. /**
  106314. * The callback that allows custom handling of the root url based on the response url.
  106315. */
  106316. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106317. /**
  106318. * Load into an asset container.
  106319. * @param scene The scene to load into
  106320. * @param data The data to import
  106321. * @param rootUrl The root url for scene and resources
  106322. * @param onError The callback when import fails
  106323. * @returns The loaded asset container
  106324. */
  106325. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106326. }
  106327. /**
  106328. * Interface used to define an async SceneLoader plugin
  106329. */
  106330. export interface ISceneLoaderPluginAsync {
  106331. /**
  106332. * The friendly name of this plugin.
  106333. */
  106334. name: string;
  106335. /**
  106336. * The file extensions supported by this plugin.
  106337. */
  106338. extensions: string | ISceneLoaderPluginExtensions;
  106339. /**
  106340. * Import meshes into a scene.
  106341. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106342. * @param scene The scene to import into
  106343. * @param data The data to import
  106344. * @param rootUrl The root url for scene and resources
  106345. * @param onProgress The callback when the load progresses
  106346. * @param fileName Defines the name of the file to load
  106347. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106348. */
  106349. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106350. meshes: AbstractMesh[];
  106351. particleSystems: IParticleSystem[];
  106352. skeletons: Skeleton[];
  106353. animationGroups: AnimationGroup[];
  106354. }>;
  106355. /**
  106356. * Load into a scene.
  106357. * @param scene The scene to load into
  106358. * @param data The data to import
  106359. * @param rootUrl The root url for scene and resources
  106360. * @param onProgress The callback when the load progresses
  106361. * @param fileName Defines the name of the file to load
  106362. * @returns Nothing
  106363. */
  106364. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106365. /**
  106366. * The callback that returns true if the data can be directly loaded.
  106367. */
  106368. canDirectLoad?: (data: string) => boolean;
  106369. /**
  106370. * The callback that allows custom handling of the root url based on the response url.
  106371. */
  106372. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106373. /**
  106374. * Load into an asset container.
  106375. * @param scene The scene to load into
  106376. * @param data The data to import
  106377. * @param rootUrl The root url for scene and resources
  106378. * @param onProgress The callback when the load progresses
  106379. * @param fileName Defines the name of the file to load
  106380. * @returns The loaded asset container
  106381. */
  106382. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106383. }
  106384. /**
  106385. * Class used to load scene from various file formats using registered plugins
  106386. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106387. */
  106388. export class SceneLoader {
  106389. /**
  106390. * No logging while loading
  106391. */
  106392. static readonly NO_LOGGING: number;
  106393. /**
  106394. * Minimal logging while loading
  106395. */
  106396. static readonly MINIMAL_LOGGING: number;
  106397. /**
  106398. * Summary logging while loading
  106399. */
  106400. static readonly SUMMARY_LOGGING: number;
  106401. /**
  106402. * Detailled logging while loading
  106403. */
  106404. static readonly DETAILED_LOGGING: number;
  106405. /**
  106406. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106407. */
  106408. static ForceFullSceneLoadingForIncremental: boolean;
  106409. /**
  106410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106411. */
  106412. static ShowLoadingScreen: boolean;
  106413. /**
  106414. * Defines the current logging level (while loading the scene)
  106415. * @ignorenaming
  106416. */
  106417. static loggingLevel: number;
  106418. /**
  106419. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106420. */
  106421. static CleanBoneMatrixWeights: boolean;
  106422. /**
  106423. * Event raised when a plugin is used to load a scene
  106424. */
  106425. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106426. private static _registeredPlugins;
  106427. private static _getDefaultPlugin;
  106428. private static _getPluginForExtension;
  106429. private static _getPluginForDirectLoad;
  106430. private static _getPluginForFilename;
  106431. private static _getDirectLoad;
  106432. private static _loadData;
  106433. private static _getFileInfo;
  106434. /**
  106435. * Gets a plugin that can load the given extension
  106436. * @param extension defines the extension to load
  106437. * @returns a plugin or null if none works
  106438. */
  106439. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106440. /**
  106441. * Gets a boolean indicating that the given extension can be loaded
  106442. * @param extension defines the extension to load
  106443. * @returns true if the extension is supported
  106444. */
  106445. static IsPluginForExtensionAvailable(extension: string): boolean;
  106446. /**
  106447. * Adds a new plugin to the list of registered plugins
  106448. * @param plugin defines the plugin to add
  106449. */
  106450. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106451. /**
  106452. * Import meshes into a scene
  106453. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106454. * @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)
  106455. * @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)
  106456. * @param scene the instance of BABYLON.Scene to append to
  106457. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106458. * @param onProgress a callback with a progress event for each file being loaded
  106459. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106460. * @param pluginExtension the extension used to determine the plugin
  106461. * @returns The loaded plugin
  106462. */
  106463. 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>;
  106464. /**
  106465. * Import meshes into a scene
  106466. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106467. * @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)
  106468. * @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)
  106469. * @param scene the instance of BABYLON.Scene to append to
  106470. * @param onProgress a callback with a progress event for each file being loaded
  106471. * @param pluginExtension the extension used to determine the plugin
  106472. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106473. */
  106474. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106475. meshes: AbstractMesh[];
  106476. particleSystems: IParticleSystem[];
  106477. skeletons: Skeleton[];
  106478. animationGroups: AnimationGroup[];
  106479. }>;
  106480. /**
  106481. * Load a scene
  106482. * @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)
  106483. * @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)
  106484. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106485. * @param onSuccess a callback with the scene when import succeeds
  106486. * @param onProgress a callback with a progress event for each file being loaded
  106487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106488. * @param pluginExtension the extension used to determine the plugin
  106489. * @returns The loaded plugin
  106490. */
  106491. 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>;
  106492. /**
  106493. * Load a scene
  106494. * @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)
  106495. * @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)
  106496. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106497. * @param onProgress a callback with a progress event for each file being loaded
  106498. * @param pluginExtension the extension used to determine the plugin
  106499. * @returns The loaded scene
  106500. */
  106501. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106502. /**
  106503. * Append a scene
  106504. * @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)
  106505. * @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)
  106506. * @param scene is the instance of BABYLON.Scene to append to
  106507. * @param onSuccess a callback with the scene when import succeeds
  106508. * @param onProgress a callback with a progress event for each file being loaded
  106509. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106510. * @param pluginExtension the extension used to determine the plugin
  106511. * @returns The loaded plugin
  106512. */
  106513. 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>;
  106514. /**
  106515. * Append a scene
  106516. * @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)
  106517. * @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)
  106518. * @param scene is the instance of BABYLON.Scene to append to
  106519. * @param onProgress a callback with a progress event for each file being loaded
  106520. * @param pluginExtension the extension used to determine the plugin
  106521. * @returns The given scene
  106522. */
  106523. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106524. /**
  106525. * Load a scene into an asset container
  106526. * @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)
  106527. * @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)
  106528. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106529. * @param onSuccess a callback with the scene when import succeeds
  106530. * @param onProgress a callback with a progress event for each file being loaded
  106531. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106532. * @param pluginExtension the extension used to determine the plugin
  106533. * @returns The loaded plugin
  106534. */
  106535. 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>;
  106536. /**
  106537. * Load a scene into an asset container
  106538. * @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)
  106539. * @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)
  106540. * @param scene is the instance of Scene to append to
  106541. * @param onProgress a callback with a progress event for each file being loaded
  106542. * @param pluginExtension the extension used to determine the plugin
  106543. * @returns The loaded asset container
  106544. */
  106545. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106546. }
  106547. }
  106548. declare module BABYLON {
  106549. /**
  106550. * Generic Controller
  106551. */
  106552. export class GenericController extends WebVRController {
  106553. /**
  106554. * Base Url for the controller model.
  106555. */
  106556. static readonly MODEL_BASE_URL: string;
  106557. /**
  106558. * File name for the controller model.
  106559. */
  106560. static readonly MODEL_FILENAME: string;
  106561. /**
  106562. * Creates a new GenericController from a gamepad
  106563. * @param vrGamepad the gamepad that the controller should be created from
  106564. */
  106565. constructor(vrGamepad: any);
  106566. /**
  106567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106568. * @param scene scene in which to add meshes
  106569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106570. */
  106571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106572. /**
  106573. * Called once for each button that changed state since the last frame
  106574. * @param buttonIdx Which button index changed
  106575. * @param state New state of the button
  106576. * @param changes Which properties on the state changed since last frame
  106577. */
  106578. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106579. }
  106580. }
  106581. declare module BABYLON {
  106582. /**
  106583. * Defines the WindowsMotionController object that the state of the windows motion controller
  106584. */
  106585. export class WindowsMotionController extends WebVRController {
  106586. /**
  106587. * The base url used to load the left and right controller models
  106588. */
  106589. static MODEL_BASE_URL: string;
  106590. /**
  106591. * The name of the left controller model file
  106592. */
  106593. static MODEL_LEFT_FILENAME: string;
  106594. /**
  106595. * The name of the right controller model file
  106596. */
  106597. static MODEL_RIGHT_FILENAME: string;
  106598. /**
  106599. * The controller name prefix for this controller type
  106600. */
  106601. static readonly GAMEPAD_ID_PREFIX: string;
  106602. /**
  106603. * The controller id pattern for this controller type
  106604. */
  106605. private static readonly GAMEPAD_ID_PATTERN;
  106606. private _loadedMeshInfo;
  106607. private readonly _mapping;
  106608. /**
  106609. * Fired when the trackpad on this controller is clicked
  106610. */
  106611. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106612. /**
  106613. * Fired when the trackpad on this controller is modified
  106614. */
  106615. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106616. /**
  106617. * The current x and y values of this controller's trackpad
  106618. */
  106619. trackpad: StickValues;
  106620. /**
  106621. * Creates a new WindowsMotionController from a gamepad
  106622. * @param vrGamepad the gamepad that the controller should be created from
  106623. */
  106624. constructor(vrGamepad: any);
  106625. /**
  106626. * Fired when the trigger on this controller is modified
  106627. */
  106628. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106629. /**
  106630. * Fired when the menu button on this controller is modified
  106631. */
  106632. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106633. /**
  106634. * Fired when the grip button on this controller is modified
  106635. */
  106636. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106637. /**
  106638. * Fired when the thumbstick button on this controller is modified
  106639. */
  106640. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106641. /**
  106642. * Fired when the touchpad button on this controller is modified
  106643. */
  106644. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106645. /**
  106646. * Fired when the touchpad values on this controller are modified
  106647. */
  106648. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106649. private _updateTrackpad;
  106650. /**
  106651. * Called once per frame by the engine.
  106652. */
  106653. update(): void;
  106654. /**
  106655. * Called once for each button that changed state since the last frame
  106656. * @param buttonIdx Which button index changed
  106657. * @param state New state of the button
  106658. * @param changes Which properties on the state changed since last frame
  106659. */
  106660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106661. /**
  106662. * Moves the buttons on the controller mesh based on their current state
  106663. * @param buttonName the name of the button to move
  106664. * @param buttonValue the value of the button which determines the buttons new position
  106665. */
  106666. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106667. /**
  106668. * Moves the axis on the controller mesh based on its current state
  106669. * @param axis the index of the axis
  106670. * @param axisValue the value of the axis which determines the meshes new position
  106671. * @hidden
  106672. */
  106673. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106674. /**
  106675. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106676. * @param scene scene in which to add meshes
  106677. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106678. */
  106679. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106680. /**
  106681. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106682. * can be transformed by button presses and axes values, based on this._mapping.
  106683. *
  106684. * @param scene scene in which the meshes exist
  106685. * @param meshes list of meshes that make up the controller model to process
  106686. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106687. */
  106688. private processModel;
  106689. private createMeshInfo;
  106690. /**
  106691. * Gets the ray of the controller in the direction the controller is pointing
  106692. * @param length the length the resulting ray should be
  106693. * @returns a ray in the direction the controller is pointing
  106694. */
  106695. getForwardRay(length?: number): Ray;
  106696. /**
  106697. * Disposes of the controller
  106698. */
  106699. dispose(): void;
  106700. }
  106701. }
  106702. declare module BABYLON {
  106703. /**
  106704. * Oculus Touch Controller
  106705. */
  106706. export class OculusTouchController extends WebVRController {
  106707. /**
  106708. * Base Url for the controller model.
  106709. */
  106710. static MODEL_BASE_URL: string;
  106711. /**
  106712. * File name for the left controller model.
  106713. */
  106714. static MODEL_LEFT_FILENAME: string;
  106715. /**
  106716. * File name for the right controller model.
  106717. */
  106718. static MODEL_RIGHT_FILENAME: string;
  106719. /**
  106720. * Base Url for the Quest controller model.
  106721. */
  106722. static QUEST_MODEL_BASE_URL: string;
  106723. /**
  106724. * @hidden
  106725. * If the controllers are running on a device that needs the updated Quest controller models
  106726. */
  106727. static _IsQuest: boolean;
  106728. /**
  106729. * Fired when the secondary trigger on this controller is modified
  106730. */
  106731. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106732. /**
  106733. * Fired when the thumb rest on this controller is modified
  106734. */
  106735. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106736. /**
  106737. * Creates a new OculusTouchController from a gamepad
  106738. * @param vrGamepad the gamepad that the controller should be created from
  106739. */
  106740. constructor(vrGamepad: any);
  106741. /**
  106742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106743. * @param scene scene in which to add meshes
  106744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106745. */
  106746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106747. /**
  106748. * Fired when the A button on this controller is modified
  106749. */
  106750. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106751. /**
  106752. * Fired when the B button on this controller is modified
  106753. */
  106754. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106755. /**
  106756. * Fired when the X button on this controller is modified
  106757. */
  106758. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106759. /**
  106760. * Fired when the Y button on this controller is modified
  106761. */
  106762. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106763. /**
  106764. * Called once for each button that changed state since the last frame
  106765. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106766. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106767. * 2) secondary trigger (same)
  106768. * 3) A (right) X (left), touch, pressed = value
  106769. * 4) B / Y
  106770. * 5) thumb rest
  106771. * @param buttonIdx Which button index changed
  106772. * @param state New state of the button
  106773. * @param changes Which properties on the state changed since last frame
  106774. */
  106775. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106776. }
  106777. }
  106778. declare module BABYLON {
  106779. /**
  106780. * Vive Controller
  106781. */
  106782. export class ViveController extends WebVRController {
  106783. /**
  106784. * Base Url for the controller model.
  106785. */
  106786. static MODEL_BASE_URL: string;
  106787. /**
  106788. * File name for the controller model.
  106789. */
  106790. static MODEL_FILENAME: string;
  106791. /**
  106792. * Creates a new ViveController from a gamepad
  106793. * @param vrGamepad the gamepad that the controller should be created from
  106794. */
  106795. constructor(vrGamepad: any);
  106796. /**
  106797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106798. * @param scene scene in which to add meshes
  106799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106800. */
  106801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106802. /**
  106803. * Fired when the left button on this controller is modified
  106804. */
  106805. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106806. /**
  106807. * Fired when the right button on this controller is modified
  106808. */
  106809. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106810. /**
  106811. * Fired when the menu button on this controller is modified
  106812. */
  106813. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106814. /**
  106815. * Called once for each button that changed state since the last frame
  106816. * Vive mapping:
  106817. * 0: touchpad
  106818. * 1: trigger
  106819. * 2: left AND right buttons
  106820. * 3: menu button
  106821. * @param buttonIdx Which button index changed
  106822. * @param state New state of the button
  106823. * @param changes Which properties on the state changed since last frame
  106824. */
  106825. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106826. }
  106827. }
  106828. declare module BABYLON {
  106829. /**
  106830. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106831. */
  106832. export class WebXRControllerModelLoader {
  106833. /**
  106834. * Creates the WebXRControllerModelLoader
  106835. * @param input xr input that creates the controllers
  106836. */
  106837. constructor(input: WebXRInput);
  106838. }
  106839. }
  106840. declare module BABYLON {
  106841. /**
  106842. * Contains an array of blocks representing the octree
  106843. */
  106844. export interface IOctreeContainer<T> {
  106845. /**
  106846. * Blocks within the octree
  106847. */
  106848. blocks: Array<OctreeBlock<T>>;
  106849. }
  106850. /**
  106851. * Class used to store a cell in an octree
  106852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106853. */
  106854. export class OctreeBlock<T> {
  106855. /**
  106856. * Gets the content of the current block
  106857. */
  106858. entries: T[];
  106859. /**
  106860. * Gets the list of block children
  106861. */
  106862. blocks: Array<OctreeBlock<T>>;
  106863. private _depth;
  106864. private _maxDepth;
  106865. private _capacity;
  106866. private _minPoint;
  106867. private _maxPoint;
  106868. private _boundingVectors;
  106869. private _creationFunc;
  106870. /**
  106871. * Creates a new block
  106872. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106873. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106874. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106875. * @param depth defines the current depth of this block in the octree
  106876. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106877. * @param creationFunc defines a callback to call when an element is added to the block
  106878. */
  106879. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106880. /**
  106881. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106882. */
  106883. readonly capacity: number;
  106884. /**
  106885. * Gets the minimum vector (in world space) of the block's bounding box
  106886. */
  106887. readonly minPoint: Vector3;
  106888. /**
  106889. * Gets the maximum vector (in world space) of the block's bounding box
  106890. */
  106891. readonly maxPoint: Vector3;
  106892. /**
  106893. * Add a new element to this block
  106894. * @param entry defines the element to add
  106895. */
  106896. addEntry(entry: T): void;
  106897. /**
  106898. * Remove an element from this block
  106899. * @param entry defines the element to remove
  106900. */
  106901. removeEntry(entry: T): void;
  106902. /**
  106903. * Add an array of elements to this block
  106904. * @param entries defines the array of elements to add
  106905. */
  106906. addEntries(entries: T[]): void;
  106907. /**
  106908. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106909. * @param frustumPlanes defines the frustum planes to test
  106910. * @param selection defines the array to store current content if selection is positive
  106911. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106912. */
  106913. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106914. /**
  106915. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106916. * @param sphereCenter defines the bounding sphere center
  106917. * @param sphereRadius defines the bounding sphere radius
  106918. * @param selection defines the array to store current content if selection is positive
  106919. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106920. */
  106921. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106922. /**
  106923. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106924. * @param ray defines the ray to test with
  106925. * @param selection defines the array to store current content if selection is positive
  106926. */
  106927. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106928. /**
  106929. * Subdivide the content into child blocks (this block will then be empty)
  106930. */
  106931. createInnerBlocks(): void;
  106932. /**
  106933. * @hidden
  106934. */
  106935. 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;
  106936. }
  106937. }
  106938. declare module BABYLON {
  106939. /**
  106940. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106942. */
  106943. export class Octree<T> {
  106944. /** 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.) */
  106945. maxDepth: number;
  106946. /**
  106947. * Blocks within the octree containing objects
  106948. */
  106949. blocks: Array<OctreeBlock<T>>;
  106950. /**
  106951. * Content stored in the octree
  106952. */
  106953. dynamicContent: T[];
  106954. private _maxBlockCapacity;
  106955. private _selectionContent;
  106956. private _creationFunc;
  106957. /**
  106958. * Creates a octree
  106959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106960. * @param creationFunc function to be used to instatiate the octree
  106961. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106962. * @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.)
  106963. */
  106964. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106965. /** 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.) */
  106966. maxDepth?: number);
  106967. /**
  106968. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106969. * @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);
  106970. * @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);
  106971. * @param entries meshes to be added to the octree blocks
  106972. */
  106973. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106974. /**
  106975. * Adds a mesh to the octree
  106976. * @param entry Mesh to add to the octree
  106977. */
  106978. addMesh(entry: T): void;
  106979. /**
  106980. * Remove an element from the octree
  106981. * @param entry defines the element to remove
  106982. */
  106983. removeMesh(entry: T): void;
  106984. /**
  106985. * Selects an array of meshes within the frustum
  106986. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106987. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106988. * @returns array of meshes within the frustum
  106989. */
  106990. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106991. /**
  106992. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106993. * @param sphereCenter defines the bounding sphere center
  106994. * @param sphereRadius defines the bounding sphere radius
  106995. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106996. * @returns an array of objects that intersect the sphere
  106997. */
  106998. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106999. /**
  107000. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107001. * @param ray defines the ray to test with
  107002. * @returns array of intersected objects
  107003. */
  107004. intersectsRay(ray: Ray): SmartArray<T>;
  107005. /**
  107006. * Adds a mesh into the octree block if it intersects the block
  107007. */
  107008. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107009. /**
  107010. * Adds a submesh into the octree block if it intersects the block
  107011. */
  107012. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107013. }
  107014. }
  107015. declare module BABYLON {
  107016. interface Scene {
  107017. /**
  107018. * @hidden
  107019. * Backing Filed
  107020. */
  107021. _selectionOctree: Octree<AbstractMesh>;
  107022. /**
  107023. * Gets the octree used to boost mesh selection (picking)
  107024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107025. */
  107026. selectionOctree: Octree<AbstractMesh>;
  107027. /**
  107028. * Creates or updates the octree used to boost selection (picking)
  107029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107030. * @param maxCapacity defines the maximum capacity per leaf
  107031. * @param maxDepth defines the maximum depth of the octree
  107032. * @returns an octree of AbstractMesh
  107033. */
  107034. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107035. }
  107036. interface AbstractMesh {
  107037. /**
  107038. * @hidden
  107039. * Backing Field
  107040. */
  107041. _submeshesOctree: Octree<SubMesh>;
  107042. /**
  107043. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107044. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107045. * @param maxCapacity defines the maximum size of each block (64 by default)
  107046. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107047. * @returns the new octree
  107048. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107050. */
  107051. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107052. }
  107053. /**
  107054. * Defines the octree scene component responsible to manage any octrees
  107055. * in a given scene.
  107056. */
  107057. export class OctreeSceneComponent {
  107058. /**
  107059. * The component name help to identify the component in the list of scene components.
  107060. */
  107061. readonly name: string;
  107062. /**
  107063. * The scene the component belongs to.
  107064. */
  107065. scene: Scene;
  107066. /**
  107067. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107068. */
  107069. readonly checksIsEnabled: boolean;
  107070. /**
  107071. * Creates a new instance of the component for the given scene
  107072. * @param scene Defines the scene to register the component in
  107073. */
  107074. constructor(scene: Scene);
  107075. /**
  107076. * Registers the component in a given scene
  107077. */
  107078. register(): void;
  107079. /**
  107080. * Return the list of active meshes
  107081. * @returns the list of active meshes
  107082. */
  107083. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107084. /**
  107085. * Return the list of active sub meshes
  107086. * @param mesh The mesh to get the candidates sub meshes from
  107087. * @returns the list of active sub meshes
  107088. */
  107089. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107090. private _tempRay;
  107091. /**
  107092. * Return the list of sub meshes intersecting with a given local ray
  107093. * @param mesh defines the mesh to find the submesh for
  107094. * @param localRay defines the ray in local space
  107095. * @returns the list of intersecting sub meshes
  107096. */
  107097. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107098. /**
  107099. * Return the list of sub meshes colliding with a collider
  107100. * @param mesh defines the mesh to find the submesh for
  107101. * @param collider defines the collider to evaluate the collision against
  107102. * @returns the list of colliding sub meshes
  107103. */
  107104. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107105. /**
  107106. * Rebuilds the elements related to this component in case of
  107107. * context lost for instance.
  107108. */
  107109. rebuild(): void;
  107110. /**
  107111. * Disposes the component and the associated ressources.
  107112. */
  107113. dispose(): void;
  107114. }
  107115. }
  107116. declare module BABYLON {
  107117. /**
  107118. * Renders a layer on top of an existing scene
  107119. */
  107120. export class UtilityLayerRenderer implements IDisposable {
  107121. /** the original scene that will be rendered on top of */
  107122. originalScene: Scene;
  107123. private _pointerCaptures;
  107124. private _lastPointerEvents;
  107125. private static _DefaultUtilityLayer;
  107126. private static _DefaultKeepDepthUtilityLayer;
  107127. private _sharedGizmoLight;
  107128. private _renderCamera;
  107129. /**
  107130. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  107131. * @returns the camera that is used when rendering the utility layer
  107132. */
  107133. getRenderCamera(): Nullable<Camera>;
  107134. /**
  107135. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  107136. * @param cam the camera that should be used when rendering the utility layer
  107137. */
  107138. setRenderCamera(cam: Nullable<Camera>): void;
  107139. /**
  107140. * @hidden
  107141. * Light which used by gizmos to get light shading
  107142. */
  107143. _getSharedGizmoLight(): HemisphericLight;
  107144. /**
  107145. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  107146. */
  107147. pickUtilitySceneFirst: boolean;
  107148. /**
  107149. * 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)
  107150. */
  107151. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  107152. /**
  107153. * 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)
  107154. */
  107155. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  107156. /**
  107157. * The scene that is rendered on top of the original scene
  107158. */
  107159. utilityLayerScene: Scene;
  107160. /**
  107161. * If the utility layer should automatically be rendered on top of existing scene
  107162. */
  107163. shouldRender: boolean;
  107164. /**
  107165. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107166. */
  107167. onlyCheckPointerDownEvents: boolean;
  107168. /**
  107169. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107170. */
  107171. processAllEvents: boolean;
  107172. /**
  107173. * Observable raised when the pointer move from the utility layer scene to the main scene
  107174. */
  107175. onPointerOutObservable: Observable<number>;
  107176. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107177. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107178. private _afterRenderObserver;
  107179. private _sceneDisposeObserver;
  107180. private _originalPointerObserver;
  107181. /**
  107182. * Instantiates a UtilityLayerRenderer
  107183. * @param originalScene the original scene that will be rendered on top of
  107184. * @param handleEvents boolean indicating if the utility layer should handle events
  107185. */
  107186. constructor(
  107187. /** the original scene that will be rendered on top of */
  107188. originalScene: Scene, handleEvents?: boolean);
  107189. private _notifyObservers;
  107190. /**
  107191. * Renders the utility layers scene on top of the original scene
  107192. */
  107193. render(): void;
  107194. /**
  107195. * Disposes of the renderer
  107196. */
  107197. dispose(): void;
  107198. private _updateCamera;
  107199. }
  107200. }
  107201. declare module BABYLON {
  107202. /**
  107203. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107204. */
  107205. export class Gizmo implements IDisposable {
  107206. /** The utility layer the gizmo will be added to */
  107207. gizmoLayer: UtilityLayerRenderer;
  107208. /**
  107209. * The root mesh of the gizmo
  107210. */
  107211. _rootMesh: Mesh;
  107212. private _attachedMesh;
  107213. /**
  107214. * Ratio for the scale of the gizmo (Default: 1)
  107215. */
  107216. scaleRatio: number;
  107217. /**
  107218. * If a custom mesh has been set (Default: false)
  107219. */
  107220. protected _customMeshSet: boolean;
  107221. /**
  107222. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107223. * * When set, interactions will be enabled
  107224. */
  107225. attachedMesh: Nullable<AbstractMesh>;
  107226. /**
  107227. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107228. * @param mesh The mesh to replace the default mesh of the gizmo
  107229. */
  107230. setCustomMesh(mesh: Mesh): void;
  107231. /**
  107232. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107233. */
  107234. updateGizmoRotationToMatchAttachedMesh: boolean;
  107235. /**
  107236. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107237. */
  107238. updateGizmoPositionToMatchAttachedMesh: boolean;
  107239. /**
  107240. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107241. */
  107242. updateScale: boolean;
  107243. protected _interactionsEnabled: boolean;
  107244. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107245. private _beforeRenderObserver;
  107246. private _tempVector;
  107247. /**
  107248. * Creates a gizmo
  107249. * @param gizmoLayer The utility layer the gizmo will be added to
  107250. */
  107251. constructor(
  107252. /** The utility layer the gizmo will be added to */
  107253. gizmoLayer?: UtilityLayerRenderer);
  107254. /**
  107255. * Updates the gizmo to match the attached mesh's position/rotation
  107256. */
  107257. protected _update(): void;
  107258. /**
  107259. * Disposes of the gizmo
  107260. */
  107261. dispose(): void;
  107262. }
  107263. }
  107264. declare module BABYLON {
  107265. /**
  107266. * Single plane drag gizmo
  107267. */
  107268. export class PlaneDragGizmo extends Gizmo {
  107269. /**
  107270. * Drag behavior responsible for the gizmos dragging interactions
  107271. */
  107272. dragBehavior: PointerDragBehavior;
  107273. private _pointerObserver;
  107274. /**
  107275. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107276. */
  107277. snapDistance: number;
  107278. /**
  107279. * Event that fires each time the gizmo snaps to a new location.
  107280. * * snapDistance is the the change in distance
  107281. */
  107282. onSnapObservable: Observable<{
  107283. snapDistance: number;
  107284. }>;
  107285. private _plane;
  107286. private _coloredMaterial;
  107287. private _hoverMaterial;
  107288. private _isEnabled;
  107289. private _parent;
  107290. /** @hidden */
  107291. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107292. /** @hidden */
  107293. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107294. /**
  107295. * Creates a PlaneDragGizmo
  107296. * @param gizmoLayer The utility layer the gizmo will be added to
  107297. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107298. * @param color The color of the gizmo
  107299. */
  107300. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107301. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107302. /**
  107303. * If the gizmo is enabled
  107304. */
  107305. isEnabled: boolean;
  107306. /**
  107307. * Disposes of the gizmo
  107308. */
  107309. dispose(): void;
  107310. }
  107311. }
  107312. declare module BABYLON {
  107313. /**
  107314. * Gizmo that enables dragging a mesh along 3 axis
  107315. */
  107316. export class PositionGizmo extends Gizmo {
  107317. /**
  107318. * Internal gizmo used for interactions on the x axis
  107319. */
  107320. xGizmo: AxisDragGizmo;
  107321. /**
  107322. * Internal gizmo used for interactions on the y axis
  107323. */
  107324. yGizmo: AxisDragGizmo;
  107325. /**
  107326. * Internal gizmo used for interactions on the z axis
  107327. */
  107328. zGizmo: AxisDragGizmo;
  107329. /**
  107330. * Internal gizmo used for interactions on the yz plane
  107331. */
  107332. xPlaneGizmo: PlaneDragGizmo;
  107333. /**
  107334. * Internal gizmo used for interactions on the xz plane
  107335. */
  107336. yPlaneGizmo: PlaneDragGizmo;
  107337. /**
  107338. * Internal gizmo used for interactions on the xy plane
  107339. */
  107340. zPlaneGizmo: PlaneDragGizmo;
  107341. /**
  107342. * private variables
  107343. */
  107344. private _meshAttached;
  107345. private _updateGizmoRotationToMatchAttachedMesh;
  107346. private _snapDistance;
  107347. private _scaleRatio;
  107348. /** Fires an event when any of it's sub gizmos are dragged */
  107349. onDragStartObservable: Observable<unknown>;
  107350. /** Fires an event when any of it's sub gizmos are released from dragging */
  107351. onDragEndObservable: Observable<unknown>;
  107352. /**
  107353. * If set to true, planar drag is enabled
  107354. */
  107355. private _planarGizmoEnabled;
  107356. attachedMesh: Nullable<AbstractMesh>;
  107357. /**
  107358. * Creates a PositionGizmo
  107359. * @param gizmoLayer The utility layer the gizmo will be added to
  107360. */
  107361. constructor(gizmoLayer?: UtilityLayerRenderer);
  107362. /**
  107363. * If the planar drag gizmo is enabled
  107364. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107365. */
  107366. planarGizmoEnabled: boolean;
  107367. updateGizmoRotationToMatchAttachedMesh: boolean;
  107368. /**
  107369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107370. */
  107371. snapDistance: number;
  107372. /**
  107373. * Ratio for the scale of the gizmo (Default: 1)
  107374. */
  107375. scaleRatio: number;
  107376. /**
  107377. * Disposes of the gizmo
  107378. */
  107379. dispose(): void;
  107380. /**
  107381. * CustomMeshes are not supported by this gizmo
  107382. * @param mesh The mesh to replace the default mesh of the gizmo
  107383. */
  107384. setCustomMesh(mesh: Mesh): void;
  107385. }
  107386. }
  107387. declare module BABYLON {
  107388. /**
  107389. * Single axis drag gizmo
  107390. */
  107391. export class AxisDragGizmo extends Gizmo {
  107392. /**
  107393. * Drag behavior responsible for the gizmos dragging interactions
  107394. */
  107395. dragBehavior: PointerDragBehavior;
  107396. private _pointerObserver;
  107397. /**
  107398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107399. */
  107400. snapDistance: number;
  107401. /**
  107402. * Event that fires each time the gizmo snaps to a new location.
  107403. * * snapDistance is the the change in distance
  107404. */
  107405. onSnapObservable: Observable<{
  107406. snapDistance: number;
  107407. }>;
  107408. private _isEnabled;
  107409. private _parent;
  107410. private _arrow;
  107411. private _coloredMaterial;
  107412. private _hoverMaterial;
  107413. /** @hidden */
  107414. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107415. /** @hidden */
  107416. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107417. /**
  107418. * Creates an AxisDragGizmo
  107419. * @param gizmoLayer The utility layer the gizmo will be added to
  107420. * @param dragAxis The axis which the gizmo will be able to drag on
  107421. * @param color The color of the gizmo
  107422. */
  107423. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107425. /**
  107426. * If the gizmo is enabled
  107427. */
  107428. isEnabled: boolean;
  107429. /**
  107430. * Disposes of the gizmo
  107431. */
  107432. dispose(): void;
  107433. }
  107434. }
  107435. declare module BABYLON.Debug {
  107436. /**
  107437. * The Axes viewer will show 3 axes in a specific point in space
  107438. */
  107439. export class AxesViewer {
  107440. private _xAxis;
  107441. private _yAxis;
  107442. private _zAxis;
  107443. private _scaleLinesFactor;
  107444. private _instanced;
  107445. /**
  107446. * Gets the hosting scene
  107447. */
  107448. scene: Scene;
  107449. /**
  107450. * Gets or sets a number used to scale line length
  107451. */
  107452. scaleLines: number;
  107453. /** Gets the node hierarchy used to render x-axis */
  107454. readonly xAxis: TransformNode;
  107455. /** Gets the node hierarchy used to render y-axis */
  107456. readonly yAxis: TransformNode;
  107457. /** Gets the node hierarchy used to render z-axis */
  107458. readonly zAxis: TransformNode;
  107459. /**
  107460. * Creates a new AxesViewer
  107461. * @param scene defines the hosting scene
  107462. * @param scaleLines defines a number used to scale line length (1 by default)
  107463. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107464. * @param xAxis defines the node hierarchy used to render the x-axis
  107465. * @param yAxis defines the node hierarchy used to render the y-axis
  107466. * @param zAxis defines the node hierarchy used to render the z-axis
  107467. */
  107468. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107469. /**
  107470. * Force the viewer to update
  107471. * @param position defines the position of the viewer
  107472. * @param xaxis defines the x axis of the viewer
  107473. * @param yaxis defines the y axis of the viewer
  107474. * @param zaxis defines the z axis of the viewer
  107475. */
  107476. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107477. /**
  107478. * Creates an instance of this axes viewer.
  107479. * @returns a new axes viewer with instanced meshes
  107480. */
  107481. createInstance(): AxesViewer;
  107482. /** Releases resources */
  107483. dispose(): void;
  107484. private static _SetRenderingGroupId;
  107485. }
  107486. }
  107487. declare module BABYLON.Debug {
  107488. /**
  107489. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107490. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107491. */
  107492. export class BoneAxesViewer extends AxesViewer {
  107493. /**
  107494. * Gets or sets the target mesh where to display the axes viewer
  107495. */
  107496. mesh: Nullable<Mesh>;
  107497. /**
  107498. * Gets or sets the target bone where to display the axes viewer
  107499. */
  107500. bone: Nullable<Bone>;
  107501. /** Gets current position */
  107502. pos: Vector3;
  107503. /** Gets direction of X axis */
  107504. xaxis: Vector3;
  107505. /** Gets direction of Y axis */
  107506. yaxis: Vector3;
  107507. /** Gets direction of Z axis */
  107508. zaxis: Vector3;
  107509. /**
  107510. * Creates a new BoneAxesViewer
  107511. * @param scene defines the hosting scene
  107512. * @param bone defines the target bone
  107513. * @param mesh defines the target mesh
  107514. * @param scaleLines defines a scaling factor for line length (1 by default)
  107515. */
  107516. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107517. /**
  107518. * Force the viewer to update
  107519. */
  107520. update(): void;
  107521. /** Releases resources */
  107522. dispose(): void;
  107523. }
  107524. }
  107525. declare module BABYLON {
  107526. /**
  107527. * Interface used to define scene explorer extensibility option
  107528. */
  107529. export interface IExplorerExtensibilityOption {
  107530. /**
  107531. * Define the option label
  107532. */
  107533. label: string;
  107534. /**
  107535. * Defines the action to execute on click
  107536. */
  107537. action: (entity: any) => void;
  107538. }
  107539. /**
  107540. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107541. */
  107542. export interface IExplorerExtensibilityGroup {
  107543. /**
  107544. * Defines a predicate to test if a given type mut be extended
  107545. */
  107546. predicate: (entity: any) => boolean;
  107547. /**
  107548. * Gets the list of options added to a type
  107549. */
  107550. entries: IExplorerExtensibilityOption[];
  107551. }
  107552. /**
  107553. * Interface used to define the options to use to create the Inspector
  107554. */
  107555. export interface IInspectorOptions {
  107556. /**
  107557. * Display in overlay mode (default: false)
  107558. */
  107559. overlay?: boolean;
  107560. /**
  107561. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107562. */
  107563. globalRoot?: HTMLElement;
  107564. /**
  107565. * Display the Scene explorer
  107566. */
  107567. showExplorer?: boolean;
  107568. /**
  107569. * Display the property inspector
  107570. */
  107571. showInspector?: boolean;
  107572. /**
  107573. * Display in embed mode (both panes on the right)
  107574. */
  107575. embedMode?: boolean;
  107576. /**
  107577. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107578. */
  107579. handleResize?: boolean;
  107580. /**
  107581. * Allow the panes to popup (default: true)
  107582. */
  107583. enablePopup?: boolean;
  107584. /**
  107585. * Allow the panes to be closed by users (default: true)
  107586. */
  107587. enableClose?: boolean;
  107588. /**
  107589. * Optional list of extensibility entries
  107590. */
  107591. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107592. /**
  107593. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107594. */
  107595. inspectorURL?: string;
  107596. }
  107597. interface Scene {
  107598. /**
  107599. * @hidden
  107600. * Backing field
  107601. */
  107602. _debugLayer: DebugLayer;
  107603. /**
  107604. * Gets the debug layer (aka Inspector) associated with the scene
  107605. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107606. */
  107607. debugLayer: DebugLayer;
  107608. }
  107609. /**
  107610. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107611. * what is happening in your scene
  107612. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107613. */
  107614. export class DebugLayer {
  107615. /**
  107616. * Define the url to get the inspector script from.
  107617. * By default it uses the babylonjs CDN.
  107618. * @ignoreNaming
  107619. */
  107620. static InspectorURL: string;
  107621. private _scene;
  107622. private BJSINSPECTOR;
  107623. private _onPropertyChangedObservable?;
  107624. /**
  107625. * Observable triggered when a property is changed through the inspector.
  107626. */
  107627. readonly onPropertyChangedObservable: any;
  107628. /**
  107629. * Instantiates a new debug layer.
  107630. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107631. * what is happening in your scene
  107632. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107633. * @param scene Defines the scene to inspect
  107634. */
  107635. constructor(scene: Scene);
  107636. /** Creates the inspector window. */
  107637. private _createInspector;
  107638. /**
  107639. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107640. * @param entity defines the entity to select
  107641. * @param lineContainerTitle defines the specific block to highlight
  107642. */
  107643. select(entity: any, lineContainerTitle?: string): void;
  107644. /** Get the inspector from bundle or global */
  107645. private _getGlobalInspector;
  107646. /**
  107647. * Get if the inspector is visible or not.
  107648. * @returns true if visible otherwise, false
  107649. */
  107650. isVisible(): boolean;
  107651. /**
  107652. * Hide the inspector and close its window.
  107653. */
  107654. hide(): void;
  107655. /**
  107656. * Launch the debugLayer.
  107657. * @param config Define the configuration of the inspector
  107658. * @return a promise fulfilled when the debug layer is visible
  107659. */
  107660. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107661. }
  107662. }
  107663. declare module BABYLON {
  107664. /**
  107665. * Class containing static functions to help procedurally build meshes
  107666. */
  107667. export class BoxBuilder {
  107668. /**
  107669. * Creates a box mesh
  107670. * * The parameter `size` sets the size (float) of each box side (default 1)
  107671. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107672. * * 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)
  107673. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107677. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107678. * @param name defines the name of the mesh
  107679. * @param options defines the options used to create the mesh
  107680. * @param scene defines the hosting scene
  107681. * @returns the box mesh
  107682. */
  107683. static CreateBox(name: string, options: {
  107684. size?: number;
  107685. width?: number;
  107686. height?: number;
  107687. depth?: number;
  107688. faceUV?: Vector4[];
  107689. faceColors?: Color4[];
  107690. sideOrientation?: number;
  107691. frontUVs?: Vector4;
  107692. backUVs?: Vector4;
  107693. wrap?: boolean;
  107694. topBaseAt?: number;
  107695. bottomBaseAt?: number;
  107696. updatable?: boolean;
  107697. }, scene?: Nullable<Scene>): Mesh;
  107698. }
  107699. }
  107700. declare module BABYLON {
  107701. /**
  107702. * Class containing static functions to help procedurally build meshes
  107703. */
  107704. export class SphereBuilder {
  107705. /**
  107706. * Creates a sphere mesh
  107707. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107708. * * 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`)
  107709. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107710. * * 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
  107711. * * 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)
  107712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107715. * @param name defines the name of the mesh
  107716. * @param options defines the options used to create the mesh
  107717. * @param scene defines the hosting scene
  107718. * @returns the sphere mesh
  107719. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107720. */
  107721. static CreateSphere(name: string, options: {
  107722. segments?: number;
  107723. diameter?: number;
  107724. diameterX?: number;
  107725. diameterY?: number;
  107726. diameterZ?: number;
  107727. arc?: number;
  107728. slice?: number;
  107729. sideOrientation?: number;
  107730. frontUVs?: Vector4;
  107731. backUVs?: Vector4;
  107732. updatable?: boolean;
  107733. }, scene: any): Mesh;
  107734. }
  107735. }
  107736. declare module BABYLON.Debug {
  107737. /**
  107738. * Used to show the physics impostor around the specific mesh
  107739. */
  107740. export class PhysicsViewer {
  107741. /** @hidden */
  107742. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107743. /** @hidden */
  107744. protected _meshes: Array<Nullable<AbstractMesh>>;
  107745. /** @hidden */
  107746. protected _scene: Nullable<Scene>;
  107747. /** @hidden */
  107748. protected _numMeshes: number;
  107749. /** @hidden */
  107750. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107751. private _renderFunction;
  107752. private _utilityLayer;
  107753. private _debugBoxMesh;
  107754. private _debugSphereMesh;
  107755. private _debugCylinderMesh;
  107756. private _debugMaterial;
  107757. private _debugMeshMeshes;
  107758. /**
  107759. * Creates a new PhysicsViewer
  107760. * @param scene defines the hosting scene
  107761. */
  107762. constructor(scene: Scene);
  107763. /** @hidden */
  107764. protected _updateDebugMeshes(): void;
  107765. /**
  107766. * Renders a specified physic impostor
  107767. * @param impostor defines the impostor to render
  107768. * @param targetMesh defines the mesh represented by the impostor
  107769. * @returns the new debug mesh used to render the impostor
  107770. */
  107771. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107772. /**
  107773. * Hides a specified physic impostor
  107774. * @param impostor defines the impostor to hide
  107775. */
  107776. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107777. private _getDebugMaterial;
  107778. private _getDebugBoxMesh;
  107779. private _getDebugSphereMesh;
  107780. private _getDebugCylinderMesh;
  107781. private _getDebugMeshMesh;
  107782. private _getDebugMesh;
  107783. /** Releases all resources */
  107784. dispose(): void;
  107785. }
  107786. }
  107787. declare module BABYLON {
  107788. /**
  107789. * Class containing static functions to help procedurally build meshes
  107790. */
  107791. export class LinesBuilder {
  107792. /**
  107793. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107794. * * 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
  107795. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107796. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107797. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107798. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107799. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107800. * * 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
  107801. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107804. * @param name defines the name of the new line system
  107805. * @param options defines the options used to create the line system
  107806. * @param scene defines the hosting scene
  107807. * @returns a new line system mesh
  107808. */
  107809. static CreateLineSystem(name: string, options: {
  107810. lines: Vector3[][];
  107811. updatable?: boolean;
  107812. instance?: Nullable<LinesMesh>;
  107813. colors?: Nullable<Color4[][]>;
  107814. useVertexAlpha?: boolean;
  107815. }, scene: Nullable<Scene>): LinesMesh;
  107816. /**
  107817. * Creates a line mesh
  107818. * 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
  107819. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107820. * * The parameter `points` is an array successive Vector3
  107821. * * 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
  107822. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107823. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107824. * * When updating an instance, remember that only point positions can change, not the number of points
  107825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107827. * @param name defines the name of the new line system
  107828. * @param options defines the options used to create the line system
  107829. * @param scene defines the hosting scene
  107830. * @returns a new line mesh
  107831. */
  107832. static CreateLines(name: string, options: {
  107833. points: Vector3[];
  107834. updatable?: boolean;
  107835. instance?: Nullable<LinesMesh>;
  107836. colors?: Color4[];
  107837. useVertexAlpha?: boolean;
  107838. }, scene?: Nullable<Scene>): LinesMesh;
  107839. /**
  107840. * Creates a dashed line mesh
  107841. * * 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
  107842. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107843. * * The parameter `points` is an array successive Vector3
  107844. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107845. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107846. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107847. * * 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
  107848. * * When updating an instance, remember that only point positions can change, not the number of points
  107849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107850. * @param name defines the name of the mesh
  107851. * @param options defines the options used to create the mesh
  107852. * @param scene defines the hosting scene
  107853. * @returns the dashed line mesh
  107854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107855. */
  107856. static CreateDashedLines(name: string, options: {
  107857. points: Vector3[];
  107858. dashSize?: number;
  107859. gapSize?: number;
  107860. dashNb?: number;
  107861. updatable?: boolean;
  107862. instance?: LinesMesh;
  107863. }, scene?: Nullable<Scene>): LinesMesh;
  107864. }
  107865. }
  107866. declare module BABYLON {
  107867. /**
  107868. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107869. * in order to better appreciate the issue one might have.
  107870. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107871. */
  107872. export class RayHelper {
  107873. /**
  107874. * Defines the ray we are currently tryin to visualize.
  107875. */
  107876. ray: Nullable<Ray>;
  107877. private _renderPoints;
  107878. private _renderLine;
  107879. private _renderFunction;
  107880. private _scene;
  107881. private _updateToMeshFunction;
  107882. private _attachedToMesh;
  107883. private _meshSpaceDirection;
  107884. private _meshSpaceOrigin;
  107885. /**
  107886. * Helper function to create a colored helper in a scene in one line.
  107887. * @param ray Defines the ray we are currently tryin to visualize
  107888. * @param scene Defines the scene the ray is used in
  107889. * @param color Defines the color we want to see the ray in
  107890. * @returns The newly created ray helper.
  107891. */
  107892. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107893. /**
  107894. * Instantiate a new ray helper.
  107895. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107896. * in order to better appreciate the issue one might have.
  107897. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107898. * @param ray Defines the ray we are currently tryin to visualize
  107899. */
  107900. constructor(ray: Ray);
  107901. /**
  107902. * Shows the ray we are willing to debug.
  107903. * @param scene Defines the scene the ray needs to be rendered in
  107904. * @param color Defines the color the ray needs to be rendered in
  107905. */
  107906. show(scene: Scene, color?: Color3): void;
  107907. /**
  107908. * Hides the ray we are debugging.
  107909. */
  107910. hide(): void;
  107911. private _render;
  107912. /**
  107913. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107914. * @param mesh Defines the mesh we want the helper attached to
  107915. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107916. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107917. * @param length Defines the length of the ray
  107918. */
  107919. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107920. /**
  107921. * Detach the ray helper from the mesh it has previously been attached to.
  107922. */
  107923. detachFromMesh(): void;
  107924. private _updateToMesh;
  107925. /**
  107926. * Dispose the helper and release its associated resources.
  107927. */
  107928. dispose(): void;
  107929. }
  107930. }
  107931. declare module BABYLON.Debug {
  107932. /**
  107933. * Class used to render a debug view of a given skeleton
  107934. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107935. */
  107936. export class SkeletonViewer {
  107937. /** defines the skeleton to render */
  107938. skeleton: Skeleton;
  107939. /** defines the mesh attached to the skeleton */
  107940. mesh: AbstractMesh;
  107941. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107942. autoUpdateBonesMatrices: boolean;
  107943. /** defines the rendering group id to use with the viewer */
  107944. renderingGroupId: number;
  107945. /** Gets or sets the color used to render the skeleton */
  107946. color: Color3;
  107947. private _scene;
  107948. private _debugLines;
  107949. private _debugMesh;
  107950. private _isEnabled;
  107951. private _renderFunction;
  107952. private _utilityLayer;
  107953. /**
  107954. * Returns the mesh used to render the bones
  107955. */
  107956. readonly debugMesh: Nullable<LinesMesh>;
  107957. /**
  107958. * Creates a new SkeletonViewer
  107959. * @param skeleton defines the skeleton to render
  107960. * @param mesh defines the mesh attached to the skeleton
  107961. * @param scene defines the hosting scene
  107962. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107963. * @param renderingGroupId defines the rendering group id to use with the viewer
  107964. */
  107965. constructor(
  107966. /** defines the skeleton to render */
  107967. skeleton: Skeleton,
  107968. /** defines the mesh attached to the skeleton */
  107969. mesh: AbstractMesh, scene: Scene,
  107970. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107971. autoUpdateBonesMatrices?: boolean,
  107972. /** defines the rendering group id to use with the viewer */
  107973. renderingGroupId?: number);
  107974. /** Gets or sets a boolean indicating if the viewer is enabled */
  107975. isEnabled: boolean;
  107976. private _getBonePosition;
  107977. private _getLinesForBonesWithLength;
  107978. private _getLinesForBonesNoLength;
  107979. /** Update the viewer to sync with current skeleton state */
  107980. update(): void;
  107981. /** Release associated resources */
  107982. dispose(): void;
  107983. }
  107984. }
  107985. declare module BABYLON {
  107986. /**
  107987. * Options to create the null engine
  107988. */
  107989. export class NullEngineOptions {
  107990. /**
  107991. * Render width (Default: 512)
  107992. */
  107993. renderWidth: number;
  107994. /**
  107995. * Render height (Default: 256)
  107996. */
  107997. renderHeight: number;
  107998. /**
  107999. * Texture size (Default: 512)
  108000. */
  108001. textureSize: number;
  108002. /**
  108003. * If delta time between frames should be constant
  108004. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108005. */
  108006. deterministicLockstep: boolean;
  108007. /**
  108008. * Maximum about of steps between frames (Default: 4)
  108009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108010. */
  108011. lockstepMaxSteps: number;
  108012. }
  108013. /**
  108014. * The null engine class provides support for headless version of babylon.js.
  108015. * This can be used in server side scenario or for testing purposes
  108016. */
  108017. export class NullEngine extends Engine {
  108018. private _options;
  108019. /**
  108020. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108021. */
  108022. isDeterministicLockStep(): boolean;
  108023. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108024. getLockstepMaxSteps(): number;
  108025. /**
  108026. * Sets hardware scaling, used to save performance if needed
  108027. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108028. */
  108029. getHardwareScalingLevel(): number;
  108030. constructor(options?: NullEngineOptions);
  108031. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108032. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108033. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108034. getRenderWidth(useScreen?: boolean): number;
  108035. getRenderHeight(useScreen?: boolean): number;
  108036. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108037. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108038. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108039. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108040. bindSamplers(effect: Effect): void;
  108041. enableEffect(effect: Effect): void;
  108042. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108043. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108044. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108045. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108046. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108047. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108048. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108049. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108050. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108051. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108052. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108053. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108054. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108055. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108056. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108057. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108058. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108059. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108060. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108061. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108062. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108063. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108064. bindBuffers(vertexBuffers: {
  108065. [key: string]: VertexBuffer;
  108066. }, indexBuffer: DataBuffer, effect: Effect): void;
  108067. wipeCaches(bruteForce?: boolean): void;
  108068. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108069. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108070. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108071. /** @hidden */
  108072. _createTexture(): WebGLTexture;
  108073. /** @hidden */
  108074. _releaseTexture(texture: InternalTexture): void;
  108075. 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;
  108076. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108077. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108079. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108080. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108081. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108082. areAllEffectsReady(): boolean;
  108083. /**
  108084. * @hidden
  108085. * Get the current error code of the webGL context
  108086. * @returns the error code
  108087. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108088. */
  108089. getError(): number;
  108090. /** @hidden */
  108091. _getUnpackAlignement(): number;
  108092. /** @hidden */
  108093. _unpackFlipY(value: boolean): void;
  108094. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108095. /**
  108096. * Updates a dynamic vertex buffer.
  108097. * @param vertexBuffer the vertex buffer to update
  108098. * @param data the data used to update the vertex buffer
  108099. * @param byteOffset the byte offset of the data (optional)
  108100. * @param byteLength the byte length of the data (optional)
  108101. */
  108102. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108103. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108104. /** @hidden */
  108105. _bindTexture(channel: number, texture: InternalTexture): void;
  108106. /** @hidden */
  108107. _releaseBuffer(buffer: DataBuffer): boolean;
  108108. releaseEffects(): void;
  108109. displayLoadingUI(): void;
  108110. hideLoadingUI(): void;
  108111. /** @hidden */
  108112. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108113. /** @hidden */
  108114. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108115. /** @hidden */
  108116. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108117. /** @hidden */
  108118. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  108119. }
  108120. }
  108121. declare module BABYLON {
  108122. /** @hidden */
  108123. export class _OcclusionDataStorage {
  108124. /** @hidden */
  108125. occlusionInternalRetryCounter: number;
  108126. /** @hidden */
  108127. isOcclusionQueryInProgress: boolean;
  108128. /** @hidden */
  108129. isOccluded: boolean;
  108130. /** @hidden */
  108131. occlusionRetryCount: number;
  108132. /** @hidden */
  108133. occlusionType: number;
  108134. /** @hidden */
  108135. occlusionQueryAlgorithmType: number;
  108136. }
  108137. interface Engine {
  108138. /**
  108139. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  108140. * @return the new query
  108141. */
  108142. createQuery(): WebGLQuery;
  108143. /**
  108144. * Delete and release a webGL query
  108145. * @param query defines the query to delete
  108146. * @return the current engine
  108147. */
  108148. deleteQuery(query: WebGLQuery): Engine;
  108149. /**
  108150. * Check if a given query has resolved and got its value
  108151. * @param query defines the query to check
  108152. * @returns true if the query got its value
  108153. */
  108154. isQueryResultAvailable(query: WebGLQuery): boolean;
  108155. /**
  108156. * Gets the value of a given query
  108157. * @param query defines the query to check
  108158. * @returns the value of the query
  108159. */
  108160. getQueryResult(query: WebGLQuery): number;
  108161. /**
  108162. * Initiates an occlusion query
  108163. * @param algorithmType defines the algorithm to use
  108164. * @param query defines the query to use
  108165. * @returns the current engine
  108166. * @see http://doc.babylonjs.com/features/occlusionquery
  108167. */
  108168. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108169. /**
  108170. * Ends an occlusion query
  108171. * @see http://doc.babylonjs.com/features/occlusionquery
  108172. * @param algorithmType defines the algorithm to use
  108173. * @returns the current engine
  108174. */
  108175. endOcclusionQuery(algorithmType: number): Engine;
  108176. /**
  108177. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108178. * Please note that only one query can be issued at a time
  108179. * @returns a time token used to track the time span
  108180. */
  108181. startTimeQuery(): Nullable<_TimeToken>;
  108182. /**
  108183. * Ends a time query
  108184. * @param token defines the token used to measure the time span
  108185. * @returns the time spent (in ns)
  108186. */
  108187. endTimeQuery(token: _TimeToken): int;
  108188. /** @hidden */
  108189. _currentNonTimestampToken: Nullable<_TimeToken>;
  108190. /** @hidden */
  108191. _createTimeQuery(): WebGLQuery;
  108192. /** @hidden */
  108193. _deleteTimeQuery(query: WebGLQuery): void;
  108194. /** @hidden */
  108195. _getGlAlgorithmType(algorithmType: number): number;
  108196. /** @hidden */
  108197. _getTimeQueryResult(query: WebGLQuery): any;
  108198. /** @hidden */
  108199. _getTimeQueryAvailability(query: WebGLQuery): any;
  108200. }
  108201. interface AbstractMesh {
  108202. /**
  108203. * Backing filed
  108204. * @hidden
  108205. */
  108206. __occlusionDataStorage: _OcclusionDataStorage;
  108207. /**
  108208. * Access property
  108209. * @hidden
  108210. */
  108211. _occlusionDataStorage: _OcclusionDataStorage;
  108212. /**
  108213. * 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.
  108214. * The default value is -1 which means don't break the query and wait till the result
  108215. * @see http://doc.babylonjs.com/features/occlusionquery
  108216. */
  108217. occlusionRetryCount: number;
  108218. /**
  108219. * 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:
  108220. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108221. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108222. * * 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.
  108223. * @see http://doc.babylonjs.com/features/occlusionquery
  108224. */
  108225. occlusionType: number;
  108226. /**
  108227. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108228. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108229. * * 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.
  108230. * @see http://doc.babylonjs.com/features/occlusionquery
  108231. */
  108232. occlusionQueryAlgorithmType: number;
  108233. /**
  108234. * 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
  108235. * @see http://doc.babylonjs.com/features/occlusionquery
  108236. */
  108237. isOccluded: boolean;
  108238. /**
  108239. * Flag to check the progress status of the query
  108240. * @see http://doc.babylonjs.com/features/occlusionquery
  108241. */
  108242. isOcclusionQueryInProgress: boolean;
  108243. }
  108244. }
  108245. declare module BABYLON {
  108246. /** @hidden */
  108247. export var _forceTransformFeedbackToBundle: boolean;
  108248. interface Engine {
  108249. /**
  108250. * Creates a webGL transform feedback object
  108251. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108252. * @returns the webGL transform feedback object
  108253. */
  108254. createTransformFeedback(): WebGLTransformFeedback;
  108255. /**
  108256. * Delete a webGL transform feedback object
  108257. * @param value defines the webGL transform feedback object to delete
  108258. */
  108259. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108260. /**
  108261. * Bind a webGL transform feedback object to the webgl context
  108262. * @param value defines the webGL transform feedback object to bind
  108263. */
  108264. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108265. /**
  108266. * Begins a transform feedback operation
  108267. * @param usePoints defines if points or triangles must be used
  108268. */
  108269. beginTransformFeedback(usePoints: boolean): void;
  108270. /**
  108271. * Ends a transform feedback operation
  108272. */
  108273. endTransformFeedback(): void;
  108274. /**
  108275. * Specify the varyings to use with transform feedback
  108276. * @param program defines the associated webGL program
  108277. * @param value defines the list of strings representing the varying names
  108278. */
  108279. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108280. /**
  108281. * Bind a webGL buffer for a transform feedback operation
  108282. * @param value defines the webGL buffer to bind
  108283. */
  108284. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108285. }
  108286. }
  108287. declare module BABYLON {
  108288. /**
  108289. * Creation options of the multi render target texture.
  108290. */
  108291. export interface IMultiRenderTargetOptions {
  108292. /**
  108293. * Define if the texture needs to create mip maps after render.
  108294. */
  108295. generateMipMaps?: boolean;
  108296. /**
  108297. * Define the types of all the draw buffers we want to create
  108298. */
  108299. types?: number[];
  108300. /**
  108301. * Define the sampling modes of all the draw buffers we want to create
  108302. */
  108303. samplingModes?: number[];
  108304. /**
  108305. * Define if a depth buffer is required
  108306. */
  108307. generateDepthBuffer?: boolean;
  108308. /**
  108309. * Define if a stencil buffer is required
  108310. */
  108311. generateStencilBuffer?: boolean;
  108312. /**
  108313. * Define if a depth texture is required instead of a depth buffer
  108314. */
  108315. generateDepthTexture?: boolean;
  108316. /**
  108317. * Define the number of desired draw buffers
  108318. */
  108319. textureCount?: number;
  108320. /**
  108321. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108322. */
  108323. doNotChangeAspectRatio?: boolean;
  108324. /**
  108325. * Define the default type of the buffers we are creating
  108326. */
  108327. defaultType?: number;
  108328. }
  108329. /**
  108330. * A multi render target, like a render target provides the ability to render to a texture.
  108331. * Unlike the render target, it can render to several draw buffers in one draw.
  108332. * This is specially interesting in deferred rendering or for any effects requiring more than
  108333. * just one color from a single pass.
  108334. */
  108335. export class MultiRenderTarget extends RenderTargetTexture {
  108336. private _internalTextures;
  108337. private _textures;
  108338. private _multiRenderTargetOptions;
  108339. /**
  108340. * Get if draw buffers are currently supported by the used hardware and browser.
  108341. */
  108342. readonly isSupported: boolean;
  108343. /**
  108344. * Get the list of textures generated by the multi render target.
  108345. */
  108346. readonly textures: Texture[];
  108347. /**
  108348. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108349. */
  108350. readonly depthTexture: Texture;
  108351. /**
  108352. * Set the wrapping mode on U of all the textures we are rendering to.
  108353. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108354. */
  108355. wrapU: number;
  108356. /**
  108357. * Set the wrapping mode on V of all the textures we are rendering to.
  108358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108359. */
  108360. wrapV: number;
  108361. /**
  108362. * Instantiate a new multi render target texture.
  108363. * A multi render target, like a render target provides the ability to render to a texture.
  108364. * Unlike the render target, it can render to several draw buffers in one draw.
  108365. * This is specially interesting in deferred rendering or for any effects requiring more than
  108366. * just one color from a single pass.
  108367. * @param name Define the name of the texture
  108368. * @param size Define the size of the buffers to render to
  108369. * @param count Define the number of target we are rendering into
  108370. * @param scene Define the scene the texture belongs to
  108371. * @param options Define the options used to create the multi render target
  108372. */
  108373. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108374. /** @hidden */
  108375. _rebuild(): void;
  108376. private _createInternalTextures;
  108377. private _createTextures;
  108378. /**
  108379. * Define the number of samples used if MSAA is enabled.
  108380. */
  108381. samples: number;
  108382. /**
  108383. * Resize all the textures in the multi render target.
  108384. * Be carrefull as it will recreate all the data in the new texture.
  108385. * @param size Define the new size
  108386. */
  108387. resize(size: any): void;
  108388. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108389. /**
  108390. * Dispose the render targets and their associated resources
  108391. */
  108392. dispose(): void;
  108393. /**
  108394. * Release all the underlying texture used as draw buffers.
  108395. */
  108396. releaseInternalTextures(): void;
  108397. }
  108398. }
  108399. declare module BABYLON {
  108400. interface Engine {
  108401. /**
  108402. * Unbind a list of render target textures from the webGL context
  108403. * This is used only when drawBuffer extension or webGL2 are active
  108404. * @param textures defines the render target textures to unbind
  108405. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108406. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108407. */
  108408. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108409. /**
  108410. * Create a multi render target texture
  108411. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108412. * @param size defines the size of the texture
  108413. * @param options defines the creation options
  108414. * @returns the cube texture as an InternalTexture
  108415. */
  108416. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108417. /**
  108418. * Update the sample count for a given multiple render target texture
  108419. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108420. * @param textures defines the textures to update
  108421. * @param samples defines the sample count to set
  108422. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108423. */
  108424. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108425. }
  108426. }
  108427. declare module BABYLON {
  108428. /**
  108429. * Gather the list of clipboard event types as constants.
  108430. */
  108431. export class ClipboardEventTypes {
  108432. /**
  108433. * The clipboard event is fired when a copy command is active (pressed).
  108434. */
  108435. static readonly COPY: number;
  108436. /**
  108437. * The clipboard event is fired when a cut command is active (pressed).
  108438. */
  108439. static readonly CUT: number;
  108440. /**
  108441. * The clipboard event is fired when a paste command is active (pressed).
  108442. */
  108443. static readonly PASTE: number;
  108444. }
  108445. /**
  108446. * This class is used to store clipboard related info for the onClipboardObservable event.
  108447. */
  108448. export class ClipboardInfo {
  108449. /**
  108450. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108451. */
  108452. type: number;
  108453. /**
  108454. * Defines the related dom event
  108455. */
  108456. event: ClipboardEvent;
  108457. /**
  108458. *Creates an instance of ClipboardInfo.
  108459. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108460. * @param event Defines the related dom event
  108461. */
  108462. constructor(
  108463. /**
  108464. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108465. */
  108466. type: number,
  108467. /**
  108468. * Defines the related dom event
  108469. */
  108470. event: ClipboardEvent);
  108471. /**
  108472. * Get the clipboard event's type from the keycode.
  108473. * @param keyCode Defines the keyCode for the current keyboard event.
  108474. * @return {number}
  108475. */
  108476. static GetTypeFromCharacter(keyCode: number): number;
  108477. }
  108478. }
  108479. declare module BABYLON {
  108480. /**
  108481. * Google Daydream controller
  108482. */
  108483. export class DaydreamController extends WebVRController {
  108484. /**
  108485. * Base Url for the controller model.
  108486. */
  108487. static MODEL_BASE_URL: string;
  108488. /**
  108489. * File name for the controller model.
  108490. */
  108491. static MODEL_FILENAME: string;
  108492. /**
  108493. * Gamepad Id prefix used to identify Daydream Controller.
  108494. */
  108495. static readonly GAMEPAD_ID_PREFIX: string;
  108496. /**
  108497. * Creates a new DaydreamController from a gamepad
  108498. * @param vrGamepad the gamepad that the controller should be created from
  108499. */
  108500. constructor(vrGamepad: any);
  108501. /**
  108502. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108503. * @param scene scene in which to add meshes
  108504. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108505. */
  108506. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108507. /**
  108508. * Called once for each button that changed state since the last frame
  108509. * @param buttonIdx Which button index changed
  108510. * @param state New state of the button
  108511. * @param changes Which properties on the state changed since last frame
  108512. */
  108513. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108514. }
  108515. }
  108516. declare module BABYLON {
  108517. /**
  108518. * Gear VR Controller
  108519. */
  108520. export class GearVRController extends WebVRController {
  108521. /**
  108522. * Base Url for the controller model.
  108523. */
  108524. static MODEL_BASE_URL: string;
  108525. /**
  108526. * File name for the controller model.
  108527. */
  108528. static MODEL_FILENAME: string;
  108529. /**
  108530. * Gamepad Id prefix used to identify this controller.
  108531. */
  108532. static readonly GAMEPAD_ID_PREFIX: string;
  108533. private readonly _buttonIndexToObservableNameMap;
  108534. /**
  108535. * Creates a new GearVRController from a gamepad
  108536. * @param vrGamepad the gamepad that the controller should be created from
  108537. */
  108538. constructor(vrGamepad: any);
  108539. /**
  108540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108541. * @param scene scene in which to add meshes
  108542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108543. */
  108544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108545. /**
  108546. * Called once for each button that changed state since the last frame
  108547. * @param buttonIdx Which button index changed
  108548. * @param state New state of the button
  108549. * @param changes Which properties on the state changed since last frame
  108550. */
  108551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108552. }
  108553. }
  108554. declare module BABYLON {
  108555. /**
  108556. * Class containing static functions to help procedurally build meshes
  108557. */
  108558. export class PolyhedronBuilder {
  108559. /**
  108560. * Creates a polyhedron mesh
  108561. * * 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
  108562. * * The parameter `size` (positive float, default 1) sets the polygon size
  108563. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108564. * * 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`
  108565. * * 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
  108566. * * 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)`)
  108567. * * 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
  108568. * * 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
  108569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108572. * @param name defines the name of the mesh
  108573. * @param options defines the options used to create the mesh
  108574. * @param scene defines the hosting scene
  108575. * @returns the polyhedron mesh
  108576. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108577. */
  108578. static CreatePolyhedron(name: string, options: {
  108579. type?: number;
  108580. size?: number;
  108581. sizeX?: number;
  108582. sizeY?: number;
  108583. sizeZ?: number;
  108584. custom?: any;
  108585. faceUV?: Vector4[];
  108586. faceColors?: Color4[];
  108587. flat?: boolean;
  108588. updatable?: boolean;
  108589. sideOrientation?: number;
  108590. frontUVs?: Vector4;
  108591. backUVs?: Vector4;
  108592. }, scene?: Nullable<Scene>): Mesh;
  108593. }
  108594. }
  108595. declare module BABYLON {
  108596. /**
  108597. * Gizmo that enables scaling a mesh along 3 axis
  108598. */
  108599. export class ScaleGizmo extends Gizmo {
  108600. /**
  108601. * Internal gizmo used for interactions on the x axis
  108602. */
  108603. xGizmo: AxisScaleGizmo;
  108604. /**
  108605. * Internal gizmo used for interactions on the y axis
  108606. */
  108607. yGizmo: AxisScaleGizmo;
  108608. /**
  108609. * Internal gizmo used for interactions on the z axis
  108610. */
  108611. zGizmo: AxisScaleGizmo;
  108612. /**
  108613. * Internal gizmo used to scale all axis equally
  108614. */
  108615. uniformScaleGizmo: AxisScaleGizmo;
  108616. private _meshAttached;
  108617. private _updateGizmoRotationToMatchAttachedMesh;
  108618. private _snapDistance;
  108619. private _scaleRatio;
  108620. private _uniformScalingMesh;
  108621. private _octahedron;
  108622. /** Fires an event when any of it's sub gizmos are dragged */
  108623. onDragStartObservable: Observable<unknown>;
  108624. /** Fires an event when any of it's sub gizmos are released from dragging */
  108625. onDragEndObservable: Observable<unknown>;
  108626. attachedMesh: Nullable<AbstractMesh>;
  108627. /**
  108628. * Creates a ScaleGizmo
  108629. * @param gizmoLayer The utility layer the gizmo will be added to
  108630. */
  108631. constructor(gizmoLayer?: UtilityLayerRenderer);
  108632. updateGizmoRotationToMatchAttachedMesh: boolean;
  108633. /**
  108634. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108635. */
  108636. snapDistance: number;
  108637. /**
  108638. * Ratio for the scale of the gizmo (Default: 1)
  108639. */
  108640. scaleRatio: number;
  108641. /**
  108642. * Disposes of the gizmo
  108643. */
  108644. dispose(): void;
  108645. }
  108646. }
  108647. declare module BABYLON {
  108648. /**
  108649. * Single axis scale gizmo
  108650. */
  108651. export class AxisScaleGizmo extends Gizmo {
  108652. /**
  108653. * Drag behavior responsible for the gizmos dragging interactions
  108654. */
  108655. dragBehavior: PointerDragBehavior;
  108656. private _pointerObserver;
  108657. /**
  108658. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108659. */
  108660. snapDistance: number;
  108661. /**
  108662. * Event that fires each time the gizmo snaps to a new location.
  108663. * * snapDistance is the the change in distance
  108664. */
  108665. onSnapObservable: Observable<{
  108666. snapDistance: number;
  108667. }>;
  108668. /**
  108669. * If the scaling operation should be done on all axis (default: false)
  108670. */
  108671. uniformScaling: boolean;
  108672. private _isEnabled;
  108673. private _parent;
  108674. private _arrow;
  108675. private _coloredMaterial;
  108676. private _hoverMaterial;
  108677. /**
  108678. * Creates an AxisScaleGizmo
  108679. * @param gizmoLayer The utility layer the gizmo will be added to
  108680. * @param dragAxis The axis which the gizmo will be able to scale on
  108681. * @param color The color of the gizmo
  108682. */
  108683. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108684. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108685. /**
  108686. * If the gizmo is enabled
  108687. */
  108688. isEnabled: boolean;
  108689. /**
  108690. * Disposes of the gizmo
  108691. */
  108692. dispose(): void;
  108693. /**
  108694. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108695. * @param mesh The mesh to replace the default mesh of the gizmo
  108696. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108697. */
  108698. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108699. }
  108700. }
  108701. declare module BABYLON {
  108702. /**
  108703. * Bounding box gizmo
  108704. */
  108705. export class BoundingBoxGizmo extends Gizmo {
  108706. private _lineBoundingBox;
  108707. private _rotateSpheresParent;
  108708. private _scaleBoxesParent;
  108709. private _boundingDimensions;
  108710. private _renderObserver;
  108711. private _pointerObserver;
  108712. private _scaleDragSpeed;
  108713. private _tmpQuaternion;
  108714. private _tmpVector;
  108715. private _tmpRotationMatrix;
  108716. /**
  108717. * 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)
  108718. */
  108719. ignoreChildren: boolean;
  108720. /**
  108721. * 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)
  108722. */
  108723. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108724. /**
  108725. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108726. */
  108727. rotationSphereSize: number;
  108728. /**
  108729. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108730. */
  108731. scaleBoxSize: number;
  108732. /**
  108733. * 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)
  108734. */
  108735. fixedDragMeshScreenSize: boolean;
  108736. /**
  108737. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108738. */
  108739. fixedDragMeshScreenSizeDistanceFactor: number;
  108740. /**
  108741. * Fired when a rotation sphere or scale box is dragged
  108742. */
  108743. onDragStartObservable: Observable<{}>;
  108744. /**
  108745. * Fired when a scale box is dragged
  108746. */
  108747. onScaleBoxDragObservable: Observable<{}>;
  108748. /**
  108749. * Fired when a scale box drag is ended
  108750. */
  108751. onScaleBoxDragEndObservable: Observable<{}>;
  108752. /**
  108753. * Fired when a rotation sphere is dragged
  108754. */
  108755. onRotationSphereDragObservable: Observable<{}>;
  108756. /**
  108757. * Fired when a rotation sphere drag is ended
  108758. */
  108759. onRotationSphereDragEndObservable: Observable<{}>;
  108760. /**
  108761. * 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)
  108762. */
  108763. scalePivot: Nullable<Vector3>;
  108764. /**
  108765. * Mesh used as a pivot to rotate the attached mesh
  108766. */
  108767. private _anchorMesh;
  108768. private _existingMeshScale;
  108769. private _dragMesh;
  108770. private pointerDragBehavior;
  108771. private coloredMaterial;
  108772. private hoverColoredMaterial;
  108773. /**
  108774. * Sets the color of the bounding box gizmo
  108775. * @param color the color to set
  108776. */
  108777. setColor(color: Color3): void;
  108778. /**
  108779. * Creates an BoundingBoxGizmo
  108780. * @param gizmoLayer The utility layer the gizmo will be added to
  108781. * @param color The color of the gizmo
  108782. */
  108783. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108784. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108785. private _selectNode;
  108786. /**
  108787. * Updates the bounding box information for the Gizmo
  108788. */
  108789. updateBoundingBox(): void;
  108790. private _updateRotationSpheres;
  108791. private _updateScaleBoxes;
  108792. /**
  108793. * Enables rotation on the specified axis and disables rotation on the others
  108794. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108795. */
  108796. setEnabledRotationAxis(axis: string): void;
  108797. /**
  108798. * Enables/disables scaling
  108799. * @param enable if scaling should be enabled
  108800. */
  108801. setEnabledScaling(enable: boolean): void;
  108802. private _updateDummy;
  108803. /**
  108804. * Enables a pointer drag behavior on the bounding box of the gizmo
  108805. */
  108806. enableDragBehavior(): void;
  108807. /**
  108808. * Disposes of the gizmo
  108809. */
  108810. dispose(): void;
  108811. /**
  108812. * 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)
  108813. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108814. * @returns the bounding box mesh with the passed in mesh as a child
  108815. */
  108816. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108817. /**
  108818. * CustomMeshes are not supported by this gizmo
  108819. * @param mesh The mesh to replace the default mesh of the gizmo
  108820. */
  108821. setCustomMesh(mesh: Mesh): void;
  108822. }
  108823. }
  108824. declare module BABYLON {
  108825. /**
  108826. * Single plane rotation gizmo
  108827. */
  108828. export class PlaneRotationGizmo extends Gizmo {
  108829. /**
  108830. * Drag behavior responsible for the gizmos dragging interactions
  108831. */
  108832. dragBehavior: PointerDragBehavior;
  108833. private _pointerObserver;
  108834. /**
  108835. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108836. */
  108837. snapDistance: number;
  108838. /**
  108839. * Event that fires each time the gizmo snaps to a new location.
  108840. * * snapDistance is the the change in distance
  108841. */
  108842. onSnapObservable: Observable<{
  108843. snapDistance: number;
  108844. }>;
  108845. private _isEnabled;
  108846. private _parent;
  108847. /**
  108848. * Creates a PlaneRotationGizmo
  108849. * @param gizmoLayer The utility layer the gizmo will be added to
  108850. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108851. * @param color The color of the gizmo
  108852. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108853. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108854. */
  108855. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  108856. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108857. /**
  108858. * If the gizmo is enabled
  108859. */
  108860. isEnabled: boolean;
  108861. /**
  108862. * Disposes of the gizmo
  108863. */
  108864. dispose(): void;
  108865. }
  108866. }
  108867. declare module BABYLON {
  108868. /**
  108869. * Gizmo that enables rotating a mesh along 3 axis
  108870. */
  108871. export class RotationGizmo extends Gizmo {
  108872. /**
  108873. * Internal gizmo used for interactions on the x axis
  108874. */
  108875. xGizmo: PlaneRotationGizmo;
  108876. /**
  108877. * Internal gizmo used for interactions on the y axis
  108878. */
  108879. yGizmo: PlaneRotationGizmo;
  108880. /**
  108881. * Internal gizmo used for interactions on the z axis
  108882. */
  108883. zGizmo: PlaneRotationGizmo;
  108884. /** Fires an event when any of it's sub gizmos are dragged */
  108885. onDragStartObservable: Observable<unknown>;
  108886. /** Fires an event when any of it's sub gizmos are released from dragging */
  108887. onDragEndObservable: Observable<unknown>;
  108888. private _meshAttached;
  108889. attachedMesh: Nullable<AbstractMesh>;
  108890. /**
  108891. * Creates a RotationGizmo
  108892. * @param gizmoLayer The utility layer the gizmo will be added to
  108893. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108894. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108895. */
  108896. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  108897. updateGizmoRotationToMatchAttachedMesh: boolean;
  108898. /**
  108899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108900. */
  108901. snapDistance: number;
  108902. /**
  108903. * Ratio for the scale of the gizmo (Default: 1)
  108904. */
  108905. scaleRatio: number;
  108906. /**
  108907. * Disposes of the gizmo
  108908. */
  108909. dispose(): void;
  108910. /**
  108911. * CustomMeshes are not supported by this gizmo
  108912. * @param mesh The mesh to replace the default mesh of the gizmo
  108913. */
  108914. setCustomMesh(mesh: Mesh): void;
  108915. }
  108916. }
  108917. declare module BABYLON {
  108918. /**
  108919. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108920. */
  108921. export class GizmoManager implements IDisposable {
  108922. private scene;
  108923. /**
  108924. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108925. */
  108926. gizmos: {
  108927. positionGizmo: Nullable<PositionGizmo>;
  108928. rotationGizmo: Nullable<RotationGizmo>;
  108929. scaleGizmo: Nullable<ScaleGizmo>;
  108930. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108931. };
  108932. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108933. clearGizmoOnEmptyPointerEvent: boolean;
  108934. /** Fires an event when the manager is attached to a mesh */
  108935. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108936. private _gizmosEnabled;
  108937. private _pointerObserver;
  108938. private _attachedMesh;
  108939. private _boundingBoxColor;
  108940. private _defaultUtilityLayer;
  108941. private _defaultKeepDepthUtilityLayer;
  108942. /**
  108943. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108944. */
  108945. boundingBoxDragBehavior: SixDofDragBehavior;
  108946. /**
  108947. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108948. */
  108949. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108950. /**
  108951. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108952. */
  108953. usePointerToAttachGizmos: boolean;
  108954. /**
  108955. * Utility layer that the bounding box gizmo belongs to
  108956. */
  108957. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108958. /**
  108959. * Utility layer that all gizmos besides bounding box belong to
  108960. */
  108961. readonly utilityLayer: UtilityLayerRenderer;
  108962. /**
  108963. * Instatiates a gizmo manager
  108964. * @param scene the scene to overlay the gizmos on top of
  108965. */
  108966. constructor(scene: Scene);
  108967. /**
  108968. * Attaches a set of gizmos to the specified mesh
  108969. * @param mesh The mesh the gizmo's should be attached to
  108970. */
  108971. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108972. /**
  108973. * If the position gizmo is enabled
  108974. */
  108975. positionGizmoEnabled: boolean;
  108976. /**
  108977. * If the rotation gizmo is enabled
  108978. */
  108979. rotationGizmoEnabled: boolean;
  108980. /**
  108981. * If the scale gizmo is enabled
  108982. */
  108983. scaleGizmoEnabled: boolean;
  108984. /**
  108985. * If the boundingBox gizmo is enabled
  108986. */
  108987. boundingBoxGizmoEnabled: boolean;
  108988. /**
  108989. * Disposes of the gizmo manager
  108990. */
  108991. dispose(): void;
  108992. }
  108993. }
  108994. declare module BABYLON {
  108995. /**
  108996. * A directional light is defined by a direction (what a surprise!).
  108997. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108998. * 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.
  108999. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109000. */
  109001. export class DirectionalLight extends ShadowLight {
  109002. private _shadowFrustumSize;
  109003. /**
  109004. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  109005. */
  109006. /**
  109007. * Specifies a fix frustum size for the shadow generation.
  109008. */
  109009. shadowFrustumSize: number;
  109010. private _shadowOrthoScale;
  109011. /**
  109012. * Gets the shadow projection scale against the optimal computed one.
  109013. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109014. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109015. */
  109016. /**
  109017. * Sets the shadow projection scale against the optimal computed one.
  109018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109020. */
  109021. shadowOrthoScale: number;
  109022. /**
  109023. * Automatically compute the projection matrix to best fit (including all the casters)
  109024. * on each frame.
  109025. */
  109026. autoUpdateExtends: boolean;
  109027. private _orthoLeft;
  109028. private _orthoRight;
  109029. private _orthoTop;
  109030. private _orthoBottom;
  109031. /**
  109032. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  109033. * The directional light is emitted from everywhere in the given direction.
  109034. * It can cast shadows.
  109035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109036. * @param name The friendly name of the light
  109037. * @param direction The direction of the light
  109038. * @param scene The scene the light belongs to
  109039. */
  109040. constructor(name: string, direction: Vector3, scene: Scene);
  109041. /**
  109042. * Returns the string "DirectionalLight".
  109043. * @return The class name
  109044. */
  109045. getClassName(): string;
  109046. /**
  109047. * Returns the integer 1.
  109048. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109049. */
  109050. getTypeID(): number;
  109051. /**
  109052. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  109053. * Returns the DirectionalLight Shadow projection matrix.
  109054. */
  109055. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109056. /**
  109057. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  109058. * Returns the DirectionalLight Shadow projection matrix.
  109059. */
  109060. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  109061. /**
  109062. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  109063. * Returns the DirectionalLight Shadow projection matrix.
  109064. */
  109065. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109066. protected _buildUniformLayout(): void;
  109067. /**
  109068. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  109069. * @param effect The effect to update
  109070. * @param lightIndex The index of the light in the effect to update
  109071. * @returns The directional light
  109072. */
  109073. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  109074. /**
  109075. * Gets the minZ used for shadow according to both the scene and the light.
  109076. *
  109077. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109078. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109079. * @param activeCamera The camera we are returning the min for
  109080. * @returns the depth min z
  109081. */
  109082. getDepthMinZ(activeCamera: Camera): number;
  109083. /**
  109084. * Gets the maxZ used for shadow according to both the scene and the light.
  109085. *
  109086. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109087. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109088. * @param activeCamera The camera we are returning the max for
  109089. * @returns the depth max z
  109090. */
  109091. getDepthMaxZ(activeCamera: Camera): number;
  109092. /**
  109093. * Prepares the list of defines specific to the light type.
  109094. * @param defines the list of defines
  109095. * @param lightIndex defines the index of the light for the effect
  109096. */
  109097. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109098. }
  109099. }
  109100. declare module BABYLON {
  109101. /**
  109102. * Class containing static functions to help procedurally build meshes
  109103. */
  109104. export class HemisphereBuilder {
  109105. /**
  109106. * Creates a hemisphere mesh
  109107. * @param name defines the name of the mesh
  109108. * @param options defines the options used to create the mesh
  109109. * @param scene defines the hosting scene
  109110. * @returns the hemisphere mesh
  109111. */
  109112. static CreateHemisphere(name: string, options: {
  109113. segments?: number;
  109114. diameter?: number;
  109115. sideOrientation?: number;
  109116. }, scene: any): Mesh;
  109117. }
  109118. }
  109119. declare module BABYLON {
  109120. /**
  109121. * A spot light is defined by a position, a direction, an angle, and an exponent.
  109122. * These values define a cone of light starting from the position, emitting toward the direction.
  109123. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  109124. * and the exponent defines the speed of the decay of the light with distance (reach).
  109125. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109126. */
  109127. export class SpotLight extends ShadowLight {
  109128. private _angle;
  109129. private _innerAngle;
  109130. private _cosHalfAngle;
  109131. private _lightAngleScale;
  109132. private _lightAngleOffset;
  109133. /**
  109134. * Gets the cone angle of the spot light in Radians.
  109135. */
  109136. /**
  109137. * Sets the cone angle of the spot light in Radians.
  109138. */
  109139. angle: number;
  109140. /**
  109141. * Only used in gltf falloff mode, this defines the angle where
  109142. * the directional falloff will start before cutting at angle which could be seen
  109143. * as outer angle.
  109144. */
  109145. /**
  109146. * Only used in gltf falloff mode, this defines the angle where
  109147. * the directional falloff will start before cutting at angle which could be seen
  109148. * as outer angle.
  109149. */
  109150. innerAngle: number;
  109151. private _shadowAngleScale;
  109152. /**
  109153. * Allows scaling the angle of the light for shadow generation only.
  109154. */
  109155. /**
  109156. * Allows scaling the angle of the light for shadow generation only.
  109157. */
  109158. shadowAngleScale: number;
  109159. /**
  109160. * The light decay speed with the distance from the emission spot.
  109161. */
  109162. exponent: number;
  109163. private _projectionTextureMatrix;
  109164. /**
  109165. * Allows reading the projecton texture
  109166. */
  109167. readonly projectionTextureMatrix: Matrix;
  109168. protected _projectionTextureLightNear: number;
  109169. /**
  109170. * Gets the near clip of the Spotlight for texture projection.
  109171. */
  109172. /**
  109173. * Sets the near clip of the Spotlight for texture projection.
  109174. */
  109175. projectionTextureLightNear: number;
  109176. protected _projectionTextureLightFar: number;
  109177. /**
  109178. * Gets the far clip of the Spotlight for texture projection.
  109179. */
  109180. /**
  109181. * Sets the far clip of the Spotlight for texture projection.
  109182. */
  109183. projectionTextureLightFar: number;
  109184. protected _projectionTextureUpDirection: Vector3;
  109185. /**
  109186. * Gets the Up vector of the Spotlight for texture projection.
  109187. */
  109188. /**
  109189. * Sets the Up vector of the Spotlight for texture projection.
  109190. */
  109191. projectionTextureUpDirection: Vector3;
  109192. private _projectionTexture;
  109193. /**
  109194. * Gets the projection texture of the light.
  109195. */
  109196. /**
  109197. * Sets the projection texture of the light.
  109198. */
  109199. projectionTexture: Nullable<BaseTexture>;
  109200. private _projectionTextureViewLightDirty;
  109201. private _projectionTextureProjectionLightDirty;
  109202. private _projectionTextureDirty;
  109203. private _projectionTextureViewTargetVector;
  109204. private _projectionTextureViewLightMatrix;
  109205. private _projectionTextureProjectionLightMatrix;
  109206. private _projectionTextureScalingMatrix;
  109207. /**
  109208. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109209. * It can cast shadows.
  109210. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109211. * @param name The light friendly name
  109212. * @param position The position of the spot light in the scene
  109213. * @param direction The direction of the light in the scene
  109214. * @param angle The cone angle of the light in Radians
  109215. * @param exponent The light decay speed with the distance from the emission spot
  109216. * @param scene The scene the lights belongs to
  109217. */
  109218. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109219. /**
  109220. * Returns the string "SpotLight".
  109221. * @returns the class name
  109222. */
  109223. getClassName(): string;
  109224. /**
  109225. * Returns the integer 2.
  109226. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109227. */
  109228. getTypeID(): number;
  109229. /**
  109230. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109231. */
  109232. protected _setDirection(value: Vector3): void;
  109233. /**
  109234. * Overrides the position setter to recompute the projection texture view light Matrix.
  109235. */
  109236. protected _setPosition(value: Vector3): void;
  109237. /**
  109238. * 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.
  109239. * Returns the SpotLight.
  109240. */
  109241. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109242. protected _computeProjectionTextureViewLightMatrix(): void;
  109243. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109244. /**
  109245. * Main function for light texture projection matrix computing.
  109246. */
  109247. protected _computeProjectionTextureMatrix(): void;
  109248. protected _buildUniformLayout(): void;
  109249. private _computeAngleValues;
  109250. /**
  109251. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109252. * @param effect The effect to update
  109253. * @param lightIndex The index of the light in the effect to update
  109254. * @returns The spot light
  109255. */
  109256. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109257. /**
  109258. * Disposes the light and the associated resources.
  109259. */
  109260. dispose(): void;
  109261. /**
  109262. * Prepares the list of defines specific to the light type.
  109263. * @param defines the list of defines
  109264. * @param lightIndex defines the index of the light for the effect
  109265. */
  109266. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109267. }
  109268. }
  109269. declare module BABYLON {
  109270. /**
  109271. * Gizmo that enables viewing a light
  109272. */
  109273. export class LightGizmo extends Gizmo {
  109274. private _lightMesh;
  109275. private _material;
  109276. private cachedPosition;
  109277. private cachedForward;
  109278. /**
  109279. * Creates a LightGizmo
  109280. * @param gizmoLayer The utility layer the gizmo will be added to
  109281. */
  109282. constructor(gizmoLayer?: UtilityLayerRenderer);
  109283. private _light;
  109284. /**
  109285. * The light that the gizmo is attached to
  109286. */
  109287. light: Nullable<Light>;
  109288. /**
  109289. * Gets the material used to render the light gizmo
  109290. */
  109291. readonly material: StandardMaterial;
  109292. /**
  109293. * @hidden
  109294. * Updates the gizmo to match the attached mesh's position/rotation
  109295. */
  109296. protected _update(): void;
  109297. private static _Scale;
  109298. /**
  109299. * Creates the lines for a light mesh
  109300. */
  109301. private static _createLightLines;
  109302. /**
  109303. * Disposes of the light gizmo
  109304. */
  109305. dispose(): void;
  109306. private static _CreateHemisphericLightMesh;
  109307. private static _CreatePointLightMesh;
  109308. private static _CreateSpotLightMesh;
  109309. private static _CreateDirectionalLightMesh;
  109310. }
  109311. }
  109312. declare module BABYLON {
  109313. /** @hidden */
  109314. export var backgroundFragmentDeclaration: {
  109315. name: string;
  109316. shader: string;
  109317. };
  109318. }
  109319. declare module BABYLON {
  109320. /** @hidden */
  109321. export var backgroundUboDeclaration: {
  109322. name: string;
  109323. shader: string;
  109324. };
  109325. }
  109326. declare module BABYLON {
  109327. /** @hidden */
  109328. export var backgroundPixelShader: {
  109329. name: string;
  109330. shader: string;
  109331. };
  109332. }
  109333. declare module BABYLON {
  109334. /** @hidden */
  109335. export var backgroundVertexDeclaration: {
  109336. name: string;
  109337. shader: string;
  109338. };
  109339. }
  109340. declare module BABYLON {
  109341. /** @hidden */
  109342. export var backgroundVertexShader: {
  109343. name: string;
  109344. shader: string;
  109345. };
  109346. }
  109347. declare module BABYLON {
  109348. /**
  109349. * Background material used to create an efficient environement around your scene.
  109350. */
  109351. export class BackgroundMaterial extends PushMaterial {
  109352. /**
  109353. * Standard reflectance value at parallel view angle.
  109354. */
  109355. static StandardReflectance0: number;
  109356. /**
  109357. * Standard reflectance value at grazing angle.
  109358. */
  109359. static StandardReflectance90: number;
  109360. protected _primaryColor: Color3;
  109361. /**
  109362. * Key light Color (multiply against the environement texture)
  109363. */
  109364. primaryColor: Color3;
  109365. protected __perceptualColor: Nullable<Color3>;
  109366. /**
  109367. * Experimental Internal Use Only.
  109368. *
  109369. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109370. * This acts as a helper to set the primary color to a more "human friendly" value.
  109371. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109372. * output color as close as possible from the chosen value.
  109373. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109374. * part of lighting setup.)
  109375. */
  109376. _perceptualColor: Nullable<Color3>;
  109377. protected _primaryColorShadowLevel: float;
  109378. /**
  109379. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109380. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109381. */
  109382. primaryColorShadowLevel: float;
  109383. protected _primaryColorHighlightLevel: float;
  109384. /**
  109385. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109386. * The primary color is used at the level chosen to define what the white area would look.
  109387. */
  109388. primaryColorHighlightLevel: float;
  109389. protected _reflectionTexture: Nullable<BaseTexture>;
  109390. /**
  109391. * Reflection Texture used in the material.
  109392. * Should be author in a specific way for the best result (refer to the documentation).
  109393. */
  109394. reflectionTexture: Nullable<BaseTexture>;
  109395. protected _reflectionBlur: float;
  109396. /**
  109397. * Reflection Texture level of blur.
  109398. *
  109399. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109400. * texture twice.
  109401. */
  109402. reflectionBlur: float;
  109403. protected _diffuseTexture: Nullable<BaseTexture>;
  109404. /**
  109405. * Diffuse Texture used in the material.
  109406. * Should be author in a specific way for the best result (refer to the documentation).
  109407. */
  109408. diffuseTexture: Nullable<BaseTexture>;
  109409. protected _shadowLights: Nullable<IShadowLight[]>;
  109410. /**
  109411. * Specify the list of lights casting shadow on the material.
  109412. * All scene shadow lights will be included if null.
  109413. */
  109414. shadowLights: Nullable<IShadowLight[]>;
  109415. protected _shadowLevel: float;
  109416. /**
  109417. * Helps adjusting the shadow to a softer level if required.
  109418. * 0 means black shadows and 1 means no shadows.
  109419. */
  109420. shadowLevel: float;
  109421. protected _sceneCenter: Vector3;
  109422. /**
  109423. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109424. * It is usually zero but might be interesting to modify according to your setup.
  109425. */
  109426. sceneCenter: Vector3;
  109427. protected _opacityFresnel: boolean;
  109428. /**
  109429. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109430. * This helps ensuring a nice transition when the camera goes under the ground.
  109431. */
  109432. opacityFresnel: boolean;
  109433. protected _reflectionFresnel: boolean;
  109434. /**
  109435. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109436. * This helps adding a mirror texture on the ground.
  109437. */
  109438. reflectionFresnel: boolean;
  109439. protected _reflectionFalloffDistance: number;
  109440. /**
  109441. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109442. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109443. */
  109444. reflectionFalloffDistance: number;
  109445. protected _reflectionAmount: number;
  109446. /**
  109447. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109448. */
  109449. reflectionAmount: number;
  109450. protected _reflectionReflectance0: number;
  109451. /**
  109452. * This specifies the weight of the reflection at grazing angle.
  109453. */
  109454. reflectionReflectance0: number;
  109455. protected _reflectionReflectance90: number;
  109456. /**
  109457. * This specifies the weight of the reflection at a perpendicular point of view.
  109458. */
  109459. reflectionReflectance90: number;
  109460. /**
  109461. * Sets the reflection reflectance fresnel values according to the default standard
  109462. * empirically know to work well :-)
  109463. */
  109464. reflectionStandardFresnelWeight: number;
  109465. protected _useRGBColor: boolean;
  109466. /**
  109467. * Helps to directly use the maps channels instead of their level.
  109468. */
  109469. useRGBColor: boolean;
  109470. protected _enableNoise: boolean;
  109471. /**
  109472. * This helps reducing the banding effect that could occur on the background.
  109473. */
  109474. enableNoise: boolean;
  109475. /**
  109476. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109477. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109478. * Recommended to be keep at 1.0 except for special cases.
  109479. */
  109480. fovMultiplier: number;
  109481. private _fovMultiplier;
  109482. /**
  109483. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109484. */
  109485. useEquirectangularFOV: boolean;
  109486. private _maxSimultaneousLights;
  109487. /**
  109488. * Number of Simultaneous lights allowed on the material.
  109489. */
  109490. maxSimultaneousLights: int;
  109491. /**
  109492. * Default configuration related to image processing available in the Background Material.
  109493. */
  109494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109495. /**
  109496. * Keep track of the image processing observer to allow dispose and replace.
  109497. */
  109498. private _imageProcessingObserver;
  109499. /**
  109500. * Attaches a new image processing configuration to the PBR Material.
  109501. * @param configuration (if null the scene configuration will be use)
  109502. */
  109503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109504. /**
  109505. * Gets the image processing configuration used either in this material.
  109506. */
  109507. /**
  109508. * Sets the Default image processing configuration used either in the this material.
  109509. *
  109510. * If sets to null, the scene one is in use.
  109511. */
  109512. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109513. /**
  109514. * Gets wether the color curves effect is enabled.
  109515. */
  109516. /**
  109517. * Sets wether the color curves effect is enabled.
  109518. */
  109519. cameraColorCurvesEnabled: boolean;
  109520. /**
  109521. * Gets wether the color grading effect is enabled.
  109522. */
  109523. /**
  109524. * Gets wether the color grading effect is enabled.
  109525. */
  109526. cameraColorGradingEnabled: boolean;
  109527. /**
  109528. * Gets wether tonemapping is enabled or not.
  109529. */
  109530. /**
  109531. * Sets wether tonemapping is enabled or not
  109532. */
  109533. cameraToneMappingEnabled: boolean;
  109534. /**
  109535. * The camera exposure used on this material.
  109536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109537. * This corresponds to a photographic exposure.
  109538. */
  109539. /**
  109540. * The camera exposure used on this material.
  109541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109542. * This corresponds to a photographic exposure.
  109543. */
  109544. cameraExposure: float;
  109545. /**
  109546. * Gets The camera contrast used on this material.
  109547. */
  109548. /**
  109549. * Sets The camera contrast used on this material.
  109550. */
  109551. cameraContrast: float;
  109552. /**
  109553. * Gets the Color Grading 2D Lookup Texture.
  109554. */
  109555. /**
  109556. * Sets the Color Grading 2D Lookup Texture.
  109557. */
  109558. cameraColorGradingTexture: Nullable<BaseTexture>;
  109559. /**
  109560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109562. * 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;
  109563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109564. */
  109565. /**
  109566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109568. * 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;
  109569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109570. */
  109571. cameraColorCurves: Nullable<ColorCurves>;
  109572. /**
  109573. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109574. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109575. */
  109576. switchToBGR: boolean;
  109577. private _renderTargets;
  109578. private _reflectionControls;
  109579. private _white;
  109580. private _primaryShadowColor;
  109581. private _primaryHighlightColor;
  109582. /**
  109583. * Instantiates a Background Material in the given scene
  109584. * @param name The friendly name of the material
  109585. * @param scene The scene to add the material to
  109586. */
  109587. constructor(name: string, scene: Scene);
  109588. /**
  109589. * Gets a boolean indicating that current material needs to register RTT
  109590. */
  109591. readonly hasRenderTargetTextures: boolean;
  109592. /**
  109593. * The entire material has been created in order to prevent overdraw.
  109594. * @returns false
  109595. */
  109596. needAlphaTesting(): boolean;
  109597. /**
  109598. * The entire material has been created in order to prevent overdraw.
  109599. * @returns true if blending is enable
  109600. */
  109601. needAlphaBlending(): boolean;
  109602. /**
  109603. * Checks wether the material is ready to be rendered for a given mesh.
  109604. * @param mesh The mesh to render
  109605. * @param subMesh The submesh to check against
  109606. * @param useInstances Specify wether or not the material is used with instances
  109607. * @returns true if all the dependencies are ready (Textures, Effects...)
  109608. */
  109609. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109610. /**
  109611. * Compute the primary color according to the chosen perceptual color.
  109612. */
  109613. private _computePrimaryColorFromPerceptualColor;
  109614. /**
  109615. * Compute the highlights and shadow colors according to their chosen levels.
  109616. */
  109617. private _computePrimaryColors;
  109618. /**
  109619. * Build the uniform buffer used in the material.
  109620. */
  109621. buildUniformLayout(): void;
  109622. /**
  109623. * Unbind the material.
  109624. */
  109625. unbind(): void;
  109626. /**
  109627. * Bind only the world matrix to the material.
  109628. * @param world The world matrix to bind.
  109629. */
  109630. bindOnlyWorldMatrix(world: Matrix): void;
  109631. /**
  109632. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109633. * @param world The world matrix to bind.
  109634. * @param subMesh The submesh to bind for.
  109635. */
  109636. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109637. /**
  109638. * Dispose the material.
  109639. * @param forceDisposeEffect Force disposal of the associated effect.
  109640. * @param forceDisposeTextures Force disposal of the associated textures.
  109641. */
  109642. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109643. /**
  109644. * Clones the material.
  109645. * @param name The cloned name.
  109646. * @returns The cloned material.
  109647. */
  109648. clone(name: string): BackgroundMaterial;
  109649. /**
  109650. * Serializes the current material to its JSON representation.
  109651. * @returns The JSON representation.
  109652. */
  109653. serialize(): any;
  109654. /**
  109655. * Gets the class name of the material
  109656. * @returns "BackgroundMaterial"
  109657. */
  109658. getClassName(): string;
  109659. /**
  109660. * Parse a JSON input to create back a background material.
  109661. * @param source The JSON data to parse
  109662. * @param scene The scene to create the parsed material in
  109663. * @param rootUrl The root url of the assets the material depends upon
  109664. * @returns the instantiated BackgroundMaterial.
  109665. */
  109666. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109667. }
  109668. }
  109669. declare module BABYLON {
  109670. /**
  109671. * Represents the different options available during the creation of
  109672. * a Environment helper.
  109673. *
  109674. * This can control the default ground, skybox and image processing setup of your scene.
  109675. */
  109676. export interface IEnvironmentHelperOptions {
  109677. /**
  109678. * Specifies wether or not to create a ground.
  109679. * True by default.
  109680. */
  109681. createGround: boolean;
  109682. /**
  109683. * Specifies the ground size.
  109684. * 15 by default.
  109685. */
  109686. groundSize: number;
  109687. /**
  109688. * The texture used on the ground for the main color.
  109689. * Comes from the BabylonJS CDN by default.
  109690. *
  109691. * Remarks: Can be either a texture or a url.
  109692. */
  109693. groundTexture: string | BaseTexture;
  109694. /**
  109695. * The color mixed in the ground texture by default.
  109696. * BabylonJS clearColor by default.
  109697. */
  109698. groundColor: Color3;
  109699. /**
  109700. * Specifies the ground opacity.
  109701. * 1 by default.
  109702. */
  109703. groundOpacity: number;
  109704. /**
  109705. * Enables the ground to receive shadows.
  109706. * True by default.
  109707. */
  109708. enableGroundShadow: boolean;
  109709. /**
  109710. * Helps preventing the shadow to be fully black on the ground.
  109711. * 0.5 by default.
  109712. */
  109713. groundShadowLevel: number;
  109714. /**
  109715. * Creates a mirror texture attach to the ground.
  109716. * false by default.
  109717. */
  109718. enableGroundMirror: boolean;
  109719. /**
  109720. * Specifies the ground mirror size ratio.
  109721. * 0.3 by default as the default kernel is 64.
  109722. */
  109723. groundMirrorSizeRatio: number;
  109724. /**
  109725. * Specifies the ground mirror blur kernel size.
  109726. * 64 by default.
  109727. */
  109728. groundMirrorBlurKernel: number;
  109729. /**
  109730. * Specifies the ground mirror visibility amount.
  109731. * 1 by default
  109732. */
  109733. groundMirrorAmount: number;
  109734. /**
  109735. * Specifies the ground mirror reflectance weight.
  109736. * This uses the standard weight of the background material to setup the fresnel effect
  109737. * of the mirror.
  109738. * 1 by default.
  109739. */
  109740. groundMirrorFresnelWeight: number;
  109741. /**
  109742. * Specifies the ground mirror Falloff distance.
  109743. * This can helps reducing the size of the reflection.
  109744. * 0 by Default.
  109745. */
  109746. groundMirrorFallOffDistance: number;
  109747. /**
  109748. * Specifies the ground mirror texture type.
  109749. * Unsigned Int by Default.
  109750. */
  109751. groundMirrorTextureType: number;
  109752. /**
  109753. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109754. * the shown objects.
  109755. */
  109756. groundYBias: number;
  109757. /**
  109758. * Specifies wether or not to create a skybox.
  109759. * True by default.
  109760. */
  109761. createSkybox: boolean;
  109762. /**
  109763. * Specifies the skybox size.
  109764. * 20 by default.
  109765. */
  109766. skyboxSize: number;
  109767. /**
  109768. * The texture used on the skybox for the main color.
  109769. * Comes from the BabylonJS CDN by default.
  109770. *
  109771. * Remarks: Can be either a texture or a url.
  109772. */
  109773. skyboxTexture: string | BaseTexture;
  109774. /**
  109775. * The color mixed in the skybox texture by default.
  109776. * BabylonJS clearColor by default.
  109777. */
  109778. skyboxColor: Color3;
  109779. /**
  109780. * The background rotation around the Y axis of the scene.
  109781. * This helps aligning the key lights of your scene with the background.
  109782. * 0 by default.
  109783. */
  109784. backgroundYRotation: number;
  109785. /**
  109786. * Compute automatically the size of the elements to best fit with the scene.
  109787. */
  109788. sizeAuto: boolean;
  109789. /**
  109790. * Default position of the rootMesh if autoSize is not true.
  109791. */
  109792. rootPosition: Vector3;
  109793. /**
  109794. * Sets up the image processing in the scene.
  109795. * true by default.
  109796. */
  109797. setupImageProcessing: boolean;
  109798. /**
  109799. * The texture used as your environment texture in the scene.
  109800. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109801. *
  109802. * Remarks: Can be either a texture or a url.
  109803. */
  109804. environmentTexture: string | BaseTexture;
  109805. /**
  109806. * The value of the exposure to apply to the scene.
  109807. * 0.6 by default if setupImageProcessing is true.
  109808. */
  109809. cameraExposure: number;
  109810. /**
  109811. * The value of the contrast to apply to the scene.
  109812. * 1.6 by default if setupImageProcessing is true.
  109813. */
  109814. cameraContrast: number;
  109815. /**
  109816. * Specifies wether or not tonemapping should be enabled in the scene.
  109817. * true by default if setupImageProcessing is true.
  109818. */
  109819. toneMappingEnabled: boolean;
  109820. }
  109821. /**
  109822. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109823. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109824. * It also helps with the default setup of your imageProcessing configuration.
  109825. */
  109826. export class EnvironmentHelper {
  109827. /**
  109828. * Default ground texture URL.
  109829. */
  109830. private static _groundTextureCDNUrl;
  109831. /**
  109832. * Default skybox texture URL.
  109833. */
  109834. private static _skyboxTextureCDNUrl;
  109835. /**
  109836. * Default environment texture URL.
  109837. */
  109838. private static _environmentTextureCDNUrl;
  109839. /**
  109840. * Creates the default options for the helper.
  109841. */
  109842. private static _getDefaultOptions;
  109843. private _rootMesh;
  109844. /**
  109845. * Gets the root mesh created by the helper.
  109846. */
  109847. readonly rootMesh: Mesh;
  109848. private _skybox;
  109849. /**
  109850. * Gets the skybox created by the helper.
  109851. */
  109852. readonly skybox: Nullable<Mesh>;
  109853. private _skyboxTexture;
  109854. /**
  109855. * Gets the skybox texture created by the helper.
  109856. */
  109857. readonly skyboxTexture: Nullable<BaseTexture>;
  109858. private _skyboxMaterial;
  109859. /**
  109860. * Gets the skybox material created by the helper.
  109861. */
  109862. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109863. private _ground;
  109864. /**
  109865. * Gets the ground mesh created by the helper.
  109866. */
  109867. readonly ground: Nullable<Mesh>;
  109868. private _groundTexture;
  109869. /**
  109870. * Gets the ground texture created by the helper.
  109871. */
  109872. readonly groundTexture: Nullable<BaseTexture>;
  109873. private _groundMirror;
  109874. /**
  109875. * Gets the ground mirror created by the helper.
  109876. */
  109877. readonly groundMirror: Nullable<MirrorTexture>;
  109878. /**
  109879. * Gets the ground mirror render list to helps pushing the meshes
  109880. * you wish in the ground reflection.
  109881. */
  109882. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109883. private _groundMaterial;
  109884. /**
  109885. * Gets the ground material created by the helper.
  109886. */
  109887. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109888. /**
  109889. * Stores the creation options.
  109890. */
  109891. private readonly _scene;
  109892. private _options;
  109893. /**
  109894. * This observable will be notified with any error during the creation of the environment,
  109895. * mainly texture creation errors.
  109896. */
  109897. onErrorObservable: Observable<{
  109898. message?: string;
  109899. exception?: any;
  109900. }>;
  109901. /**
  109902. * constructor
  109903. * @param options Defines the options we want to customize the helper
  109904. * @param scene The scene to add the material to
  109905. */
  109906. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109907. /**
  109908. * Updates the background according to the new options
  109909. * @param options
  109910. */
  109911. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109912. /**
  109913. * Sets the primary color of all the available elements.
  109914. * @param color the main color to affect to the ground and the background
  109915. */
  109916. setMainColor(color: Color3): void;
  109917. /**
  109918. * Setup the image processing according to the specified options.
  109919. */
  109920. private _setupImageProcessing;
  109921. /**
  109922. * Setup the environment texture according to the specified options.
  109923. */
  109924. private _setupEnvironmentTexture;
  109925. /**
  109926. * Setup the background according to the specified options.
  109927. */
  109928. private _setupBackground;
  109929. /**
  109930. * Get the scene sizes according to the setup.
  109931. */
  109932. private _getSceneSize;
  109933. /**
  109934. * Setup the ground according to the specified options.
  109935. */
  109936. private _setupGround;
  109937. /**
  109938. * Setup the ground material according to the specified options.
  109939. */
  109940. private _setupGroundMaterial;
  109941. /**
  109942. * Setup the ground diffuse texture according to the specified options.
  109943. */
  109944. private _setupGroundDiffuseTexture;
  109945. /**
  109946. * Setup the ground mirror texture according to the specified options.
  109947. */
  109948. private _setupGroundMirrorTexture;
  109949. /**
  109950. * Setup the ground to receive the mirror texture.
  109951. */
  109952. private _setupMirrorInGroundMaterial;
  109953. /**
  109954. * Setup the skybox according to the specified options.
  109955. */
  109956. private _setupSkybox;
  109957. /**
  109958. * Setup the skybox material according to the specified options.
  109959. */
  109960. private _setupSkyboxMaterial;
  109961. /**
  109962. * Setup the skybox reflection texture according to the specified options.
  109963. */
  109964. private _setupSkyboxReflectionTexture;
  109965. private _errorHandler;
  109966. /**
  109967. * Dispose all the elements created by the Helper.
  109968. */
  109969. dispose(): void;
  109970. }
  109971. }
  109972. declare module BABYLON {
  109973. /**
  109974. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109975. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109976. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109977. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109978. */
  109979. export class PhotoDome extends TransformNode {
  109980. /**
  109981. * Define the image as a Monoscopic panoramic 360 image.
  109982. */
  109983. static readonly MODE_MONOSCOPIC: number;
  109984. /**
  109985. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109986. */
  109987. static readonly MODE_TOPBOTTOM: number;
  109988. /**
  109989. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109990. */
  109991. static readonly MODE_SIDEBYSIDE: number;
  109992. private _useDirectMapping;
  109993. /**
  109994. * The texture being displayed on the sphere
  109995. */
  109996. protected _photoTexture: Texture;
  109997. /**
  109998. * Gets or sets the texture being displayed on the sphere
  109999. */
  110000. photoTexture: Texture;
  110001. /**
  110002. * Observable raised when an error occured while loading the 360 image
  110003. */
  110004. onLoadErrorObservable: Observable<string>;
  110005. /**
  110006. * The skybox material
  110007. */
  110008. protected _material: BackgroundMaterial;
  110009. /**
  110010. * The surface used for the skybox
  110011. */
  110012. protected _mesh: Mesh;
  110013. /**
  110014. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110015. * Also see the options.resolution property.
  110016. */
  110017. fovMultiplier: number;
  110018. private _imageMode;
  110019. /**
  110020. * Gets or set the current video mode for the video. It can be:
  110021. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  110022. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110023. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110024. */
  110025. imageMode: number;
  110026. /**
  110027. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  110028. * @param name Element's name, child elements will append suffixes for their own names.
  110029. * @param urlsOfPhoto defines the url of the photo to display
  110030. * @param options defines an object containing optional or exposed sub element properties
  110031. * @param onError defines a callback called when an error occured while loading the texture
  110032. */
  110033. constructor(name: string, urlOfPhoto: string, options: {
  110034. resolution?: number;
  110035. size?: number;
  110036. useDirectMapping?: boolean;
  110037. faceForward?: boolean;
  110038. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  110039. private _onBeforeCameraRenderObserver;
  110040. private _changeImageMode;
  110041. /**
  110042. * Releases resources associated with this node.
  110043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110045. */
  110046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. /** @hidden */
  110051. export var rgbdDecodePixelShader: {
  110052. name: string;
  110053. shader: string;
  110054. };
  110055. }
  110056. declare module BABYLON {
  110057. /**
  110058. * Class used to host texture specific utilities
  110059. */
  110060. export class BRDFTextureTools {
  110061. /**
  110062. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  110063. * @param texture the texture to expand.
  110064. */
  110065. private static _ExpandDefaultBRDFTexture;
  110066. /**
  110067. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  110068. * @param scene defines the hosting scene
  110069. * @returns the environment BRDF texture
  110070. */
  110071. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  110072. private static _environmentBRDFBase64Texture;
  110073. }
  110074. }
  110075. declare module BABYLON {
  110076. /**
  110077. * @hidden
  110078. */
  110079. export interface IMaterialClearCoatDefines {
  110080. CLEARCOAT: boolean;
  110081. CLEARCOAT_DEFAULTIOR: boolean;
  110082. CLEARCOAT_TEXTURE: boolean;
  110083. CLEARCOAT_TEXTUREDIRECTUV: number;
  110084. CLEARCOAT_BUMP: boolean;
  110085. CLEARCOAT_BUMPDIRECTUV: number;
  110086. CLEARCOAT_TINT: boolean;
  110087. CLEARCOAT_TINT_TEXTURE: boolean;
  110088. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110089. /** @hidden */
  110090. _areTexturesDirty: boolean;
  110091. }
  110092. /**
  110093. * Define the code related to the clear coat parameters of the pbr material.
  110094. */
  110095. export class PBRClearCoatConfiguration {
  110096. /**
  110097. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110098. * The default fits with a polyurethane material.
  110099. */
  110100. private static readonly _DefaultIndexOfRefraction;
  110101. private _isEnabled;
  110102. /**
  110103. * Defines if the clear coat is enabled in the material.
  110104. */
  110105. isEnabled: boolean;
  110106. /**
  110107. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  110108. */
  110109. intensity: number;
  110110. /**
  110111. * Defines the clear coat layer roughness.
  110112. */
  110113. roughness: number;
  110114. private _indexOfRefraction;
  110115. /**
  110116. * Defines the index of refraction of the clear coat.
  110117. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110118. * The default fits with a polyurethane material.
  110119. * Changing the default value is more performance intensive.
  110120. */
  110121. indexOfRefraction: number;
  110122. private _texture;
  110123. /**
  110124. * Stores the clear coat values in a texture.
  110125. */
  110126. texture: Nullable<BaseTexture>;
  110127. private _bumpTexture;
  110128. /**
  110129. * Define the clear coat specific bump texture.
  110130. */
  110131. bumpTexture: Nullable<BaseTexture>;
  110132. private _isTintEnabled;
  110133. /**
  110134. * Defines if the clear coat tint is enabled in the material.
  110135. */
  110136. isTintEnabled: boolean;
  110137. /**
  110138. * Defines the clear coat tint of the material.
  110139. * This is only use if tint is enabled
  110140. */
  110141. tintColor: Color3;
  110142. /**
  110143. * Defines the distance at which the tint color should be found in the
  110144. * clear coat media.
  110145. * This is only use if tint is enabled
  110146. */
  110147. tintColorAtDistance: number;
  110148. /**
  110149. * Defines the clear coat layer thickness.
  110150. * This is only use if tint is enabled
  110151. */
  110152. tintThickness: number;
  110153. private _tintTexture;
  110154. /**
  110155. * Stores the clear tint values in a texture.
  110156. * rgb is tint
  110157. * a is a thickness factor
  110158. */
  110159. tintTexture: Nullable<BaseTexture>;
  110160. /** @hidden */
  110161. private _internalMarkAllSubMeshesAsTexturesDirty;
  110162. /** @hidden */
  110163. _markAllSubMeshesAsTexturesDirty(): void;
  110164. /**
  110165. * Instantiate a new istance of clear coat configuration.
  110166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110167. */
  110168. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110169. /**
  110170. * Gets wehter the submesh is ready to be used or not.
  110171. * @param defines the list of "defines" to update.
  110172. * @param scene defines the scene the material belongs to.
  110173. * @param engine defines the engine the material belongs to.
  110174. * @param disableBumpMap defines wether the material disables bump or not.
  110175. * @returns - boolean indicating that the submesh is ready or not.
  110176. */
  110177. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110178. /**
  110179. * Checks to see if a texture is used in the material.
  110180. * @param defines the list of "defines" to update.
  110181. * @param scene defines the scene to the material belongs to.
  110182. */
  110183. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110184. /**
  110185. * Binds the material data.
  110186. * @param uniformBuffer defines the Uniform buffer to fill in.
  110187. * @param scene defines the scene the material belongs to.
  110188. * @param engine defines the engine the material belongs to.
  110189. * @param disableBumpMap defines wether the material disables bump or not.
  110190. * @param isFrozen defines wether the material is frozen or not.
  110191. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110192. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110193. */
  110194. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110195. /**
  110196. * Checks to see if a texture is used in the material.
  110197. * @param texture - Base texture to use.
  110198. * @returns - Boolean specifying if a texture is used in the material.
  110199. */
  110200. hasTexture(texture: BaseTexture): boolean;
  110201. /**
  110202. * Returns an array of the actively used textures.
  110203. * @param activeTextures Array of BaseTextures
  110204. */
  110205. getActiveTextures(activeTextures: BaseTexture[]): void;
  110206. /**
  110207. * Returns the animatable textures.
  110208. * @param animatables Array of animatable textures.
  110209. */
  110210. getAnimatables(animatables: IAnimatable[]): void;
  110211. /**
  110212. * Disposes the resources of the material.
  110213. * @param forceDisposeTextures - Forces the disposal of all textures.
  110214. */
  110215. dispose(forceDisposeTextures?: boolean): void;
  110216. /**
  110217. * Get the current class name of the texture useful for serialization or dynamic coding.
  110218. * @returns "PBRClearCoatConfiguration"
  110219. */
  110220. getClassName(): string;
  110221. /**
  110222. * Add fallbacks to the effect fallbacks list.
  110223. * @param defines defines the Base texture to use.
  110224. * @param fallbacks defines the current fallback list.
  110225. * @param currentRank defines the current fallback rank.
  110226. * @returns the new fallback rank.
  110227. */
  110228. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110229. /**
  110230. * Add the required uniforms to the current list.
  110231. * @param uniforms defines the current uniform list.
  110232. */
  110233. static AddUniforms(uniforms: string[]): void;
  110234. /**
  110235. * Add the required samplers to the current list.
  110236. * @param samplers defines the current sampler list.
  110237. */
  110238. static AddSamplers(samplers: string[]): void;
  110239. /**
  110240. * Add the required uniforms to the current buffer.
  110241. * @param uniformBuffer defines the current uniform buffer.
  110242. */
  110243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110244. /**
  110245. * Makes a duplicate of the current configuration into another one.
  110246. * @param clearCoatConfiguration define the config where to copy the info
  110247. */
  110248. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110249. /**
  110250. * Serializes this clear coat configuration.
  110251. * @returns - An object with the serialized config.
  110252. */
  110253. serialize(): any;
  110254. /**
  110255. * Parses a anisotropy Configuration from a serialized object.
  110256. * @param source - Serialized object.
  110257. * @param scene Defines the scene we are parsing for
  110258. * @param rootUrl Defines the rootUrl to load from
  110259. */
  110260. parse(source: any, scene: Scene, rootUrl: string): void;
  110261. }
  110262. }
  110263. declare module BABYLON {
  110264. /**
  110265. * @hidden
  110266. */
  110267. export interface IMaterialAnisotropicDefines {
  110268. ANISOTROPIC: boolean;
  110269. ANISOTROPIC_TEXTURE: boolean;
  110270. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110271. MAINUV1: boolean;
  110272. _areTexturesDirty: boolean;
  110273. _needUVs: boolean;
  110274. }
  110275. /**
  110276. * Define the code related to the anisotropic parameters of the pbr material.
  110277. */
  110278. export class PBRAnisotropicConfiguration {
  110279. private _isEnabled;
  110280. /**
  110281. * Defines if the anisotropy is enabled in the material.
  110282. */
  110283. isEnabled: boolean;
  110284. /**
  110285. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110286. */
  110287. intensity: number;
  110288. /**
  110289. * Defines if the effect is along the tangents, bitangents or in between.
  110290. * By default, the effect is "strectching" the highlights along the tangents.
  110291. */
  110292. direction: Vector2;
  110293. private _texture;
  110294. /**
  110295. * Stores the anisotropy values in a texture.
  110296. * rg is direction (like normal from -1 to 1)
  110297. * b is a intensity
  110298. */
  110299. texture: Nullable<BaseTexture>;
  110300. /** @hidden */
  110301. private _internalMarkAllSubMeshesAsTexturesDirty;
  110302. /** @hidden */
  110303. _markAllSubMeshesAsTexturesDirty(): void;
  110304. /**
  110305. * Instantiate a new istance of anisotropy configuration.
  110306. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110307. */
  110308. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110309. /**
  110310. * Specifies that the submesh is ready to be used.
  110311. * @param defines the list of "defines" to update.
  110312. * @param scene defines the scene the material belongs to.
  110313. * @returns - boolean indicating that the submesh is ready or not.
  110314. */
  110315. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110316. /**
  110317. * Checks to see if a texture is used in the material.
  110318. * @param defines the list of "defines" to update.
  110319. * @param mesh the mesh we are preparing the defines for.
  110320. * @param scene defines the scene the material belongs to.
  110321. */
  110322. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110323. /**
  110324. * Binds the material data.
  110325. * @param uniformBuffer defines the Uniform buffer to fill in.
  110326. * @param scene defines the scene the material belongs to.
  110327. * @param isFrozen defines wether the material is frozen or not.
  110328. */
  110329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110330. /**
  110331. * Checks to see if a texture is used in the material.
  110332. * @param texture - Base texture to use.
  110333. * @returns - Boolean specifying if a texture is used in the material.
  110334. */
  110335. hasTexture(texture: BaseTexture): boolean;
  110336. /**
  110337. * Returns an array of the actively used textures.
  110338. * @param activeTextures Array of BaseTextures
  110339. */
  110340. getActiveTextures(activeTextures: BaseTexture[]): void;
  110341. /**
  110342. * Returns the animatable textures.
  110343. * @param animatables Array of animatable textures.
  110344. */
  110345. getAnimatables(animatables: IAnimatable[]): void;
  110346. /**
  110347. * Disposes the resources of the material.
  110348. * @param forceDisposeTextures - Forces the disposal of all textures.
  110349. */
  110350. dispose(forceDisposeTextures?: boolean): void;
  110351. /**
  110352. * Get the current class name of the texture useful for serialization or dynamic coding.
  110353. * @returns "PBRAnisotropicConfiguration"
  110354. */
  110355. getClassName(): string;
  110356. /**
  110357. * Add fallbacks to the effect fallbacks list.
  110358. * @param defines defines the Base texture to use.
  110359. * @param fallbacks defines the current fallback list.
  110360. * @param currentRank defines the current fallback rank.
  110361. * @returns the new fallback rank.
  110362. */
  110363. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110364. /**
  110365. * Add the required uniforms to the current list.
  110366. * @param uniforms defines the current uniform list.
  110367. */
  110368. static AddUniforms(uniforms: string[]): void;
  110369. /**
  110370. * Add the required uniforms to the current buffer.
  110371. * @param uniformBuffer defines the current uniform buffer.
  110372. */
  110373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110374. /**
  110375. * Add the required samplers to the current list.
  110376. * @param samplers defines the current sampler list.
  110377. */
  110378. static AddSamplers(samplers: string[]): void;
  110379. /**
  110380. * Makes a duplicate of the current configuration into another one.
  110381. * @param anisotropicConfiguration define the config where to copy the info
  110382. */
  110383. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110384. /**
  110385. * Serializes this anisotropy configuration.
  110386. * @returns - An object with the serialized config.
  110387. */
  110388. serialize(): any;
  110389. /**
  110390. * Parses a anisotropy Configuration from a serialized object.
  110391. * @param source - Serialized object.
  110392. * @param scene Defines the scene we are parsing for
  110393. * @param rootUrl Defines the rootUrl to load from
  110394. */
  110395. parse(source: any, scene: Scene, rootUrl: string): void;
  110396. }
  110397. }
  110398. declare module BABYLON {
  110399. /**
  110400. * @hidden
  110401. */
  110402. export interface IMaterialBRDFDefines {
  110403. BRDF_V_HEIGHT_CORRELATED: boolean;
  110404. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110405. SPHERICAL_HARMONICS: boolean;
  110406. /** @hidden */
  110407. _areMiscDirty: boolean;
  110408. }
  110409. /**
  110410. * Define the code related to the BRDF parameters of the pbr material.
  110411. */
  110412. export class PBRBRDFConfiguration {
  110413. /**
  110414. * Default value used for the energy conservation.
  110415. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110416. */
  110417. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110418. /**
  110419. * Default value used for the Smith Visibility Height Correlated mode.
  110420. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110421. */
  110422. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110423. /**
  110424. * Default value used for the IBL diffuse part.
  110425. * This can help switching back to the polynomials mode globally which is a tiny bit
  110426. * less GPU intensive at the drawback of a lower quality.
  110427. */
  110428. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110429. private _useEnergyConservation;
  110430. /**
  110431. * Defines if the material uses energy conservation.
  110432. */
  110433. useEnergyConservation: boolean;
  110434. private _useSmithVisibilityHeightCorrelated;
  110435. /**
  110436. * LEGACY Mode set to false
  110437. * Defines if the material uses height smith correlated visibility term.
  110438. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110439. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110440. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110441. * Not relying on height correlated will also disable energy conservation.
  110442. */
  110443. useSmithVisibilityHeightCorrelated: boolean;
  110444. private _useSphericalHarmonics;
  110445. /**
  110446. * LEGACY Mode set to false
  110447. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110448. * diffuse part of the IBL.
  110449. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110450. * to the ground truth.
  110451. */
  110452. useSphericalHarmonics: boolean;
  110453. /** @hidden */
  110454. private _internalMarkAllSubMeshesAsMiscDirty;
  110455. /** @hidden */
  110456. _markAllSubMeshesAsMiscDirty(): void;
  110457. /**
  110458. * Instantiate a new istance of clear coat configuration.
  110459. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110460. */
  110461. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110462. /**
  110463. * Checks to see if a texture is used in the material.
  110464. * @param defines the list of "defines" to update.
  110465. */
  110466. prepareDefines(defines: IMaterialBRDFDefines): void;
  110467. /**
  110468. * Get the current class name of the texture useful for serialization or dynamic coding.
  110469. * @returns "PBRClearCoatConfiguration"
  110470. */
  110471. getClassName(): string;
  110472. /**
  110473. * Makes a duplicate of the current configuration into another one.
  110474. * @param brdfConfiguration define the config where to copy the info
  110475. */
  110476. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110477. /**
  110478. * Serializes this BRDF configuration.
  110479. * @returns - An object with the serialized config.
  110480. */
  110481. serialize(): any;
  110482. /**
  110483. * Parses a anisotropy Configuration from a serialized object.
  110484. * @param source - Serialized object.
  110485. * @param scene Defines the scene we are parsing for
  110486. * @param rootUrl Defines the rootUrl to load from
  110487. */
  110488. parse(source: any, scene: Scene, rootUrl: string): void;
  110489. }
  110490. }
  110491. declare module BABYLON {
  110492. /**
  110493. * @hidden
  110494. */
  110495. export interface IMaterialSheenDefines {
  110496. SHEEN: boolean;
  110497. SHEEN_TEXTURE: boolean;
  110498. SHEEN_TEXTUREDIRECTUV: number;
  110499. SHEEN_LINKWITHALBEDO: boolean;
  110500. /** @hidden */
  110501. _areTexturesDirty: boolean;
  110502. }
  110503. /**
  110504. * Define the code related to the Sheen parameters of the pbr material.
  110505. */
  110506. export class PBRSheenConfiguration {
  110507. private _isEnabled;
  110508. /**
  110509. * Defines if the material uses sheen.
  110510. */
  110511. isEnabled: boolean;
  110512. private _linkSheenWithAlbedo;
  110513. /**
  110514. * Defines if the sheen is linked to the sheen color.
  110515. */
  110516. linkSheenWithAlbedo: boolean;
  110517. /**
  110518. * Defines the sheen intensity.
  110519. */
  110520. intensity: number;
  110521. /**
  110522. * Defines the sheen color.
  110523. */
  110524. color: Color3;
  110525. private _texture;
  110526. /**
  110527. * Stores the sheen tint values in a texture.
  110528. * rgb is tint
  110529. * a is a intensity
  110530. */
  110531. texture: Nullable<BaseTexture>;
  110532. /** @hidden */
  110533. private _internalMarkAllSubMeshesAsTexturesDirty;
  110534. /** @hidden */
  110535. _markAllSubMeshesAsTexturesDirty(): void;
  110536. /**
  110537. * Instantiate a new istance of clear coat configuration.
  110538. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110539. */
  110540. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110541. /**
  110542. * Specifies that the submesh is ready to be used.
  110543. * @param defines the list of "defines" to update.
  110544. * @param scene defines the scene the material belongs to.
  110545. * @returns - boolean indicating that the submesh is ready or not.
  110546. */
  110547. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110548. /**
  110549. * Checks to see if a texture is used in the material.
  110550. * @param defines the list of "defines" to update.
  110551. * @param scene defines the scene the material belongs to.
  110552. */
  110553. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110554. /**
  110555. * Binds the material data.
  110556. * @param uniformBuffer defines the Uniform buffer to fill in.
  110557. * @param scene defines the scene the material belongs to.
  110558. * @param isFrozen defines wether the material is frozen or not.
  110559. */
  110560. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110561. /**
  110562. * Checks to see if a texture is used in the material.
  110563. * @param texture - Base texture to use.
  110564. * @returns - Boolean specifying if a texture is used in the material.
  110565. */
  110566. hasTexture(texture: BaseTexture): boolean;
  110567. /**
  110568. * Returns an array of the actively used textures.
  110569. * @param activeTextures Array of BaseTextures
  110570. */
  110571. getActiveTextures(activeTextures: BaseTexture[]): void;
  110572. /**
  110573. * Returns the animatable textures.
  110574. * @param animatables Array of animatable textures.
  110575. */
  110576. getAnimatables(animatables: IAnimatable[]): void;
  110577. /**
  110578. * Disposes the resources of the material.
  110579. * @param forceDisposeTextures - Forces the disposal of all textures.
  110580. */
  110581. dispose(forceDisposeTextures?: boolean): void;
  110582. /**
  110583. * Get the current class name of the texture useful for serialization or dynamic coding.
  110584. * @returns "PBRSheenConfiguration"
  110585. */
  110586. getClassName(): string;
  110587. /**
  110588. * Add fallbacks to the effect fallbacks list.
  110589. * @param defines defines the Base texture to use.
  110590. * @param fallbacks defines the current fallback list.
  110591. * @param currentRank defines the current fallback rank.
  110592. * @returns the new fallback rank.
  110593. */
  110594. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110595. /**
  110596. * Add the required uniforms to the current list.
  110597. * @param uniforms defines the current uniform list.
  110598. */
  110599. static AddUniforms(uniforms: string[]): void;
  110600. /**
  110601. * Add the required uniforms to the current buffer.
  110602. * @param uniformBuffer defines the current uniform buffer.
  110603. */
  110604. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110605. /**
  110606. * Add the required samplers to the current list.
  110607. * @param samplers defines the current sampler list.
  110608. */
  110609. static AddSamplers(samplers: string[]): void;
  110610. /**
  110611. * Makes a duplicate of the current configuration into another one.
  110612. * @param sheenConfiguration define the config where to copy the info
  110613. */
  110614. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110615. /**
  110616. * Serializes this BRDF configuration.
  110617. * @returns - An object with the serialized config.
  110618. */
  110619. serialize(): any;
  110620. /**
  110621. * Parses a anisotropy Configuration from a serialized object.
  110622. * @param source - Serialized object.
  110623. * @param scene Defines the scene we are parsing for
  110624. * @param rootUrl Defines the rootUrl to load from
  110625. */
  110626. parse(source: any, scene: Scene, rootUrl: string): void;
  110627. }
  110628. }
  110629. declare module BABYLON {
  110630. /**
  110631. * @hidden
  110632. */
  110633. export interface IMaterialSubSurfaceDefines {
  110634. SUBSURFACE: boolean;
  110635. SS_REFRACTION: boolean;
  110636. SS_TRANSLUCENCY: boolean;
  110637. SS_SCATERRING: boolean;
  110638. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110639. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110640. SS_REFRACTIONMAP_3D: boolean;
  110641. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110642. SS_LODINREFRACTIONALPHA: boolean;
  110643. SS_GAMMAREFRACTION: boolean;
  110644. SS_RGBDREFRACTION: boolean;
  110645. SS_LINEARSPECULARREFRACTION: boolean;
  110646. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110647. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110648. /** @hidden */
  110649. _areTexturesDirty: boolean;
  110650. }
  110651. /**
  110652. * Define the code related to the sub surface parameters of the pbr material.
  110653. */
  110654. export class PBRSubSurfaceConfiguration {
  110655. private _isRefractionEnabled;
  110656. /**
  110657. * Defines if the refraction is enabled in the material.
  110658. */
  110659. isRefractionEnabled: boolean;
  110660. private _isTranslucencyEnabled;
  110661. /**
  110662. * Defines if the translucency is enabled in the material.
  110663. */
  110664. isTranslucencyEnabled: boolean;
  110665. private _isScatteringEnabled;
  110666. /**
  110667. * Defines the refraction intensity of the material.
  110668. * The refraction when enabled replaces the Diffuse part of the material.
  110669. * The intensity helps transitionning between diffuse and refraction.
  110670. */
  110671. refractionIntensity: number;
  110672. /**
  110673. * Defines the translucency intensity of the material.
  110674. * When translucency has been enabled, this defines how much of the "translucency"
  110675. * is addded to the diffuse part of the material.
  110676. */
  110677. translucencyIntensity: number;
  110678. /**
  110679. * Defines the scattering intensity of the material.
  110680. * When scattering has been enabled, this defines how much of the "scattered light"
  110681. * is addded to the diffuse part of the material.
  110682. */
  110683. scatteringIntensity: number;
  110684. private _thicknessTexture;
  110685. /**
  110686. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110687. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110688. * 0 would mean minimumThickness
  110689. * 1 would mean maximumThickness
  110690. * The other channels might be use as a mask to vary the different effects intensity.
  110691. */
  110692. thicknessTexture: Nullable<BaseTexture>;
  110693. private _refractionTexture;
  110694. /**
  110695. * Defines the texture to use for refraction.
  110696. */
  110697. refractionTexture: Nullable<BaseTexture>;
  110698. private _indexOfRefraction;
  110699. /**
  110700. * Defines the index of refraction used in the material.
  110701. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110702. */
  110703. indexOfRefraction: number;
  110704. private _invertRefractionY;
  110705. /**
  110706. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110707. */
  110708. invertRefractionY: boolean;
  110709. private _linkRefractionWithTransparency;
  110710. /**
  110711. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110712. * Materials half opaque for instance using refraction could benefit from this control.
  110713. */
  110714. linkRefractionWithTransparency: boolean;
  110715. /**
  110716. * Defines the minimum thickness stored in the thickness map.
  110717. * If no thickness map is defined, this value will be used to simulate thickness.
  110718. */
  110719. minimumThickness: number;
  110720. /**
  110721. * Defines the maximum thickness stored in the thickness map.
  110722. */
  110723. maximumThickness: number;
  110724. /**
  110725. * Defines the volume tint of the material.
  110726. * This is used for both translucency and scattering.
  110727. */
  110728. tintColor: Color3;
  110729. /**
  110730. * Defines the distance at which the tint color should be found in the media.
  110731. * This is used for refraction only.
  110732. */
  110733. tintColorAtDistance: number;
  110734. /**
  110735. * Defines how far each channel transmit through the media.
  110736. * It is defined as a color to simplify it selection.
  110737. */
  110738. diffusionDistance: Color3;
  110739. private _useMaskFromThicknessTexture;
  110740. /**
  110741. * Stores the intensity of the different subsurface effects in the thickness texture.
  110742. * * the green channel is the translucency intensity.
  110743. * * the blue channel is the scattering intensity.
  110744. * * the alpha channel is the refraction intensity.
  110745. */
  110746. useMaskFromThicknessTexture: boolean;
  110747. /** @hidden */
  110748. private _internalMarkAllSubMeshesAsTexturesDirty;
  110749. /** @hidden */
  110750. _markAllSubMeshesAsTexturesDirty(): void;
  110751. /**
  110752. * Instantiate a new istance of sub surface configuration.
  110753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110754. */
  110755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110756. /**
  110757. * Gets wehter the submesh is ready to be used or not.
  110758. * @param defines the list of "defines" to update.
  110759. * @param scene defines the scene the material belongs to.
  110760. * @returns - boolean indicating that the submesh is ready or not.
  110761. */
  110762. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110763. /**
  110764. * Checks to see if a texture is used in the material.
  110765. * @param defines the list of "defines" to update.
  110766. * @param scene defines the scene to the material belongs to.
  110767. */
  110768. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110769. /**
  110770. * Binds the material data.
  110771. * @param uniformBuffer defines the Uniform buffer to fill in.
  110772. * @param scene defines the scene the material belongs to.
  110773. * @param engine defines the engine the material belongs to.
  110774. * @param isFrozen defines wether the material is frozen or not.
  110775. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110776. */
  110777. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110778. /**
  110779. * Unbinds the material from the mesh.
  110780. * @param activeEffect defines the effect that should be unbound from.
  110781. * @returns true if unbound, otherwise false
  110782. */
  110783. unbind(activeEffect: Effect): boolean;
  110784. /**
  110785. * Returns the texture used for refraction or null if none is used.
  110786. * @param scene defines the scene the material belongs to.
  110787. * @returns - Refraction texture if present. If no refraction texture and refraction
  110788. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110789. */
  110790. private _getRefractionTexture;
  110791. /**
  110792. * Returns true if alpha blending should be disabled.
  110793. */
  110794. readonly disableAlphaBlending: boolean;
  110795. /**
  110796. * Fills the list of render target textures.
  110797. * @param renderTargets the list of render targets to update
  110798. */
  110799. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110800. /**
  110801. * Checks to see if a texture is used in the material.
  110802. * @param texture - Base texture to use.
  110803. * @returns - Boolean specifying if a texture is used in the material.
  110804. */
  110805. hasTexture(texture: BaseTexture): boolean;
  110806. /**
  110807. * Gets a boolean indicating that current material needs to register RTT
  110808. * @returns true if this uses a render target otherwise false.
  110809. */
  110810. hasRenderTargetTextures(): boolean;
  110811. /**
  110812. * Returns an array of the actively used textures.
  110813. * @param activeTextures Array of BaseTextures
  110814. */
  110815. getActiveTextures(activeTextures: BaseTexture[]): void;
  110816. /**
  110817. * Returns the animatable textures.
  110818. * @param animatables Array of animatable textures.
  110819. */
  110820. getAnimatables(animatables: IAnimatable[]): void;
  110821. /**
  110822. * Disposes the resources of the material.
  110823. * @param forceDisposeTextures - Forces the disposal of all textures.
  110824. */
  110825. dispose(forceDisposeTextures?: boolean): void;
  110826. /**
  110827. * Get the current class name of the texture useful for serialization or dynamic coding.
  110828. * @returns "PBRSubSurfaceConfiguration"
  110829. */
  110830. getClassName(): string;
  110831. /**
  110832. * Add fallbacks to the effect fallbacks list.
  110833. * @param defines defines the Base texture to use.
  110834. * @param fallbacks defines the current fallback list.
  110835. * @param currentRank defines the current fallback rank.
  110836. * @returns the new fallback rank.
  110837. */
  110838. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110839. /**
  110840. * Add the required uniforms to the current list.
  110841. * @param uniforms defines the current uniform list.
  110842. */
  110843. static AddUniforms(uniforms: string[]): void;
  110844. /**
  110845. * Add the required samplers to the current list.
  110846. * @param samplers defines the current sampler list.
  110847. */
  110848. static AddSamplers(samplers: string[]): void;
  110849. /**
  110850. * Add the required uniforms to the current buffer.
  110851. * @param uniformBuffer defines the current uniform buffer.
  110852. */
  110853. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110854. /**
  110855. * Makes a duplicate of the current configuration into another one.
  110856. * @param configuration define the config where to copy the info
  110857. */
  110858. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110859. /**
  110860. * Serializes this Sub Surface configuration.
  110861. * @returns - An object with the serialized config.
  110862. */
  110863. serialize(): any;
  110864. /**
  110865. * Parses a anisotropy Configuration from a serialized object.
  110866. * @param source - Serialized object.
  110867. * @param scene Defines the scene we are parsing for
  110868. * @param rootUrl Defines the rootUrl to load from
  110869. */
  110870. parse(source: any, scene: Scene, rootUrl: string): void;
  110871. }
  110872. }
  110873. declare module BABYLON {
  110874. /** @hidden */
  110875. export var pbrFragmentDeclaration: {
  110876. name: string;
  110877. shader: string;
  110878. };
  110879. }
  110880. declare module BABYLON {
  110881. /** @hidden */
  110882. export var pbrUboDeclaration: {
  110883. name: string;
  110884. shader: string;
  110885. };
  110886. }
  110887. declare module BABYLON {
  110888. /** @hidden */
  110889. export var pbrFragmentExtraDeclaration: {
  110890. name: string;
  110891. shader: string;
  110892. };
  110893. }
  110894. declare module BABYLON {
  110895. /** @hidden */
  110896. export var pbrFragmentSamplersDeclaration: {
  110897. name: string;
  110898. shader: string;
  110899. };
  110900. }
  110901. declare module BABYLON {
  110902. /** @hidden */
  110903. export var pbrHelperFunctions: {
  110904. name: string;
  110905. shader: string;
  110906. };
  110907. }
  110908. declare module BABYLON {
  110909. /** @hidden */
  110910. export var harmonicsFunctions: {
  110911. name: string;
  110912. shader: string;
  110913. };
  110914. }
  110915. declare module BABYLON {
  110916. /** @hidden */
  110917. export var pbrDirectLightingSetupFunctions: {
  110918. name: string;
  110919. shader: string;
  110920. };
  110921. }
  110922. declare module BABYLON {
  110923. /** @hidden */
  110924. export var pbrDirectLightingFalloffFunctions: {
  110925. name: string;
  110926. shader: string;
  110927. };
  110928. }
  110929. declare module BABYLON {
  110930. /** @hidden */
  110931. export var pbrBRDFFunctions: {
  110932. name: string;
  110933. shader: string;
  110934. };
  110935. }
  110936. declare module BABYLON {
  110937. /** @hidden */
  110938. export var pbrDirectLightingFunctions: {
  110939. name: string;
  110940. shader: string;
  110941. };
  110942. }
  110943. declare module BABYLON {
  110944. /** @hidden */
  110945. export var pbrIBLFunctions: {
  110946. name: string;
  110947. shader: string;
  110948. };
  110949. }
  110950. declare module BABYLON {
  110951. /** @hidden */
  110952. export var pbrDebug: {
  110953. name: string;
  110954. shader: string;
  110955. };
  110956. }
  110957. declare module BABYLON {
  110958. /** @hidden */
  110959. export var pbrPixelShader: {
  110960. name: string;
  110961. shader: string;
  110962. };
  110963. }
  110964. declare module BABYLON {
  110965. /** @hidden */
  110966. export var pbrVertexDeclaration: {
  110967. name: string;
  110968. shader: string;
  110969. };
  110970. }
  110971. declare module BABYLON {
  110972. /** @hidden */
  110973. export var pbrVertexShader: {
  110974. name: string;
  110975. shader: string;
  110976. };
  110977. }
  110978. declare module BABYLON {
  110979. /**
  110980. * Manages the defines for the PBR Material.
  110981. * @hidden
  110982. */
  110983. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110984. PBR: boolean;
  110985. MAINUV1: boolean;
  110986. MAINUV2: boolean;
  110987. UV1: boolean;
  110988. UV2: boolean;
  110989. ALBEDO: boolean;
  110990. ALBEDODIRECTUV: number;
  110991. VERTEXCOLOR: boolean;
  110992. AMBIENT: boolean;
  110993. AMBIENTDIRECTUV: number;
  110994. AMBIENTINGRAYSCALE: boolean;
  110995. OPACITY: boolean;
  110996. VERTEXALPHA: boolean;
  110997. OPACITYDIRECTUV: number;
  110998. OPACITYRGB: boolean;
  110999. ALPHATEST: boolean;
  111000. DEPTHPREPASS: boolean;
  111001. ALPHABLEND: boolean;
  111002. ALPHAFROMALBEDO: boolean;
  111003. ALPHATESTVALUE: string;
  111004. SPECULAROVERALPHA: boolean;
  111005. RADIANCEOVERALPHA: boolean;
  111006. ALPHAFRESNEL: boolean;
  111007. LINEARALPHAFRESNEL: boolean;
  111008. PREMULTIPLYALPHA: boolean;
  111009. EMISSIVE: boolean;
  111010. EMISSIVEDIRECTUV: number;
  111011. REFLECTIVITY: boolean;
  111012. REFLECTIVITYDIRECTUV: number;
  111013. SPECULARTERM: boolean;
  111014. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  111015. MICROSURFACEAUTOMATIC: boolean;
  111016. LODBASEDMICROSFURACE: boolean;
  111017. MICROSURFACEMAP: boolean;
  111018. MICROSURFACEMAPDIRECTUV: number;
  111019. METALLICWORKFLOW: boolean;
  111020. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  111021. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  111022. METALLNESSSTOREINMETALMAPBLUE: boolean;
  111023. AOSTOREINMETALMAPRED: boolean;
  111024. ENVIRONMENTBRDF: boolean;
  111025. ENVIRONMENTBRDF_RGBD: boolean;
  111026. NORMAL: boolean;
  111027. TANGENT: boolean;
  111028. BUMP: boolean;
  111029. BUMPDIRECTUV: number;
  111030. OBJECTSPACE_NORMALMAP: boolean;
  111031. PARALLAX: boolean;
  111032. PARALLAXOCCLUSION: boolean;
  111033. NORMALXYSCALE: boolean;
  111034. LIGHTMAP: boolean;
  111035. LIGHTMAPDIRECTUV: number;
  111036. USELIGHTMAPASSHADOWMAP: boolean;
  111037. GAMMALIGHTMAP: boolean;
  111038. REFLECTION: boolean;
  111039. REFLECTIONMAP_3D: boolean;
  111040. REFLECTIONMAP_SPHERICAL: boolean;
  111041. REFLECTIONMAP_PLANAR: boolean;
  111042. REFLECTIONMAP_CUBIC: boolean;
  111043. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111044. REFLECTIONMAP_PROJECTION: boolean;
  111045. REFLECTIONMAP_SKYBOX: boolean;
  111046. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  111047. REFLECTIONMAP_EXPLICIT: boolean;
  111048. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111049. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111050. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111051. INVERTCUBICMAP: boolean;
  111052. USESPHERICALFROMREFLECTIONMAP: boolean;
  111053. USEIRRADIANCEMAP: boolean;
  111054. SPHERICAL_HARMONICS: boolean;
  111055. USESPHERICALINVERTEX: boolean;
  111056. REFLECTIONMAP_OPPOSITEZ: boolean;
  111057. LODINREFLECTIONALPHA: boolean;
  111058. GAMMAREFLECTION: boolean;
  111059. RGBDREFLECTION: boolean;
  111060. LINEARSPECULARREFLECTION: boolean;
  111061. RADIANCEOCCLUSION: boolean;
  111062. HORIZONOCCLUSION: boolean;
  111063. INSTANCES: boolean;
  111064. NUM_BONE_INFLUENCERS: number;
  111065. BonesPerMesh: number;
  111066. BONETEXTURE: boolean;
  111067. NONUNIFORMSCALING: boolean;
  111068. MORPHTARGETS: boolean;
  111069. MORPHTARGETS_NORMAL: boolean;
  111070. MORPHTARGETS_TANGENT: boolean;
  111071. MORPHTARGETS_UV: boolean;
  111072. NUM_MORPH_INFLUENCERS: number;
  111073. IMAGEPROCESSING: boolean;
  111074. VIGNETTE: boolean;
  111075. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111076. VIGNETTEBLENDMODEOPAQUE: boolean;
  111077. TONEMAPPING: boolean;
  111078. TONEMAPPING_ACES: boolean;
  111079. CONTRAST: boolean;
  111080. COLORCURVES: boolean;
  111081. COLORGRADING: boolean;
  111082. COLORGRADING3D: boolean;
  111083. SAMPLER3DGREENDEPTH: boolean;
  111084. SAMPLER3DBGRMAP: boolean;
  111085. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111086. EXPOSURE: boolean;
  111087. MULTIVIEW: boolean;
  111088. USEPHYSICALLIGHTFALLOFF: boolean;
  111089. USEGLTFLIGHTFALLOFF: boolean;
  111090. TWOSIDEDLIGHTING: boolean;
  111091. SHADOWFLOAT: boolean;
  111092. CLIPPLANE: boolean;
  111093. CLIPPLANE2: boolean;
  111094. CLIPPLANE3: boolean;
  111095. CLIPPLANE4: boolean;
  111096. POINTSIZE: boolean;
  111097. FOG: boolean;
  111098. LOGARITHMICDEPTH: boolean;
  111099. FORCENORMALFORWARD: boolean;
  111100. SPECULARAA: boolean;
  111101. CLEARCOAT: boolean;
  111102. CLEARCOAT_DEFAULTIOR: boolean;
  111103. CLEARCOAT_TEXTURE: boolean;
  111104. CLEARCOAT_TEXTUREDIRECTUV: number;
  111105. CLEARCOAT_BUMP: boolean;
  111106. CLEARCOAT_BUMPDIRECTUV: number;
  111107. CLEARCOAT_TINT: boolean;
  111108. CLEARCOAT_TINT_TEXTURE: boolean;
  111109. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111110. ANISOTROPIC: boolean;
  111111. ANISOTROPIC_TEXTURE: boolean;
  111112. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111113. BRDF_V_HEIGHT_CORRELATED: boolean;
  111114. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111115. SHEEN: boolean;
  111116. SHEEN_TEXTURE: boolean;
  111117. SHEEN_TEXTUREDIRECTUV: number;
  111118. SHEEN_LINKWITHALBEDO: boolean;
  111119. SUBSURFACE: boolean;
  111120. SS_REFRACTION: boolean;
  111121. SS_TRANSLUCENCY: boolean;
  111122. SS_SCATERRING: boolean;
  111123. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111124. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111125. SS_REFRACTIONMAP_3D: boolean;
  111126. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111127. SS_LODINREFRACTIONALPHA: boolean;
  111128. SS_GAMMAREFRACTION: boolean;
  111129. SS_RGBDREFRACTION: boolean;
  111130. SS_LINEARSPECULARREFRACTION: boolean;
  111131. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111132. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111133. UNLIT: boolean;
  111134. DEBUGMODE: number;
  111135. /**
  111136. * Initializes the PBR Material defines.
  111137. */
  111138. constructor();
  111139. /**
  111140. * Resets the PBR Material defines.
  111141. */
  111142. reset(): void;
  111143. }
  111144. /**
  111145. * The Physically based material base class of BJS.
  111146. *
  111147. * This offers the main features of a standard PBR material.
  111148. * For more information, please refer to the documentation :
  111149. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111150. */
  111151. export abstract class PBRBaseMaterial extends PushMaterial {
  111152. /**
  111153. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111154. */
  111155. static readonly PBRMATERIAL_OPAQUE: number;
  111156. /**
  111157. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111158. */
  111159. static readonly PBRMATERIAL_ALPHATEST: number;
  111160. /**
  111161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111162. */
  111163. static readonly PBRMATERIAL_ALPHABLEND: number;
  111164. /**
  111165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111166. * They are also discarded below the alpha cutoff threshold to improve performances.
  111167. */
  111168. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111169. /**
  111170. * Defines the default value of how much AO map is occluding the analytical lights
  111171. * (point spot...).
  111172. */
  111173. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111174. /**
  111175. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111176. */
  111177. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111178. /**
  111179. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111180. * to enhance interoperability with other engines.
  111181. */
  111182. static readonly LIGHTFALLOFF_GLTF: number;
  111183. /**
  111184. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111185. * to enhance interoperability with other materials.
  111186. */
  111187. static readonly LIGHTFALLOFF_STANDARD: number;
  111188. /**
  111189. * Intensity of the direct lights e.g. the four lights available in your scene.
  111190. * This impacts both the direct diffuse and specular highlights.
  111191. */
  111192. protected _directIntensity: number;
  111193. /**
  111194. * Intensity of the emissive part of the material.
  111195. * This helps controlling the emissive effect without modifying the emissive color.
  111196. */
  111197. protected _emissiveIntensity: number;
  111198. /**
  111199. * Intensity of the environment e.g. how much the environment will light the object
  111200. * either through harmonics for rough material or through the refelction for shiny ones.
  111201. */
  111202. protected _environmentIntensity: number;
  111203. /**
  111204. * This is a special control allowing the reduction of the specular highlights coming from the
  111205. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111206. */
  111207. protected _specularIntensity: number;
  111208. /**
  111209. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111210. */
  111211. private _lightingInfos;
  111212. /**
  111213. * Debug Control allowing disabling the bump map on this material.
  111214. */
  111215. protected _disableBumpMap: boolean;
  111216. /**
  111217. * AKA Diffuse Texture in standard nomenclature.
  111218. */
  111219. protected _albedoTexture: Nullable<BaseTexture>;
  111220. /**
  111221. * AKA Occlusion Texture in other nomenclature.
  111222. */
  111223. protected _ambientTexture: Nullable<BaseTexture>;
  111224. /**
  111225. * AKA Occlusion Texture Intensity in other nomenclature.
  111226. */
  111227. protected _ambientTextureStrength: number;
  111228. /**
  111229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111230. * 1 means it completely occludes it
  111231. * 0 mean it has no impact
  111232. */
  111233. protected _ambientTextureImpactOnAnalyticalLights: number;
  111234. /**
  111235. * Stores the alpha values in a texture.
  111236. */
  111237. protected _opacityTexture: Nullable<BaseTexture>;
  111238. /**
  111239. * Stores the reflection values in a texture.
  111240. */
  111241. protected _reflectionTexture: Nullable<BaseTexture>;
  111242. /**
  111243. * Stores the emissive values in a texture.
  111244. */
  111245. protected _emissiveTexture: Nullable<BaseTexture>;
  111246. /**
  111247. * AKA Specular texture in other nomenclature.
  111248. */
  111249. protected _reflectivityTexture: Nullable<BaseTexture>;
  111250. /**
  111251. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111252. */
  111253. protected _metallicTexture: Nullable<BaseTexture>;
  111254. /**
  111255. * Specifies the metallic scalar of the metallic/roughness workflow.
  111256. * Can also be used to scale the metalness values of the metallic texture.
  111257. */
  111258. protected _metallic: Nullable<number>;
  111259. /**
  111260. * Specifies the roughness scalar of the metallic/roughness workflow.
  111261. * Can also be used to scale the roughness values of the metallic texture.
  111262. */
  111263. protected _roughness: Nullable<number>;
  111264. /**
  111265. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111266. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111267. */
  111268. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111269. /**
  111270. * Stores surface normal data used to displace a mesh in a texture.
  111271. */
  111272. protected _bumpTexture: Nullable<BaseTexture>;
  111273. /**
  111274. * Stores the pre-calculated light information of a mesh in a texture.
  111275. */
  111276. protected _lightmapTexture: Nullable<BaseTexture>;
  111277. /**
  111278. * The color of a material in ambient lighting.
  111279. */
  111280. protected _ambientColor: Color3;
  111281. /**
  111282. * AKA Diffuse Color in other nomenclature.
  111283. */
  111284. protected _albedoColor: Color3;
  111285. /**
  111286. * AKA Specular Color in other nomenclature.
  111287. */
  111288. protected _reflectivityColor: Color3;
  111289. /**
  111290. * The color applied when light is reflected from a material.
  111291. */
  111292. protected _reflectionColor: Color3;
  111293. /**
  111294. * The color applied when light is emitted from a material.
  111295. */
  111296. protected _emissiveColor: Color3;
  111297. /**
  111298. * AKA Glossiness in other nomenclature.
  111299. */
  111300. protected _microSurface: number;
  111301. /**
  111302. * Specifies that the material will use the light map as a show map.
  111303. */
  111304. protected _useLightmapAsShadowmap: boolean;
  111305. /**
  111306. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111307. * makes the reflect vector face the model (under horizon).
  111308. */
  111309. protected _useHorizonOcclusion: boolean;
  111310. /**
  111311. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111312. * too much the area relying on ambient texture to define their ambient occlusion.
  111313. */
  111314. protected _useRadianceOcclusion: boolean;
  111315. /**
  111316. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111317. */
  111318. protected _useAlphaFromAlbedoTexture: boolean;
  111319. /**
  111320. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111321. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111322. */
  111323. protected _useSpecularOverAlpha: boolean;
  111324. /**
  111325. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111326. */
  111327. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111328. /**
  111329. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111330. */
  111331. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111332. /**
  111333. * Specifies if the metallic texture contains the roughness information in its green channel.
  111334. */
  111335. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111336. /**
  111337. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111338. */
  111339. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111340. /**
  111341. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111342. */
  111343. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111344. /**
  111345. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111346. */
  111347. protected _useAmbientInGrayScale: boolean;
  111348. /**
  111349. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111350. * The material will try to infer what glossiness each pixel should be.
  111351. */
  111352. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111353. /**
  111354. * Defines the falloff type used in this material.
  111355. * It by default is Physical.
  111356. */
  111357. protected _lightFalloff: number;
  111358. /**
  111359. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111360. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111361. */
  111362. protected _useRadianceOverAlpha: boolean;
  111363. /**
  111364. * Allows using an object space normal map (instead of tangent space).
  111365. */
  111366. protected _useObjectSpaceNormalMap: boolean;
  111367. /**
  111368. * Allows using the bump map in parallax mode.
  111369. */
  111370. protected _useParallax: boolean;
  111371. /**
  111372. * Allows using the bump map in parallax occlusion mode.
  111373. */
  111374. protected _useParallaxOcclusion: boolean;
  111375. /**
  111376. * Controls the scale bias of the parallax mode.
  111377. */
  111378. protected _parallaxScaleBias: number;
  111379. /**
  111380. * If sets to true, disables all the lights affecting the material.
  111381. */
  111382. protected _disableLighting: boolean;
  111383. /**
  111384. * Number of Simultaneous lights allowed on the material.
  111385. */
  111386. protected _maxSimultaneousLights: number;
  111387. /**
  111388. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111389. */
  111390. protected _invertNormalMapX: boolean;
  111391. /**
  111392. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111393. */
  111394. protected _invertNormalMapY: boolean;
  111395. /**
  111396. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111397. */
  111398. protected _twoSidedLighting: boolean;
  111399. /**
  111400. * Defines the alpha limits in alpha test mode.
  111401. */
  111402. protected _alphaCutOff: number;
  111403. /**
  111404. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111405. */
  111406. protected _forceAlphaTest: boolean;
  111407. /**
  111408. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111409. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111410. */
  111411. protected _useAlphaFresnel: boolean;
  111412. /**
  111413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111414. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111415. */
  111416. protected _useLinearAlphaFresnel: boolean;
  111417. /**
  111418. * The transparency mode of the material.
  111419. */
  111420. protected _transparencyMode: Nullable<number>;
  111421. /**
  111422. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111423. * from cos thetav and roughness:
  111424. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111425. */
  111426. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111427. /**
  111428. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111429. */
  111430. protected _forceIrradianceInFragment: boolean;
  111431. /**
  111432. * Force normal to face away from face.
  111433. */
  111434. protected _forceNormalForward: boolean;
  111435. /**
  111436. * Enables specular anti aliasing in the PBR shader.
  111437. * It will both interacts on the Geometry for analytical and IBL lighting.
  111438. * It also prefilter the roughness map based on the bump values.
  111439. */
  111440. protected _enableSpecularAntiAliasing: boolean;
  111441. /**
  111442. * Default configuration related to image processing available in the PBR Material.
  111443. */
  111444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111445. /**
  111446. * Keep track of the image processing observer to allow dispose and replace.
  111447. */
  111448. private _imageProcessingObserver;
  111449. /**
  111450. * Attaches a new image processing configuration to the PBR Material.
  111451. * @param configuration
  111452. */
  111453. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111454. /**
  111455. * Stores the available render targets.
  111456. */
  111457. private _renderTargets;
  111458. /**
  111459. * Sets the global ambient color for the material used in lighting calculations.
  111460. */
  111461. private _globalAmbientColor;
  111462. /**
  111463. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111464. */
  111465. private _useLogarithmicDepth;
  111466. /**
  111467. * If set to true, no lighting calculations will be applied.
  111468. */
  111469. private _unlit;
  111470. private _debugMode;
  111471. /**
  111472. * @hidden
  111473. * This is reserved for the inspector.
  111474. * Defines the material debug mode.
  111475. * It helps seeing only some components of the material while troubleshooting.
  111476. */
  111477. debugMode: number;
  111478. /**
  111479. * @hidden
  111480. * This is reserved for the inspector.
  111481. * Specify from where on screen the debug mode should start.
  111482. * The value goes from -1 (full screen) to 1 (not visible)
  111483. * It helps with side by side comparison against the final render
  111484. * This defaults to -1
  111485. */
  111486. private debugLimit;
  111487. /**
  111488. * @hidden
  111489. * This is reserved for the inspector.
  111490. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111491. * You can use the factor to better multiply the final value.
  111492. */
  111493. private debugFactor;
  111494. /**
  111495. * Defines the clear coat layer parameters for the material.
  111496. */
  111497. readonly clearCoat: PBRClearCoatConfiguration;
  111498. /**
  111499. * Defines the anisotropic parameters for the material.
  111500. */
  111501. readonly anisotropy: PBRAnisotropicConfiguration;
  111502. /**
  111503. * Defines the BRDF parameters for the material.
  111504. */
  111505. readonly brdf: PBRBRDFConfiguration;
  111506. /**
  111507. * Defines the Sheen parameters for the material.
  111508. */
  111509. readonly sheen: PBRSheenConfiguration;
  111510. /**
  111511. * Defines the SubSurface parameters for the material.
  111512. */
  111513. readonly subSurface: PBRSubSurfaceConfiguration;
  111514. /**
  111515. * Custom callback helping to override the default shader used in the material.
  111516. */
  111517. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111518. /**
  111519. * Instantiates a new PBRMaterial instance.
  111520. *
  111521. * @param name The material name
  111522. * @param scene The scene the material will be use in.
  111523. */
  111524. constructor(name: string, scene: Scene);
  111525. /**
  111526. * Gets a boolean indicating that current material needs to register RTT
  111527. */
  111528. readonly hasRenderTargetTextures: boolean;
  111529. /**
  111530. * Gets the name of the material class.
  111531. */
  111532. getClassName(): string;
  111533. /**
  111534. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111535. */
  111536. /**
  111537. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111538. */
  111539. useLogarithmicDepth: boolean;
  111540. /**
  111541. * Gets the current transparency mode.
  111542. */
  111543. /**
  111544. * Sets the transparency mode of the material.
  111545. *
  111546. * | Value | Type | Description |
  111547. * | ----- | ----------------------------------- | ----------- |
  111548. * | 0 | OPAQUE | |
  111549. * | 1 | ALPHATEST | |
  111550. * | 2 | ALPHABLEND | |
  111551. * | 3 | ALPHATESTANDBLEND | |
  111552. *
  111553. */
  111554. transparencyMode: Nullable<number>;
  111555. /**
  111556. * Returns true if alpha blending should be disabled.
  111557. */
  111558. private readonly _disableAlphaBlending;
  111559. /**
  111560. * Specifies whether or not this material should be rendered in alpha blend mode.
  111561. */
  111562. needAlphaBlending(): boolean;
  111563. /**
  111564. * Specifies if the mesh will require alpha blending.
  111565. * @param mesh - BJS mesh.
  111566. */
  111567. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111568. /**
  111569. * Specifies whether or not this material should be rendered in alpha test mode.
  111570. */
  111571. needAlphaTesting(): boolean;
  111572. /**
  111573. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111574. */
  111575. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111576. /**
  111577. * Gets the texture used for the alpha test.
  111578. */
  111579. getAlphaTestTexture(): Nullable<BaseTexture>;
  111580. /**
  111581. * Specifies that the submesh is ready to be used.
  111582. * @param mesh - BJS mesh.
  111583. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111584. * @param useInstances - Specifies that instances should be used.
  111585. * @returns - boolean indicating that the submesh is ready or not.
  111586. */
  111587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111588. /**
  111589. * Specifies if the material uses metallic roughness workflow.
  111590. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111591. */
  111592. isMetallicWorkflow(): boolean;
  111593. private _prepareEffect;
  111594. private _prepareDefines;
  111595. /**
  111596. * Force shader compilation
  111597. */
  111598. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111599. clipPlane: boolean;
  111600. }>): void;
  111601. /**
  111602. * Initializes the uniform buffer layout for the shader.
  111603. */
  111604. buildUniformLayout(): void;
  111605. /**
  111606. * Unbinds the material from the mesh
  111607. */
  111608. unbind(): void;
  111609. /**
  111610. * Binds the submesh data.
  111611. * @param world - The world matrix.
  111612. * @param mesh - The BJS mesh.
  111613. * @param subMesh - A submesh of the BJS mesh.
  111614. */
  111615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111616. /**
  111617. * Returns the animatable textures.
  111618. * @returns - Array of animatable textures.
  111619. */
  111620. getAnimatables(): IAnimatable[];
  111621. /**
  111622. * Returns the texture used for reflections.
  111623. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111624. */
  111625. private _getReflectionTexture;
  111626. /**
  111627. * Returns an array of the actively used textures.
  111628. * @returns - Array of BaseTextures
  111629. */
  111630. getActiveTextures(): BaseTexture[];
  111631. /**
  111632. * Checks to see if a texture is used in the material.
  111633. * @param texture - Base texture to use.
  111634. * @returns - Boolean specifying if a texture is used in the material.
  111635. */
  111636. hasTexture(texture: BaseTexture): boolean;
  111637. /**
  111638. * Disposes the resources of the material.
  111639. * @param forceDisposeEffect - Forces the disposal of effects.
  111640. * @param forceDisposeTextures - Forces the disposal of all textures.
  111641. */
  111642. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111643. }
  111644. }
  111645. declare module BABYLON {
  111646. /**
  111647. * The Physically based material of BJS.
  111648. *
  111649. * This offers the main features of a standard PBR material.
  111650. * For more information, please refer to the documentation :
  111651. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111652. */
  111653. export class PBRMaterial extends PBRBaseMaterial {
  111654. /**
  111655. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111656. */
  111657. static readonly PBRMATERIAL_OPAQUE: number;
  111658. /**
  111659. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111660. */
  111661. static readonly PBRMATERIAL_ALPHATEST: number;
  111662. /**
  111663. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111664. */
  111665. static readonly PBRMATERIAL_ALPHABLEND: number;
  111666. /**
  111667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111668. * They are also discarded below the alpha cutoff threshold to improve performances.
  111669. */
  111670. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111671. /**
  111672. * Defines the default value of how much AO map is occluding the analytical lights
  111673. * (point spot...).
  111674. */
  111675. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111676. /**
  111677. * Intensity of the direct lights e.g. the four lights available in your scene.
  111678. * This impacts both the direct diffuse and specular highlights.
  111679. */
  111680. directIntensity: number;
  111681. /**
  111682. * Intensity of the emissive part of the material.
  111683. * This helps controlling the emissive effect without modifying the emissive color.
  111684. */
  111685. emissiveIntensity: number;
  111686. /**
  111687. * Intensity of the environment e.g. how much the environment will light the object
  111688. * either through harmonics for rough material or through the refelction for shiny ones.
  111689. */
  111690. environmentIntensity: number;
  111691. /**
  111692. * This is a special control allowing the reduction of the specular highlights coming from the
  111693. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111694. */
  111695. specularIntensity: number;
  111696. /**
  111697. * Debug Control allowing disabling the bump map on this material.
  111698. */
  111699. disableBumpMap: boolean;
  111700. /**
  111701. * AKA Diffuse Texture in standard nomenclature.
  111702. */
  111703. albedoTexture: BaseTexture;
  111704. /**
  111705. * AKA Occlusion Texture in other nomenclature.
  111706. */
  111707. ambientTexture: BaseTexture;
  111708. /**
  111709. * AKA Occlusion Texture Intensity in other nomenclature.
  111710. */
  111711. ambientTextureStrength: number;
  111712. /**
  111713. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111714. * 1 means it completely occludes it
  111715. * 0 mean it has no impact
  111716. */
  111717. ambientTextureImpactOnAnalyticalLights: number;
  111718. /**
  111719. * Stores the alpha values in a texture.
  111720. */
  111721. opacityTexture: BaseTexture;
  111722. /**
  111723. * Stores the reflection values in a texture.
  111724. */
  111725. reflectionTexture: Nullable<BaseTexture>;
  111726. /**
  111727. * Stores the emissive values in a texture.
  111728. */
  111729. emissiveTexture: BaseTexture;
  111730. /**
  111731. * AKA Specular texture in other nomenclature.
  111732. */
  111733. reflectivityTexture: BaseTexture;
  111734. /**
  111735. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111736. */
  111737. metallicTexture: BaseTexture;
  111738. /**
  111739. * Specifies the metallic scalar of the metallic/roughness workflow.
  111740. * Can also be used to scale the metalness values of the metallic texture.
  111741. */
  111742. metallic: Nullable<number>;
  111743. /**
  111744. * Specifies the roughness scalar of the metallic/roughness workflow.
  111745. * Can also be used to scale the roughness values of the metallic texture.
  111746. */
  111747. roughness: Nullable<number>;
  111748. /**
  111749. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111750. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111751. */
  111752. microSurfaceTexture: BaseTexture;
  111753. /**
  111754. * Stores surface normal data used to displace a mesh in a texture.
  111755. */
  111756. bumpTexture: BaseTexture;
  111757. /**
  111758. * Stores the pre-calculated light information of a mesh in a texture.
  111759. */
  111760. lightmapTexture: BaseTexture;
  111761. /**
  111762. * Stores the refracted light information in a texture.
  111763. */
  111764. refractionTexture: Nullable<BaseTexture>;
  111765. /**
  111766. * The color of a material in ambient lighting.
  111767. */
  111768. ambientColor: Color3;
  111769. /**
  111770. * AKA Diffuse Color in other nomenclature.
  111771. */
  111772. albedoColor: Color3;
  111773. /**
  111774. * AKA Specular Color in other nomenclature.
  111775. */
  111776. reflectivityColor: Color3;
  111777. /**
  111778. * The color reflected from the material.
  111779. */
  111780. reflectionColor: Color3;
  111781. /**
  111782. * The color emitted from the material.
  111783. */
  111784. emissiveColor: Color3;
  111785. /**
  111786. * AKA Glossiness in other nomenclature.
  111787. */
  111788. microSurface: number;
  111789. /**
  111790. * source material index of refraction (IOR)' / 'destination material IOR.
  111791. */
  111792. indexOfRefraction: number;
  111793. /**
  111794. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111795. */
  111796. invertRefractionY: boolean;
  111797. /**
  111798. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111799. * Materials half opaque for instance using refraction could benefit from this control.
  111800. */
  111801. linkRefractionWithTransparency: boolean;
  111802. /**
  111803. * If true, the light map contains occlusion information instead of lighting info.
  111804. */
  111805. useLightmapAsShadowmap: boolean;
  111806. /**
  111807. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111808. */
  111809. useAlphaFromAlbedoTexture: boolean;
  111810. /**
  111811. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111812. */
  111813. forceAlphaTest: boolean;
  111814. /**
  111815. * Defines the alpha limits in alpha test mode.
  111816. */
  111817. alphaCutOff: number;
  111818. /**
  111819. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111820. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111821. */
  111822. useSpecularOverAlpha: boolean;
  111823. /**
  111824. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111825. */
  111826. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111827. /**
  111828. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111829. */
  111830. useRoughnessFromMetallicTextureAlpha: boolean;
  111831. /**
  111832. * Specifies if the metallic texture contains the roughness information in its green channel.
  111833. */
  111834. useRoughnessFromMetallicTextureGreen: boolean;
  111835. /**
  111836. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111837. */
  111838. useMetallnessFromMetallicTextureBlue: boolean;
  111839. /**
  111840. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111841. */
  111842. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111843. /**
  111844. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111845. */
  111846. useAmbientInGrayScale: boolean;
  111847. /**
  111848. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111849. * The material will try to infer what glossiness each pixel should be.
  111850. */
  111851. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111852. /**
  111853. * BJS is using an harcoded light falloff based on a manually sets up range.
  111854. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111855. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111856. */
  111857. /**
  111858. * BJS is using an harcoded light falloff based on a manually sets up range.
  111859. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111860. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111861. */
  111862. usePhysicalLightFalloff: boolean;
  111863. /**
  111864. * In order to support the falloff compatibility with gltf, a special mode has been added
  111865. * to reproduce the gltf light falloff.
  111866. */
  111867. /**
  111868. * In order to support the falloff compatibility with gltf, a special mode has been added
  111869. * to reproduce the gltf light falloff.
  111870. */
  111871. useGLTFLightFalloff: boolean;
  111872. /**
  111873. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111874. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111875. */
  111876. useRadianceOverAlpha: boolean;
  111877. /**
  111878. * Allows using an object space normal map (instead of tangent space).
  111879. */
  111880. useObjectSpaceNormalMap: boolean;
  111881. /**
  111882. * Allows using the bump map in parallax mode.
  111883. */
  111884. useParallax: boolean;
  111885. /**
  111886. * Allows using the bump map in parallax occlusion mode.
  111887. */
  111888. useParallaxOcclusion: boolean;
  111889. /**
  111890. * Controls the scale bias of the parallax mode.
  111891. */
  111892. parallaxScaleBias: number;
  111893. /**
  111894. * If sets to true, disables all the lights affecting the material.
  111895. */
  111896. disableLighting: boolean;
  111897. /**
  111898. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111899. */
  111900. forceIrradianceInFragment: boolean;
  111901. /**
  111902. * Number of Simultaneous lights allowed on the material.
  111903. */
  111904. maxSimultaneousLights: number;
  111905. /**
  111906. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111907. */
  111908. invertNormalMapX: boolean;
  111909. /**
  111910. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111911. */
  111912. invertNormalMapY: boolean;
  111913. /**
  111914. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111915. */
  111916. twoSidedLighting: boolean;
  111917. /**
  111918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111919. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111920. */
  111921. useAlphaFresnel: boolean;
  111922. /**
  111923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111924. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111925. */
  111926. useLinearAlphaFresnel: boolean;
  111927. /**
  111928. * Let user defines the brdf lookup texture used for IBL.
  111929. * A default 8bit version is embedded but you could point at :
  111930. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111931. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111932. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111933. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111934. */
  111935. environmentBRDFTexture: Nullable<BaseTexture>;
  111936. /**
  111937. * Force normal to face away from face.
  111938. */
  111939. forceNormalForward: boolean;
  111940. /**
  111941. * Enables specular anti aliasing in the PBR shader.
  111942. * It will both interacts on the Geometry for analytical and IBL lighting.
  111943. * It also prefilter the roughness map based on the bump values.
  111944. */
  111945. enableSpecularAntiAliasing: boolean;
  111946. /**
  111947. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111948. * makes the reflect vector face the model (under horizon).
  111949. */
  111950. useHorizonOcclusion: boolean;
  111951. /**
  111952. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111953. * too much the area relying on ambient texture to define their ambient occlusion.
  111954. */
  111955. useRadianceOcclusion: boolean;
  111956. /**
  111957. * If set to true, no lighting calculations will be applied.
  111958. */
  111959. unlit: boolean;
  111960. /**
  111961. * Gets the image processing configuration used either in this material.
  111962. */
  111963. /**
  111964. * Sets the Default image processing configuration used either in the this material.
  111965. *
  111966. * If sets to null, the scene one is in use.
  111967. */
  111968. imageProcessingConfiguration: ImageProcessingConfiguration;
  111969. /**
  111970. * Gets wether the color curves effect is enabled.
  111971. */
  111972. /**
  111973. * Sets wether the color curves effect is enabled.
  111974. */
  111975. cameraColorCurvesEnabled: boolean;
  111976. /**
  111977. * Gets wether the color grading effect is enabled.
  111978. */
  111979. /**
  111980. * Gets wether the color grading effect is enabled.
  111981. */
  111982. cameraColorGradingEnabled: boolean;
  111983. /**
  111984. * Gets wether tonemapping is enabled or not.
  111985. */
  111986. /**
  111987. * Sets wether tonemapping is enabled or not
  111988. */
  111989. cameraToneMappingEnabled: boolean;
  111990. /**
  111991. * The camera exposure used on this material.
  111992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111993. * This corresponds to a photographic exposure.
  111994. */
  111995. /**
  111996. * The camera exposure used on this material.
  111997. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111998. * This corresponds to a photographic exposure.
  111999. */
  112000. cameraExposure: number;
  112001. /**
  112002. * Gets The camera contrast used on this material.
  112003. */
  112004. /**
  112005. * Sets The camera contrast used on this material.
  112006. */
  112007. cameraContrast: number;
  112008. /**
  112009. * Gets the Color Grading 2D Lookup Texture.
  112010. */
  112011. /**
  112012. * Sets the Color Grading 2D Lookup Texture.
  112013. */
  112014. cameraColorGradingTexture: Nullable<BaseTexture>;
  112015. /**
  112016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112018. * 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;
  112019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112020. */
  112021. /**
  112022. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112023. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112024. * 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;
  112025. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112026. */
  112027. cameraColorCurves: Nullable<ColorCurves>;
  112028. /**
  112029. * Instantiates a new PBRMaterial instance.
  112030. *
  112031. * @param name The material name
  112032. * @param scene The scene the material will be use in.
  112033. */
  112034. constructor(name: string, scene: Scene);
  112035. /**
  112036. * Returns the name of this material class.
  112037. */
  112038. getClassName(): string;
  112039. /**
  112040. * Makes a duplicate of the current material.
  112041. * @param name - name to use for the new material.
  112042. */
  112043. clone(name: string): PBRMaterial;
  112044. /**
  112045. * Serializes this PBR Material.
  112046. * @returns - An object with the serialized material.
  112047. */
  112048. serialize(): any;
  112049. /**
  112050. * Parses a PBR Material from a serialized object.
  112051. * @param source - Serialized object.
  112052. * @param scene - BJS scene instance.
  112053. * @param rootUrl - url for the scene object
  112054. * @returns - PBRMaterial
  112055. */
  112056. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  112057. }
  112058. }
  112059. declare module BABYLON {
  112060. /**
  112061. * Direct draw surface info
  112062. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  112063. */
  112064. export interface DDSInfo {
  112065. /**
  112066. * Width of the texture
  112067. */
  112068. width: number;
  112069. /**
  112070. * Width of the texture
  112071. */
  112072. height: number;
  112073. /**
  112074. * Number of Mipmaps for the texture
  112075. * @see https://en.wikipedia.org/wiki/Mipmap
  112076. */
  112077. mipmapCount: number;
  112078. /**
  112079. * If the textures format is a known fourCC format
  112080. * @see https://www.fourcc.org/
  112081. */
  112082. isFourCC: boolean;
  112083. /**
  112084. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  112085. */
  112086. isRGB: boolean;
  112087. /**
  112088. * If the texture is a lumincance format
  112089. */
  112090. isLuminance: boolean;
  112091. /**
  112092. * If this is a cube texture
  112093. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  112094. */
  112095. isCube: boolean;
  112096. /**
  112097. * If the texture is a compressed format eg. FOURCC_DXT1
  112098. */
  112099. isCompressed: boolean;
  112100. /**
  112101. * The dxgiFormat of the texture
  112102. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  112103. */
  112104. dxgiFormat: number;
  112105. /**
  112106. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  112107. */
  112108. textureType: number;
  112109. /**
  112110. * Sphericle polynomial created for the dds texture
  112111. */
  112112. sphericalPolynomial?: SphericalPolynomial;
  112113. }
  112114. /**
  112115. * Class used to provide DDS decompression tools
  112116. */
  112117. export class DDSTools {
  112118. /**
  112119. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  112120. */
  112121. static StoreLODInAlphaChannel: boolean;
  112122. /**
  112123. * Gets DDS information from an array buffer
  112124. * @param arrayBuffer defines the array buffer to read data from
  112125. * @returns the DDS information
  112126. */
  112127. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  112128. private static _FloatView;
  112129. private static _Int32View;
  112130. private static _ToHalfFloat;
  112131. private static _FromHalfFloat;
  112132. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  112133. private static _GetHalfFloatRGBAArrayBuffer;
  112134. private static _GetFloatRGBAArrayBuffer;
  112135. private static _GetFloatAsUIntRGBAArrayBuffer;
  112136. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  112137. private static _GetRGBAArrayBuffer;
  112138. private static _ExtractLongWordOrder;
  112139. private static _GetRGBArrayBuffer;
  112140. private static _GetLuminanceArrayBuffer;
  112141. /**
  112142. * Uploads DDS Levels to a Babylon Texture
  112143. * @hidden
  112144. */
  112145. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  112146. }
  112147. interface Engine {
  112148. /**
  112149. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  112150. * @param rootUrl defines the url where the file to load is located
  112151. * @param scene defines the current scene
  112152. * @param lodScale defines scale to apply to the mip map selection
  112153. * @param lodOffset defines offset to apply to the mip map selection
  112154. * @param onLoad defines an optional callback raised when the texture is loaded
  112155. * @param onError defines an optional callback raised if there is an issue to load the texture
  112156. * @param format defines the format of the data
  112157. * @param forcedExtension defines the extension to use to pick the right loader
  112158. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  112159. * @returns the cube texture as an InternalTexture
  112160. */
  112161. 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;
  112162. }
  112163. }
  112164. declare module BABYLON {
  112165. /**
  112166. * Implementation of the DDS Texture Loader.
  112167. * @hidden
  112168. */
  112169. export class _DDSTextureLoader implements IInternalTextureLoader {
  112170. /**
  112171. * Defines wether the loader supports cascade loading the different faces.
  112172. */
  112173. readonly supportCascades: boolean;
  112174. /**
  112175. * This returns if the loader support the current file information.
  112176. * @param extension defines the file extension of the file being loaded
  112177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112178. * @param fallback defines the fallback internal texture if any
  112179. * @param isBase64 defines whether the texture is encoded as a base64
  112180. * @param isBuffer defines whether the texture data are stored as a buffer
  112181. * @returns true if the loader can load the specified file
  112182. */
  112183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112184. /**
  112185. * Transform the url before loading if required.
  112186. * @param rootUrl the url of the texture
  112187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112188. * @returns the transformed texture
  112189. */
  112190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112191. /**
  112192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112193. * @param rootUrl the url of the texture
  112194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112195. * @returns the fallback texture
  112196. */
  112197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112198. /**
  112199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112200. * @param data contains the texture data
  112201. * @param texture defines the BabylonJS internal texture
  112202. * @param createPolynomials will be true if polynomials have been requested
  112203. * @param onLoad defines the callback to trigger once the texture is ready
  112204. * @param onError defines the callback to trigger in case of error
  112205. */
  112206. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112207. /**
  112208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112209. * @param data contains the texture data
  112210. * @param texture defines the BabylonJS internal texture
  112211. * @param callback defines the method to call once ready to upload
  112212. */
  112213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112214. }
  112215. }
  112216. declare module BABYLON {
  112217. /** @hidden */
  112218. export var rgbdEncodePixelShader: {
  112219. name: string;
  112220. shader: string;
  112221. };
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * Raw texture data and descriptor sufficient for WebGL texture upload
  112226. */
  112227. export interface EnvironmentTextureInfo {
  112228. /**
  112229. * Version of the environment map
  112230. */
  112231. version: number;
  112232. /**
  112233. * Width of image
  112234. */
  112235. width: number;
  112236. /**
  112237. * Irradiance information stored in the file.
  112238. */
  112239. irradiance: any;
  112240. /**
  112241. * Specular information stored in the file.
  112242. */
  112243. specular: any;
  112244. }
  112245. /**
  112246. * Sets of helpers addressing the serialization and deserialization of environment texture
  112247. * stored in a BabylonJS env file.
  112248. * Those files are usually stored as .env files.
  112249. */
  112250. export class EnvironmentTextureTools {
  112251. /**
  112252. * Magic number identifying the env file.
  112253. */
  112254. private static _MagicBytes;
  112255. /**
  112256. * Gets the environment info from an env file.
  112257. * @param data The array buffer containing the .env bytes.
  112258. * @returns the environment file info (the json header) if successfully parsed.
  112259. */
  112260. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112261. /**
  112262. * Creates an environment texture from a loaded cube texture.
  112263. * @param texture defines the cube texture to convert in env file
  112264. * @return a promise containing the environment data if succesfull.
  112265. */
  112266. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112267. /**
  112268. * Creates a JSON representation of the spherical data.
  112269. * @param texture defines the texture containing the polynomials
  112270. * @return the JSON representation of the spherical info
  112271. */
  112272. private static _CreateEnvTextureIrradiance;
  112273. /**
  112274. * Uploads the texture info contained in the env file to the GPU.
  112275. * @param texture defines the internal texture to upload to
  112276. * @param arrayBuffer defines the buffer cotaining the data to load
  112277. * @param info defines the texture info retrieved through the GetEnvInfo method
  112278. * @returns a promise
  112279. */
  112280. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112281. /**
  112282. * Uploads the levels of image data to the GPU.
  112283. * @param texture defines the internal texture to upload to
  112284. * @param imageData defines the array buffer views of image data [mipmap][face]
  112285. * @returns a promise
  112286. */
  112287. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112288. /**
  112289. * Uploads spherical polynomials information to the texture.
  112290. * @param texture defines the texture we are trying to upload the information to
  112291. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112292. */
  112293. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112294. /** @hidden */
  112295. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112296. }
  112297. }
  112298. declare module BABYLON {
  112299. /**
  112300. * Implementation of the ENV Texture Loader.
  112301. * @hidden
  112302. */
  112303. export class _ENVTextureLoader implements IInternalTextureLoader {
  112304. /**
  112305. * Defines wether the loader supports cascade loading the different faces.
  112306. */
  112307. readonly supportCascades: boolean;
  112308. /**
  112309. * This returns if the loader support the current file information.
  112310. * @param extension defines the file extension of the file being loaded
  112311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112312. * @param fallback defines the fallback internal texture if any
  112313. * @param isBase64 defines whether the texture is encoded as a base64
  112314. * @param isBuffer defines whether the texture data are stored as a buffer
  112315. * @returns true if the loader can load the specified file
  112316. */
  112317. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112318. /**
  112319. * Transform the url before loading if required.
  112320. * @param rootUrl the url of the texture
  112321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112322. * @returns the transformed texture
  112323. */
  112324. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112325. /**
  112326. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112327. * @param rootUrl the url of the texture
  112328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112329. * @returns the fallback texture
  112330. */
  112331. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112332. /**
  112333. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112334. * @param data contains the texture data
  112335. * @param texture defines the BabylonJS internal texture
  112336. * @param createPolynomials will be true if polynomials have been requested
  112337. * @param onLoad defines the callback to trigger once the texture is ready
  112338. * @param onError defines the callback to trigger in case of error
  112339. */
  112340. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112341. /**
  112342. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112343. * @param data contains the texture data
  112344. * @param texture defines the BabylonJS internal texture
  112345. * @param callback defines the method to call once ready to upload
  112346. */
  112347. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112348. }
  112349. }
  112350. declare module BABYLON {
  112351. /**
  112352. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112353. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112354. */
  112355. export class KhronosTextureContainer {
  112356. /** contents of the KTX container file */
  112357. arrayBuffer: any;
  112358. private static HEADER_LEN;
  112359. private static COMPRESSED_2D;
  112360. private static COMPRESSED_3D;
  112361. private static TEX_2D;
  112362. private static TEX_3D;
  112363. /**
  112364. * Gets the openGL type
  112365. */
  112366. glType: number;
  112367. /**
  112368. * Gets the openGL type size
  112369. */
  112370. glTypeSize: number;
  112371. /**
  112372. * Gets the openGL format
  112373. */
  112374. glFormat: number;
  112375. /**
  112376. * Gets the openGL internal format
  112377. */
  112378. glInternalFormat: number;
  112379. /**
  112380. * Gets the base internal format
  112381. */
  112382. glBaseInternalFormat: number;
  112383. /**
  112384. * Gets image width in pixel
  112385. */
  112386. pixelWidth: number;
  112387. /**
  112388. * Gets image height in pixel
  112389. */
  112390. pixelHeight: number;
  112391. /**
  112392. * Gets image depth in pixels
  112393. */
  112394. pixelDepth: number;
  112395. /**
  112396. * Gets the number of array elements
  112397. */
  112398. numberOfArrayElements: number;
  112399. /**
  112400. * Gets the number of faces
  112401. */
  112402. numberOfFaces: number;
  112403. /**
  112404. * Gets the number of mipmap levels
  112405. */
  112406. numberOfMipmapLevels: number;
  112407. /**
  112408. * Gets the bytes of key value data
  112409. */
  112410. bytesOfKeyValueData: number;
  112411. /**
  112412. * Gets the load type
  112413. */
  112414. loadType: number;
  112415. /**
  112416. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112417. */
  112418. isInvalid: boolean;
  112419. /**
  112420. * Creates a new KhronosTextureContainer
  112421. * @param arrayBuffer contents of the KTX container file
  112422. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112423. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112424. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112425. */
  112426. constructor(
  112427. /** contents of the KTX container file */
  112428. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112429. /**
  112430. * Uploads KTX content to a Babylon Texture.
  112431. * It is assumed that the texture has already been created & is currently bound
  112432. * @hidden
  112433. */
  112434. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112435. private _upload2DCompressedLevels;
  112436. }
  112437. }
  112438. declare module BABYLON {
  112439. /**
  112440. * Implementation of the KTX Texture Loader.
  112441. * @hidden
  112442. */
  112443. export class _KTXTextureLoader implements IInternalTextureLoader {
  112444. /**
  112445. * Defines wether the loader supports cascade loading the different faces.
  112446. */
  112447. readonly supportCascades: boolean;
  112448. /**
  112449. * This returns if the loader support the current file information.
  112450. * @param extension defines the file extension of the file being loaded
  112451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112452. * @param fallback defines the fallback internal texture if any
  112453. * @param isBase64 defines whether the texture is encoded as a base64
  112454. * @param isBuffer defines whether the texture data are stored as a buffer
  112455. * @returns true if the loader can load the specified file
  112456. */
  112457. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112458. /**
  112459. * Transform the url before loading if required.
  112460. * @param rootUrl the url of the texture
  112461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112462. * @returns the transformed texture
  112463. */
  112464. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112465. /**
  112466. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112467. * @param rootUrl the url of the texture
  112468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112469. * @returns the fallback texture
  112470. */
  112471. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112472. /**
  112473. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112474. * @param data contains the texture data
  112475. * @param texture defines the BabylonJS internal texture
  112476. * @param createPolynomials will be true if polynomials have been requested
  112477. * @param onLoad defines the callback to trigger once the texture is ready
  112478. * @param onError defines the callback to trigger in case of error
  112479. */
  112480. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112481. /**
  112482. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112483. * @param data contains the texture data
  112484. * @param texture defines the BabylonJS internal texture
  112485. * @param callback defines the method to call once ready to upload
  112486. */
  112487. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112488. }
  112489. }
  112490. declare module BABYLON {
  112491. /**
  112492. * Options for the default xr helper
  112493. */
  112494. export class WebXRDefaultExperienceOptions {
  112495. /**
  112496. * Floor meshes that should be used for teleporting
  112497. */
  112498. floorMeshes: Array<AbstractMesh>;
  112499. }
  112500. /**
  112501. * Default experience which provides a similar setup to the previous webVRExperience
  112502. */
  112503. export class WebXRDefaultExperience {
  112504. /**
  112505. * Base experience
  112506. */
  112507. baseExperience: WebXRExperienceHelper;
  112508. /**
  112509. * Input experience extension
  112510. */
  112511. input: WebXRInput;
  112512. /**
  112513. * Loads the controller models
  112514. */
  112515. controllerModelLoader: WebXRControllerModelLoader;
  112516. /**
  112517. * Enables laser pointer and selection
  112518. */
  112519. pointerSelection: WebXRControllerPointerSelection;
  112520. /**
  112521. * Enables teleportation
  112522. */
  112523. teleportation: WebXRControllerTeleportation;
  112524. /**
  112525. * Enables ui for enetering/exiting xr
  112526. */
  112527. enterExitUI: WebXREnterExitUI;
  112528. /**
  112529. * Default output canvas xr should render to
  112530. */
  112531. outputCanvas: WebXRManagedOutputCanvas;
  112532. /**
  112533. * Creates the default xr experience
  112534. * @param scene scene
  112535. * @param options options for basic configuration
  112536. * @returns resulting WebXRDefaultExperience
  112537. */
  112538. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112539. private constructor();
  112540. /**
  112541. * DIsposes of the experience helper
  112542. */
  112543. dispose(): void;
  112544. }
  112545. }
  112546. declare module BABYLON {
  112547. /** @hidden */
  112548. export var _forceSceneHelpersToBundle: boolean;
  112549. interface Scene {
  112550. /**
  112551. * Creates a default light for the scene.
  112552. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112553. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112554. */
  112555. createDefaultLight(replace?: boolean): void;
  112556. /**
  112557. * Creates a default camera for the scene.
  112558. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112559. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112560. * @param replace has default false, when true replaces the active camera in the scene
  112561. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112562. */
  112563. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112564. /**
  112565. * Creates a default camera and a default light.
  112566. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112567. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112568. * @param replace has the default false, when true replaces the active camera/light in the scene
  112569. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112570. */
  112571. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112572. /**
  112573. * Creates a new sky box
  112574. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112575. * @param environmentTexture defines the texture to use as environment texture
  112576. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112577. * @param scale defines the overall scale of the skybox
  112578. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112579. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112580. * @returns a new mesh holding the sky box
  112581. */
  112582. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112583. /**
  112584. * Creates a new environment
  112585. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112586. * @param options defines the options you can use to configure the environment
  112587. * @returns the new EnvironmentHelper
  112588. */
  112589. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112590. /**
  112591. * Creates a new VREXperienceHelper
  112592. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112593. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112594. * @returns a new VREXperienceHelper
  112595. */
  112596. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112597. /**
  112598. * Creates a new WebXRDefaultExperience
  112599. * @see http://doc.babylonjs.com/how_to/webxr
  112600. * @param options experience options
  112601. * @returns a promise for a new WebXRDefaultExperience
  112602. */
  112603. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112604. }
  112605. }
  112606. declare module BABYLON {
  112607. /**
  112608. * Contains position and normal vectors for a vertex
  112609. */
  112610. export class PositionNormalVertex {
  112611. /** the position of the vertex (defaut: 0,0,0) */
  112612. position: Vector3;
  112613. /** the normal of the vertex (defaut: 0,1,0) */
  112614. normal: Vector3;
  112615. /**
  112616. * Creates a PositionNormalVertex
  112617. * @param position the position of the vertex (defaut: 0,0,0)
  112618. * @param normal the normal of the vertex (defaut: 0,1,0)
  112619. */
  112620. constructor(
  112621. /** the position of the vertex (defaut: 0,0,0) */
  112622. position?: Vector3,
  112623. /** the normal of the vertex (defaut: 0,1,0) */
  112624. normal?: Vector3);
  112625. /**
  112626. * Clones the PositionNormalVertex
  112627. * @returns the cloned PositionNormalVertex
  112628. */
  112629. clone(): PositionNormalVertex;
  112630. }
  112631. /**
  112632. * Contains position, normal and uv vectors for a vertex
  112633. */
  112634. export class PositionNormalTextureVertex {
  112635. /** the position of the vertex (defaut: 0,0,0) */
  112636. position: Vector3;
  112637. /** the normal of the vertex (defaut: 0,1,0) */
  112638. normal: Vector3;
  112639. /** the uv of the vertex (default: 0,0) */
  112640. uv: Vector2;
  112641. /**
  112642. * Creates a PositionNormalTextureVertex
  112643. * @param position the position of the vertex (defaut: 0,0,0)
  112644. * @param normal the normal of the vertex (defaut: 0,1,0)
  112645. * @param uv the uv of the vertex (default: 0,0)
  112646. */
  112647. constructor(
  112648. /** the position of the vertex (defaut: 0,0,0) */
  112649. position?: Vector3,
  112650. /** the normal of the vertex (defaut: 0,1,0) */
  112651. normal?: Vector3,
  112652. /** the uv of the vertex (default: 0,0) */
  112653. uv?: Vector2);
  112654. /**
  112655. * Clones the PositionNormalTextureVertex
  112656. * @returns the cloned PositionNormalTextureVertex
  112657. */
  112658. clone(): PositionNormalTextureVertex;
  112659. }
  112660. }
  112661. declare module BABYLON {
  112662. /**
  112663. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112664. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112665. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112666. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112667. */
  112668. export class VideoDome extends TransformNode {
  112669. /**
  112670. * Define the video source as a Monoscopic panoramic 360 video.
  112671. */
  112672. static readonly MODE_MONOSCOPIC: number;
  112673. /**
  112674. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112675. */
  112676. static readonly MODE_TOPBOTTOM: number;
  112677. /**
  112678. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112679. */
  112680. static readonly MODE_SIDEBYSIDE: number;
  112681. private _halfDome;
  112682. private _useDirectMapping;
  112683. /**
  112684. * The video texture being displayed on the sphere
  112685. */
  112686. protected _videoTexture: VideoTexture;
  112687. /**
  112688. * Gets the video texture being displayed on the sphere
  112689. */
  112690. readonly videoTexture: VideoTexture;
  112691. /**
  112692. * The skybox material
  112693. */
  112694. protected _material: BackgroundMaterial;
  112695. /**
  112696. * The surface used for the skybox
  112697. */
  112698. protected _mesh: Mesh;
  112699. /**
  112700. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  112701. */
  112702. private _halfDomeMask;
  112703. /**
  112704. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112705. * Also see the options.resolution property.
  112706. */
  112707. fovMultiplier: number;
  112708. private _videoMode;
  112709. /**
  112710. * Gets or set the current video mode for the video. It can be:
  112711. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112712. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112713. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112714. */
  112715. videoMode: number;
  112716. /**
  112717. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  112718. *
  112719. */
  112720. /**
  112721. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  112722. */
  112723. halfDome: boolean;
  112724. /**
  112725. * Oberserver used in Stereoscopic VR Mode.
  112726. */
  112727. private _onBeforeCameraRenderObserver;
  112728. /**
  112729. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112730. * @param name Element's name, child elements will append suffixes for their own names.
  112731. * @param urlsOrVideo defines the url(s) or the video element to use
  112732. * @param options An object containing optional or exposed sub element properties
  112733. */
  112734. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112735. resolution?: number;
  112736. clickToPlay?: boolean;
  112737. autoPlay?: boolean;
  112738. loop?: boolean;
  112739. size?: number;
  112740. poster?: string;
  112741. faceForward?: boolean;
  112742. useDirectMapping?: boolean;
  112743. halfDomeMode?: boolean;
  112744. }, scene: Scene);
  112745. private _changeVideoMode;
  112746. /**
  112747. * Releases resources associated with this node.
  112748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112750. */
  112751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112752. }
  112753. }
  112754. declare module BABYLON {
  112755. /**
  112756. * This class can be used to get instrumentation data from a Babylon engine
  112757. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112758. */
  112759. export class EngineInstrumentation implements IDisposable {
  112760. /**
  112761. * Define the instrumented engine.
  112762. */
  112763. engine: Engine;
  112764. private _captureGPUFrameTime;
  112765. private _gpuFrameTimeToken;
  112766. private _gpuFrameTime;
  112767. private _captureShaderCompilationTime;
  112768. private _shaderCompilationTime;
  112769. private _onBeginFrameObserver;
  112770. private _onEndFrameObserver;
  112771. private _onBeforeShaderCompilationObserver;
  112772. private _onAfterShaderCompilationObserver;
  112773. /**
  112774. * Gets the perf counter used for GPU frame time
  112775. */
  112776. readonly gpuFrameTimeCounter: PerfCounter;
  112777. /**
  112778. * Gets the GPU frame time capture status
  112779. */
  112780. /**
  112781. * Enable or disable the GPU frame time capture
  112782. */
  112783. captureGPUFrameTime: boolean;
  112784. /**
  112785. * Gets the perf counter used for shader compilation time
  112786. */
  112787. readonly shaderCompilationTimeCounter: PerfCounter;
  112788. /**
  112789. * Gets the shader compilation time capture status
  112790. */
  112791. /**
  112792. * Enable or disable the shader compilation time capture
  112793. */
  112794. captureShaderCompilationTime: boolean;
  112795. /**
  112796. * Instantiates a new engine instrumentation.
  112797. * This class can be used to get instrumentation data from a Babylon engine
  112798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112799. * @param engine Defines the engine to instrument
  112800. */
  112801. constructor(
  112802. /**
  112803. * Define the instrumented engine.
  112804. */
  112805. engine: Engine);
  112806. /**
  112807. * Dispose and release associated resources.
  112808. */
  112809. dispose(): void;
  112810. }
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * This class can be used to get instrumentation data from a Babylon engine
  112815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112816. */
  112817. export class SceneInstrumentation implements IDisposable {
  112818. /**
  112819. * Defines the scene to instrument
  112820. */
  112821. scene: Scene;
  112822. private _captureActiveMeshesEvaluationTime;
  112823. private _activeMeshesEvaluationTime;
  112824. private _captureRenderTargetsRenderTime;
  112825. private _renderTargetsRenderTime;
  112826. private _captureFrameTime;
  112827. private _frameTime;
  112828. private _captureRenderTime;
  112829. private _renderTime;
  112830. private _captureInterFrameTime;
  112831. private _interFrameTime;
  112832. private _captureParticlesRenderTime;
  112833. private _particlesRenderTime;
  112834. private _captureSpritesRenderTime;
  112835. private _spritesRenderTime;
  112836. private _capturePhysicsTime;
  112837. private _physicsTime;
  112838. private _captureAnimationsTime;
  112839. private _animationsTime;
  112840. private _captureCameraRenderTime;
  112841. private _cameraRenderTime;
  112842. private _onBeforeActiveMeshesEvaluationObserver;
  112843. private _onAfterActiveMeshesEvaluationObserver;
  112844. private _onBeforeRenderTargetsRenderObserver;
  112845. private _onAfterRenderTargetsRenderObserver;
  112846. private _onAfterRenderObserver;
  112847. private _onBeforeDrawPhaseObserver;
  112848. private _onAfterDrawPhaseObserver;
  112849. private _onBeforeAnimationsObserver;
  112850. private _onBeforeParticlesRenderingObserver;
  112851. private _onAfterParticlesRenderingObserver;
  112852. private _onBeforeSpritesRenderingObserver;
  112853. private _onAfterSpritesRenderingObserver;
  112854. private _onBeforePhysicsObserver;
  112855. private _onAfterPhysicsObserver;
  112856. private _onAfterAnimationsObserver;
  112857. private _onBeforeCameraRenderObserver;
  112858. private _onAfterCameraRenderObserver;
  112859. /**
  112860. * Gets the perf counter used for active meshes evaluation time
  112861. */
  112862. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112863. /**
  112864. * Gets the active meshes evaluation time capture status
  112865. */
  112866. /**
  112867. * Enable or disable the active meshes evaluation time capture
  112868. */
  112869. captureActiveMeshesEvaluationTime: boolean;
  112870. /**
  112871. * Gets the perf counter used for render targets render time
  112872. */
  112873. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112874. /**
  112875. * Gets the render targets render time capture status
  112876. */
  112877. /**
  112878. * Enable or disable the render targets render time capture
  112879. */
  112880. captureRenderTargetsRenderTime: boolean;
  112881. /**
  112882. * Gets the perf counter used for particles render time
  112883. */
  112884. readonly particlesRenderTimeCounter: PerfCounter;
  112885. /**
  112886. * Gets the particles render time capture status
  112887. */
  112888. /**
  112889. * Enable or disable the particles render time capture
  112890. */
  112891. captureParticlesRenderTime: boolean;
  112892. /**
  112893. * Gets the perf counter used for sprites render time
  112894. */
  112895. readonly spritesRenderTimeCounter: PerfCounter;
  112896. /**
  112897. * Gets the sprites render time capture status
  112898. */
  112899. /**
  112900. * Enable or disable the sprites render time capture
  112901. */
  112902. captureSpritesRenderTime: boolean;
  112903. /**
  112904. * Gets the perf counter used for physics time
  112905. */
  112906. readonly physicsTimeCounter: PerfCounter;
  112907. /**
  112908. * Gets the physics time capture status
  112909. */
  112910. /**
  112911. * Enable or disable the physics time capture
  112912. */
  112913. capturePhysicsTime: boolean;
  112914. /**
  112915. * Gets the perf counter used for animations time
  112916. */
  112917. readonly animationsTimeCounter: PerfCounter;
  112918. /**
  112919. * Gets the animations time capture status
  112920. */
  112921. /**
  112922. * Enable or disable the animations time capture
  112923. */
  112924. captureAnimationsTime: boolean;
  112925. /**
  112926. * Gets the perf counter used for frame time capture
  112927. */
  112928. readonly frameTimeCounter: PerfCounter;
  112929. /**
  112930. * Gets the frame time capture status
  112931. */
  112932. /**
  112933. * Enable or disable the frame time capture
  112934. */
  112935. captureFrameTime: boolean;
  112936. /**
  112937. * Gets the perf counter used for inter-frames time capture
  112938. */
  112939. readonly interFrameTimeCounter: PerfCounter;
  112940. /**
  112941. * Gets the inter-frames time capture status
  112942. */
  112943. /**
  112944. * Enable or disable the inter-frames time capture
  112945. */
  112946. captureInterFrameTime: boolean;
  112947. /**
  112948. * Gets the perf counter used for render time capture
  112949. */
  112950. readonly renderTimeCounter: PerfCounter;
  112951. /**
  112952. * Gets the render time capture status
  112953. */
  112954. /**
  112955. * Enable or disable the render time capture
  112956. */
  112957. captureRenderTime: boolean;
  112958. /**
  112959. * Gets the perf counter used for camera render time capture
  112960. */
  112961. readonly cameraRenderTimeCounter: PerfCounter;
  112962. /**
  112963. * Gets the camera render time capture status
  112964. */
  112965. /**
  112966. * Enable or disable the camera render time capture
  112967. */
  112968. captureCameraRenderTime: boolean;
  112969. /**
  112970. * Gets the perf counter used for draw calls
  112971. */
  112972. readonly drawCallsCounter: PerfCounter;
  112973. /**
  112974. * Instantiates a new scene instrumentation.
  112975. * This class can be used to get instrumentation data from a Babylon engine
  112976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112977. * @param scene Defines the scene to instrument
  112978. */
  112979. constructor(
  112980. /**
  112981. * Defines the scene to instrument
  112982. */
  112983. scene: Scene);
  112984. /**
  112985. * Dispose and release associated resources.
  112986. */
  112987. dispose(): void;
  112988. }
  112989. }
  112990. declare module BABYLON {
  112991. /** @hidden */
  112992. export var glowMapGenerationPixelShader: {
  112993. name: string;
  112994. shader: string;
  112995. };
  112996. }
  112997. declare module BABYLON {
  112998. /** @hidden */
  112999. export var glowMapGenerationVertexShader: {
  113000. name: string;
  113001. shader: string;
  113002. };
  113003. }
  113004. declare module BABYLON {
  113005. /**
  113006. * Effect layer options. This helps customizing the behaviour
  113007. * of the effect layer.
  113008. */
  113009. export interface IEffectLayerOptions {
  113010. /**
  113011. * Multiplication factor apply to the canvas size to compute the render target size
  113012. * used to generated the objects (the smaller the faster).
  113013. */
  113014. mainTextureRatio: number;
  113015. /**
  113016. * Enforces a fixed size texture to ensure effect stability across devices.
  113017. */
  113018. mainTextureFixedSize?: number;
  113019. /**
  113020. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  113021. */
  113022. alphaBlendingMode: number;
  113023. /**
  113024. * The camera attached to the layer.
  113025. */
  113026. camera: Nullable<Camera>;
  113027. /**
  113028. * The rendering group to draw the layer in.
  113029. */
  113030. renderingGroupId: number;
  113031. }
  113032. /**
  113033. * The effect layer Helps adding post process effect blended with the main pass.
  113034. *
  113035. * This can be for instance use to generate glow or higlight effects on the scene.
  113036. *
  113037. * The effect layer class can not be used directly and is intented to inherited from to be
  113038. * customized per effects.
  113039. */
  113040. export abstract class EffectLayer {
  113041. private _vertexBuffers;
  113042. private _indexBuffer;
  113043. private _cachedDefines;
  113044. private _effectLayerMapGenerationEffect;
  113045. private _effectLayerOptions;
  113046. private _mergeEffect;
  113047. protected _scene: Scene;
  113048. protected _engine: Engine;
  113049. protected _maxSize: number;
  113050. protected _mainTextureDesiredSize: ISize;
  113051. protected _mainTexture: RenderTargetTexture;
  113052. protected _shouldRender: boolean;
  113053. protected _postProcesses: PostProcess[];
  113054. protected _textures: BaseTexture[];
  113055. protected _emissiveTextureAndColor: {
  113056. texture: Nullable<BaseTexture>;
  113057. color: Color4;
  113058. };
  113059. /**
  113060. * The name of the layer
  113061. */
  113062. name: string;
  113063. /**
  113064. * The clear color of the texture used to generate the glow map.
  113065. */
  113066. neutralColor: Color4;
  113067. /**
  113068. * Specifies wether the highlight layer is enabled or not.
  113069. */
  113070. isEnabled: boolean;
  113071. /**
  113072. * Gets the camera attached to the layer.
  113073. */
  113074. readonly camera: Nullable<Camera>;
  113075. /**
  113076. * Gets the rendering group id the layer should render in.
  113077. */
  113078. renderingGroupId: number;
  113079. /**
  113080. * An event triggered when the effect layer has been disposed.
  113081. */
  113082. onDisposeObservable: Observable<EffectLayer>;
  113083. /**
  113084. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  113085. */
  113086. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  113087. /**
  113088. * An event triggered when the generated texture is being merged in the scene.
  113089. */
  113090. onBeforeComposeObservable: Observable<EffectLayer>;
  113091. /**
  113092. * An event triggered when the generated texture has been merged in the scene.
  113093. */
  113094. onAfterComposeObservable: Observable<EffectLayer>;
  113095. /**
  113096. * An event triggered when the efffect layer changes its size.
  113097. */
  113098. onSizeChangedObservable: Observable<EffectLayer>;
  113099. /** @hidden */
  113100. static _SceneComponentInitialization: (scene: Scene) => void;
  113101. /**
  113102. * Instantiates a new effect Layer and references it in the scene.
  113103. * @param name The name of the layer
  113104. * @param scene The scene to use the layer in
  113105. */
  113106. constructor(
  113107. /** The Friendly of the effect in the scene */
  113108. name: string, scene: Scene);
  113109. /**
  113110. * Get the effect name of the layer.
  113111. * @return The effect name
  113112. */
  113113. abstract getEffectName(): string;
  113114. /**
  113115. * Checks for the readiness of the element composing the layer.
  113116. * @param subMesh the mesh to check for
  113117. * @param useInstances specify wether or not to use instances to render the mesh
  113118. * @return true if ready otherwise, false
  113119. */
  113120. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113121. /**
  113122. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113123. * @returns true if the effect requires stencil during the main canvas render pass.
  113124. */
  113125. abstract needStencil(): boolean;
  113126. /**
  113127. * Create the merge effect. This is the shader use to blit the information back
  113128. * to the main canvas at the end of the scene rendering.
  113129. * @returns The effect containing the shader used to merge the effect on the main canvas
  113130. */
  113131. protected abstract _createMergeEffect(): Effect;
  113132. /**
  113133. * Creates the render target textures and post processes used in the effect layer.
  113134. */
  113135. protected abstract _createTextureAndPostProcesses(): void;
  113136. /**
  113137. * Implementation specific of rendering the generating effect on the main canvas.
  113138. * @param effect The effect used to render through
  113139. */
  113140. protected abstract _internalRender(effect: Effect): void;
  113141. /**
  113142. * Sets the required values for both the emissive texture and and the main color.
  113143. */
  113144. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113145. /**
  113146. * Free any resources and references associated to a mesh.
  113147. * Internal use
  113148. * @param mesh The mesh to free.
  113149. */
  113150. abstract _disposeMesh(mesh: Mesh): void;
  113151. /**
  113152. * Serializes this layer (Glow or Highlight for example)
  113153. * @returns a serialized layer object
  113154. */
  113155. abstract serialize?(): any;
  113156. /**
  113157. * Initializes the effect layer with the required options.
  113158. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  113159. */
  113160. protected _init(options: Partial<IEffectLayerOptions>): void;
  113161. /**
  113162. * Generates the index buffer of the full screen quad blending to the main canvas.
  113163. */
  113164. private _generateIndexBuffer;
  113165. /**
  113166. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113167. */
  113168. private _generateVertexBuffer;
  113169. /**
  113170. * Sets the main texture desired size which is the closest power of two
  113171. * of the engine canvas size.
  113172. */
  113173. private _setMainTextureSize;
  113174. /**
  113175. * Creates the main texture for the effect layer.
  113176. */
  113177. protected _createMainTexture(): void;
  113178. /**
  113179. * Adds specific effects defines.
  113180. * @param defines The defines to add specifics to.
  113181. */
  113182. protected _addCustomEffectDefines(defines: string[]): void;
  113183. /**
  113184. * Checks for the readiness of the element composing the layer.
  113185. * @param subMesh the mesh to check for
  113186. * @param useInstances specify wether or not to use instances to render the mesh
  113187. * @param emissiveTexture the associated emissive texture used to generate the glow
  113188. * @return true if ready otherwise, false
  113189. */
  113190. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113191. /**
  113192. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113193. */
  113194. render(): void;
  113195. /**
  113196. * Determine if a given mesh will be used in the current effect.
  113197. * @param mesh mesh to test
  113198. * @returns true if the mesh will be used
  113199. */
  113200. hasMesh(mesh: AbstractMesh): boolean;
  113201. /**
  113202. * Returns true if the layer contains information to display, otherwise false.
  113203. * @returns true if the glow layer should be rendered
  113204. */
  113205. shouldRender(): boolean;
  113206. /**
  113207. * Returns true if the mesh should render, otherwise false.
  113208. * @param mesh The mesh to render
  113209. * @returns true if it should render otherwise false
  113210. */
  113211. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113212. /**
  113213. * Returns true if the mesh can be rendered, otherwise false.
  113214. * @param mesh The mesh to render
  113215. * @param material The material used on the mesh
  113216. * @returns true if it can be rendered otherwise false
  113217. */
  113218. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113219. /**
  113220. * Returns true if the mesh should render, otherwise false.
  113221. * @param mesh The mesh to render
  113222. * @returns true if it should render otherwise false
  113223. */
  113224. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113225. /**
  113226. * Renders the submesh passed in parameter to the generation map.
  113227. */
  113228. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113229. /**
  113230. * Rebuild the required buffers.
  113231. * @hidden Internal use only.
  113232. */
  113233. _rebuild(): void;
  113234. /**
  113235. * Dispose only the render target textures and post process.
  113236. */
  113237. private _disposeTextureAndPostProcesses;
  113238. /**
  113239. * Dispose the highlight layer and free resources.
  113240. */
  113241. dispose(): void;
  113242. /**
  113243. * Gets the class name of the effect layer
  113244. * @returns the string with the class name of the effect layer
  113245. */
  113246. getClassName(): string;
  113247. /**
  113248. * Creates an effect layer from parsed effect layer data
  113249. * @param parsedEffectLayer defines effect layer data
  113250. * @param scene defines the current scene
  113251. * @param rootUrl defines the root URL containing the effect layer information
  113252. * @returns a parsed effect Layer
  113253. */
  113254. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113255. }
  113256. }
  113257. declare module BABYLON {
  113258. interface AbstractScene {
  113259. /**
  113260. * The list of effect layers (highlights/glow) added to the scene
  113261. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113262. * @see http://doc.babylonjs.com/how_to/glow_layer
  113263. */
  113264. effectLayers: Array<EffectLayer>;
  113265. /**
  113266. * Removes the given effect layer from this scene.
  113267. * @param toRemove defines the effect layer to remove
  113268. * @returns the index of the removed effect layer
  113269. */
  113270. removeEffectLayer(toRemove: EffectLayer): number;
  113271. /**
  113272. * Adds the given effect layer to this scene
  113273. * @param newEffectLayer defines the effect layer to add
  113274. */
  113275. addEffectLayer(newEffectLayer: EffectLayer): void;
  113276. }
  113277. /**
  113278. * Defines the layer scene component responsible to manage any effect layers
  113279. * in a given scene.
  113280. */
  113281. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113282. /**
  113283. * The component name helpfull to identify the component in the list of scene components.
  113284. */
  113285. readonly name: string;
  113286. /**
  113287. * The scene the component belongs to.
  113288. */
  113289. scene: Scene;
  113290. private _engine;
  113291. private _renderEffects;
  113292. private _needStencil;
  113293. private _previousStencilState;
  113294. /**
  113295. * Creates a new instance of the component for the given scene
  113296. * @param scene Defines the scene to register the component in
  113297. */
  113298. constructor(scene: Scene);
  113299. /**
  113300. * Registers the component in a given scene
  113301. */
  113302. register(): void;
  113303. /**
  113304. * Rebuilds the elements related to this component in case of
  113305. * context lost for instance.
  113306. */
  113307. rebuild(): void;
  113308. /**
  113309. * Serializes the component data to the specified json object
  113310. * @param serializationObject The object to serialize to
  113311. */
  113312. serialize(serializationObject: any): void;
  113313. /**
  113314. * Adds all the elements from the container to the scene
  113315. * @param container the container holding the elements
  113316. */
  113317. addFromContainer(container: AbstractScene): void;
  113318. /**
  113319. * Removes all the elements in the container from the scene
  113320. * @param container contains the elements to remove
  113321. * @param dispose if the removed element should be disposed (default: false)
  113322. */
  113323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113324. /**
  113325. * Disposes the component and the associated ressources.
  113326. */
  113327. dispose(): void;
  113328. private _isReadyForMesh;
  113329. private _renderMainTexture;
  113330. private _setStencil;
  113331. private _setStencilBack;
  113332. private _draw;
  113333. private _drawCamera;
  113334. private _drawRenderingGroup;
  113335. }
  113336. }
  113337. declare module BABYLON {
  113338. /** @hidden */
  113339. export var glowMapMergePixelShader: {
  113340. name: string;
  113341. shader: string;
  113342. };
  113343. }
  113344. declare module BABYLON {
  113345. /** @hidden */
  113346. export var glowMapMergeVertexShader: {
  113347. name: string;
  113348. shader: string;
  113349. };
  113350. }
  113351. declare module BABYLON {
  113352. interface AbstractScene {
  113353. /**
  113354. * Return a the first highlight layer of the scene with a given name.
  113355. * @param name The name of the highlight layer to look for.
  113356. * @return The highlight layer if found otherwise null.
  113357. */
  113358. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113359. }
  113360. /**
  113361. * Glow layer options. This helps customizing the behaviour
  113362. * of the glow layer.
  113363. */
  113364. export interface IGlowLayerOptions {
  113365. /**
  113366. * Multiplication factor apply to the canvas size to compute the render target size
  113367. * used to generated the glowing objects (the smaller the faster).
  113368. */
  113369. mainTextureRatio: number;
  113370. /**
  113371. * Enforces a fixed size texture to ensure resize independant blur.
  113372. */
  113373. mainTextureFixedSize?: number;
  113374. /**
  113375. * How big is the kernel of the blur texture.
  113376. */
  113377. blurKernelSize: number;
  113378. /**
  113379. * The camera attached to the layer.
  113380. */
  113381. camera: Nullable<Camera>;
  113382. /**
  113383. * Enable MSAA by chosing the number of samples.
  113384. */
  113385. mainTextureSamples?: number;
  113386. /**
  113387. * The rendering group to draw the layer in.
  113388. */
  113389. renderingGroupId: number;
  113390. }
  113391. /**
  113392. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113393. *
  113394. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113395. * glowy meshes to your scene.
  113396. *
  113397. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113398. */
  113399. export class GlowLayer extends EffectLayer {
  113400. /**
  113401. * Effect Name of the layer.
  113402. */
  113403. static readonly EffectName: string;
  113404. /**
  113405. * The default blur kernel size used for the glow.
  113406. */
  113407. static DefaultBlurKernelSize: number;
  113408. /**
  113409. * The default texture size ratio used for the glow.
  113410. */
  113411. static DefaultTextureRatio: number;
  113412. /**
  113413. * Sets the kernel size of the blur.
  113414. */
  113415. /**
  113416. * Gets the kernel size of the blur.
  113417. */
  113418. blurKernelSize: number;
  113419. /**
  113420. * Sets the glow intensity.
  113421. */
  113422. /**
  113423. * Gets the glow intensity.
  113424. */
  113425. intensity: number;
  113426. private _options;
  113427. private _intensity;
  113428. private _horizontalBlurPostprocess1;
  113429. private _verticalBlurPostprocess1;
  113430. private _horizontalBlurPostprocess2;
  113431. private _verticalBlurPostprocess2;
  113432. private _blurTexture1;
  113433. private _blurTexture2;
  113434. private _postProcesses1;
  113435. private _postProcesses2;
  113436. private _includedOnlyMeshes;
  113437. private _excludedMeshes;
  113438. /**
  113439. * Callback used to let the user override the color selection on a per mesh basis
  113440. */
  113441. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113442. /**
  113443. * Callback used to let the user override the texture selection on a per mesh basis
  113444. */
  113445. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113446. /**
  113447. * Instantiates a new glow Layer and references it to the scene.
  113448. * @param name The name of the layer
  113449. * @param scene The scene to use the layer in
  113450. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113451. */
  113452. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113453. /**
  113454. * Get the effect name of the layer.
  113455. * @return The effect name
  113456. */
  113457. getEffectName(): string;
  113458. /**
  113459. * Create the merge effect. This is the shader use to blit the information back
  113460. * to the main canvas at the end of the scene rendering.
  113461. */
  113462. protected _createMergeEffect(): Effect;
  113463. /**
  113464. * Creates the render target textures and post processes used in the glow layer.
  113465. */
  113466. protected _createTextureAndPostProcesses(): void;
  113467. /**
  113468. * Checks for the readiness of the element composing the layer.
  113469. * @param subMesh the mesh to check for
  113470. * @param useInstances specify wether or not to use instances to render the mesh
  113471. * @param emissiveTexture the associated emissive texture used to generate the glow
  113472. * @return true if ready otherwise, false
  113473. */
  113474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113475. /**
  113476. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113477. */
  113478. needStencil(): boolean;
  113479. /**
  113480. * Returns true if the mesh can be rendered, otherwise false.
  113481. * @param mesh The mesh to render
  113482. * @param material The material used on the mesh
  113483. * @returns true if it can be rendered otherwise false
  113484. */
  113485. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113486. /**
  113487. * Implementation specific of rendering the generating effect on the main canvas.
  113488. * @param effect The effect used to render through
  113489. */
  113490. protected _internalRender(effect: Effect): void;
  113491. /**
  113492. * Sets the required values for both the emissive texture and and the main color.
  113493. */
  113494. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113495. /**
  113496. * Returns true if the mesh should render, otherwise false.
  113497. * @param mesh The mesh to render
  113498. * @returns true if it should render otherwise false
  113499. */
  113500. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113501. /**
  113502. * Adds specific effects defines.
  113503. * @param defines The defines to add specifics to.
  113504. */
  113505. protected _addCustomEffectDefines(defines: string[]): void;
  113506. /**
  113507. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113508. * @param mesh The mesh to exclude from the glow layer
  113509. */
  113510. addExcludedMesh(mesh: Mesh): void;
  113511. /**
  113512. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113513. * @param mesh The mesh to remove
  113514. */
  113515. removeExcludedMesh(mesh: Mesh): void;
  113516. /**
  113517. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113518. * @param mesh The mesh to include in the glow layer
  113519. */
  113520. addIncludedOnlyMesh(mesh: Mesh): void;
  113521. /**
  113522. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113523. * @param mesh The mesh to remove
  113524. */
  113525. removeIncludedOnlyMesh(mesh: Mesh): void;
  113526. /**
  113527. * Determine if a given mesh will be used in the glow layer
  113528. * @param mesh The mesh to test
  113529. * @returns true if the mesh will be highlighted by the current glow layer
  113530. */
  113531. hasMesh(mesh: AbstractMesh): boolean;
  113532. /**
  113533. * Free any resources and references associated to a mesh.
  113534. * Internal use
  113535. * @param mesh The mesh to free.
  113536. * @hidden
  113537. */
  113538. _disposeMesh(mesh: Mesh): void;
  113539. /**
  113540. * Gets the class name of the effect layer
  113541. * @returns the string with the class name of the effect layer
  113542. */
  113543. getClassName(): string;
  113544. /**
  113545. * Serializes this glow layer
  113546. * @returns a serialized glow layer object
  113547. */
  113548. serialize(): any;
  113549. /**
  113550. * Creates a Glow Layer from parsed glow layer data
  113551. * @param parsedGlowLayer defines glow layer data
  113552. * @param scene defines the current scene
  113553. * @param rootUrl defines the root URL containing the glow layer information
  113554. * @returns a parsed Glow Layer
  113555. */
  113556. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113557. }
  113558. }
  113559. declare module BABYLON {
  113560. /** @hidden */
  113561. export var glowBlurPostProcessPixelShader: {
  113562. name: string;
  113563. shader: string;
  113564. };
  113565. }
  113566. declare module BABYLON {
  113567. interface AbstractScene {
  113568. /**
  113569. * Return a the first highlight layer of the scene with a given name.
  113570. * @param name The name of the highlight layer to look for.
  113571. * @return The highlight layer if found otherwise null.
  113572. */
  113573. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113574. }
  113575. /**
  113576. * Highlight layer options. This helps customizing the behaviour
  113577. * of the highlight layer.
  113578. */
  113579. export interface IHighlightLayerOptions {
  113580. /**
  113581. * Multiplication factor apply to the canvas size to compute the render target size
  113582. * used to generated the glowing objects (the smaller the faster).
  113583. */
  113584. mainTextureRatio: number;
  113585. /**
  113586. * Enforces a fixed size texture to ensure resize independant blur.
  113587. */
  113588. mainTextureFixedSize?: number;
  113589. /**
  113590. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113591. * of the picture to blur (the smaller the faster).
  113592. */
  113593. blurTextureSizeRatio: number;
  113594. /**
  113595. * How big in texel of the blur texture is the vertical blur.
  113596. */
  113597. blurVerticalSize: number;
  113598. /**
  113599. * How big in texel of the blur texture is the horizontal blur.
  113600. */
  113601. blurHorizontalSize: number;
  113602. /**
  113603. * Alpha blending mode used to apply the blur. Default is combine.
  113604. */
  113605. alphaBlendingMode: number;
  113606. /**
  113607. * The camera attached to the layer.
  113608. */
  113609. camera: Nullable<Camera>;
  113610. /**
  113611. * Should we display highlight as a solid stroke?
  113612. */
  113613. isStroke?: boolean;
  113614. /**
  113615. * The rendering group to draw the layer in.
  113616. */
  113617. renderingGroupId: number;
  113618. }
  113619. /**
  113620. * The highlight layer Helps adding a glow effect around a mesh.
  113621. *
  113622. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113623. * glowy meshes to your scene.
  113624. *
  113625. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113626. */
  113627. export class HighlightLayer extends EffectLayer {
  113628. name: string;
  113629. /**
  113630. * Effect Name of the highlight layer.
  113631. */
  113632. static readonly EffectName: string;
  113633. /**
  113634. * The neutral color used during the preparation of the glow effect.
  113635. * This is black by default as the blend operation is a blend operation.
  113636. */
  113637. static NeutralColor: Color4;
  113638. /**
  113639. * Stencil value used for glowing meshes.
  113640. */
  113641. static GlowingMeshStencilReference: number;
  113642. /**
  113643. * Stencil value used for the other meshes in the scene.
  113644. */
  113645. static NormalMeshStencilReference: number;
  113646. /**
  113647. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113648. */
  113649. innerGlow: boolean;
  113650. /**
  113651. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113652. */
  113653. outerGlow: boolean;
  113654. /**
  113655. * Specifies the horizontal size of the blur.
  113656. */
  113657. /**
  113658. * Gets the horizontal size of the blur.
  113659. */
  113660. blurHorizontalSize: number;
  113661. /**
  113662. * Specifies the vertical size of the blur.
  113663. */
  113664. /**
  113665. * Gets the vertical size of the blur.
  113666. */
  113667. blurVerticalSize: number;
  113668. /**
  113669. * An event triggered when the highlight layer is being blurred.
  113670. */
  113671. onBeforeBlurObservable: Observable<HighlightLayer>;
  113672. /**
  113673. * An event triggered when the highlight layer has been blurred.
  113674. */
  113675. onAfterBlurObservable: Observable<HighlightLayer>;
  113676. private _instanceGlowingMeshStencilReference;
  113677. private _options;
  113678. private _downSamplePostprocess;
  113679. private _horizontalBlurPostprocess;
  113680. private _verticalBlurPostprocess;
  113681. private _blurTexture;
  113682. private _meshes;
  113683. private _excludedMeshes;
  113684. /**
  113685. * Instantiates a new highlight Layer and references it to the scene..
  113686. * @param name The name of the layer
  113687. * @param scene The scene to use the layer in
  113688. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113689. */
  113690. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113691. /**
  113692. * Get the effect name of the layer.
  113693. * @return The effect name
  113694. */
  113695. getEffectName(): string;
  113696. /**
  113697. * Create the merge effect. This is the shader use to blit the information back
  113698. * to the main canvas at the end of the scene rendering.
  113699. */
  113700. protected _createMergeEffect(): Effect;
  113701. /**
  113702. * Creates the render target textures and post processes used in the highlight layer.
  113703. */
  113704. protected _createTextureAndPostProcesses(): void;
  113705. /**
  113706. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113707. */
  113708. needStencil(): boolean;
  113709. /**
  113710. * Checks for the readiness of the element composing the layer.
  113711. * @param subMesh the mesh to check for
  113712. * @param useInstances specify wether or not to use instances to render the mesh
  113713. * @param emissiveTexture the associated emissive texture used to generate the glow
  113714. * @return true if ready otherwise, false
  113715. */
  113716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113717. /**
  113718. * Implementation specific of rendering the generating effect on the main canvas.
  113719. * @param effect The effect used to render through
  113720. */
  113721. protected _internalRender(effect: Effect): void;
  113722. /**
  113723. * Returns true if the layer contains information to display, otherwise false.
  113724. */
  113725. shouldRender(): boolean;
  113726. /**
  113727. * Returns true if the mesh should render, otherwise false.
  113728. * @param mesh The mesh to render
  113729. * @returns true if it should render otherwise false
  113730. */
  113731. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113732. /**
  113733. * Sets the required values for both the emissive texture and and the main color.
  113734. */
  113735. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113736. /**
  113737. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113738. * @param mesh The mesh to exclude from the highlight layer
  113739. */
  113740. addExcludedMesh(mesh: Mesh): void;
  113741. /**
  113742. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113743. * @param mesh The mesh to highlight
  113744. */
  113745. removeExcludedMesh(mesh: Mesh): void;
  113746. /**
  113747. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113748. * @param mesh mesh to test
  113749. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113750. */
  113751. hasMesh(mesh: AbstractMesh): boolean;
  113752. /**
  113753. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113754. * @param mesh The mesh to highlight
  113755. * @param color The color of the highlight
  113756. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113757. */
  113758. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113759. /**
  113760. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113761. * @param mesh The mesh to highlight
  113762. */
  113763. removeMesh(mesh: Mesh): void;
  113764. /**
  113765. * Force the stencil to the normal expected value for none glowing parts
  113766. */
  113767. private _defaultStencilReference;
  113768. /**
  113769. * Free any resources and references associated to a mesh.
  113770. * Internal use
  113771. * @param mesh The mesh to free.
  113772. * @hidden
  113773. */
  113774. _disposeMesh(mesh: Mesh): void;
  113775. /**
  113776. * Dispose the highlight layer and free resources.
  113777. */
  113778. dispose(): void;
  113779. /**
  113780. * Gets the class name of the effect layer
  113781. * @returns the string with the class name of the effect layer
  113782. */
  113783. getClassName(): string;
  113784. /**
  113785. * Serializes this Highlight layer
  113786. * @returns a serialized Highlight layer object
  113787. */
  113788. serialize(): any;
  113789. /**
  113790. * Creates a Highlight layer from parsed Highlight layer data
  113791. * @param parsedHightlightLayer defines the Highlight layer data
  113792. * @param scene defines the current scene
  113793. * @param rootUrl defines the root URL containing the Highlight layer information
  113794. * @returns a parsed Highlight layer
  113795. */
  113796. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113797. }
  113798. }
  113799. declare module BABYLON {
  113800. interface AbstractScene {
  113801. /**
  113802. * The list of layers (background and foreground) of the scene
  113803. */
  113804. layers: Array<Layer>;
  113805. }
  113806. /**
  113807. * Defines the layer scene component responsible to manage any layers
  113808. * in a given scene.
  113809. */
  113810. export class LayerSceneComponent implements ISceneComponent {
  113811. /**
  113812. * The component name helpfull to identify the component in the list of scene components.
  113813. */
  113814. readonly name: string;
  113815. /**
  113816. * The scene the component belongs to.
  113817. */
  113818. scene: Scene;
  113819. private _engine;
  113820. /**
  113821. * Creates a new instance of the component for the given scene
  113822. * @param scene Defines the scene to register the component in
  113823. */
  113824. constructor(scene: Scene);
  113825. /**
  113826. * Registers the component in a given scene
  113827. */
  113828. register(): void;
  113829. /**
  113830. * Rebuilds the elements related to this component in case of
  113831. * context lost for instance.
  113832. */
  113833. rebuild(): void;
  113834. /**
  113835. * Disposes the component and the associated ressources.
  113836. */
  113837. dispose(): void;
  113838. private _draw;
  113839. private _drawCameraPredicate;
  113840. private _drawCameraBackground;
  113841. private _drawCameraForeground;
  113842. private _drawRenderTargetPredicate;
  113843. private _drawRenderTargetBackground;
  113844. private _drawRenderTargetForeground;
  113845. /**
  113846. * Adds all the elements from the container to the scene
  113847. * @param container the container holding the elements
  113848. */
  113849. addFromContainer(container: AbstractScene): void;
  113850. /**
  113851. * Removes all the elements in the container from the scene
  113852. * @param container contains the elements to remove
  113853. * @param dispose if the removed element should be disposed (default: false)
  113854. */
  113855. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113856. }
  113857. }
  113858. declare module BABYLON {
  113859. /** @hidden */
  113860. export var layerPixelShader: {
  113861. name: string;
  113862. shader: string;
  113863. };
  113864. }
  113865. declare module BABYLON {
  113866. /** @hidden */
  113867. export var layerVertexShader: {
  113868. name: string;
  113869. shader: string;
  113870. };
  113871. }
  113872. declare module BABYLON {
  113873. /**
  113874. * This represents a full screen 2d layer.
  113875. * This can be useful to display a picture in the background of your scene for instance.
  113876. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113877. */
  113878. export class Layer {
  113879. /**
  113880. * Define the name of the layer.
  113881. */
  113882. name: string;
  113883. /**
  113884. * Define the texture the layer should display.
  113885. */
  113886. texture: Nullable<Texture>;
  113887. /**
  113888. * Is the layer in background or foreground.
  113889. */
  113890. isBackground: boolean;
  113891. /**
  113892. * Define the color of the layer (instead of texture).
  113893. */
  113894. color: Color4;
  113895. /**
  113896. * Define the scale of the layer in order to zoom in out of the texture.
  113897. */
  113898. scale: Vector2;
  113899. /**
  113900. * Define an offset for the layer in order to shift the texture.
  113901. */
  113902. offset: Vector2;
  113903. /**
  113904. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113905. */
  113906. alphaBlendingMode: number;
  113907. /**
  113908. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113909. * Alpha test will not mix with the background color in case of transparency.
  113910. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113911. */
  113912. alphaTest: boolean;
  113913. /**
  113914. * Define a mask to restrict the layer to only some of the scene cameras.
  113915. */
  113916. layerMask: number;
  113917. /**
  113918. * Define the list of render target the layer is visible into.
  113919. */
  113920. renderTargetTextures: RenderTargetTexture[];
  113921. /**
  113922. * Define if the layer is only used in renderTarget or if it also
  113923. * renders in the main frame buffer of the canvas.
  113924. */
  113925. renderOnlyInRenderTargetTextures: boolean;
  113926. private _scene;
  113927. private _vertexBuffers;
  113928. private _indexBuffer;
  113929. private _effect;
  113930. private _alphaTestEffect;
  113931. /**
  113932. * An event triggered when the layer is disposed.
  113933. */
  113934. onDisposeObservable: Observable<Layer>;
  113935. private _onDisposeObserver;
  113936. /**
  113937. * Back compatibility with callback before the onDisposeObservable existed.
  113938. * The set callback will be triggered when the layer has been disposed.
  113939. */
  113940. onDispose: () => void;
  113941. /**
  113942. * An event triggered before rendering the scene
  113943. */
  113944. onBeforeRenderObservable: Observable<Layer>;
  113945. private _onBeforeRenderObserver;
  113946. /**
  113947. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113948. * The set callback will be triggered just before rendering the layer.
  113949. */
  113950. onBeforeRender: () => void;
  113951. /**
  113952. * An event triggered after rendering the scene
  113953. */
  113954. onAfterRenderObservable: Observable<Layer>;
  113955. private _onAfterRenderObserver;
  113956. /**
  113957. * Back compatibility with callback before the onAfterRenderObservable existed.
  113958. * The set callback will be triggered just after rendering the layer.
  113959. */
  113960. onAfterRender: () => void;
  113961. /**
  113962. * Instantiates a new layer.
  113963. * This represents a full screen 2d layer.
  113964. * This can be useful to display a picture in the background of your scene for instance.
  113965. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113966. * @param name Define the name of the layer in the scene
  113967. * @param imgUrl Define the url of the texture to display in the layer
  113968. * @param scene Define the scene the layer belongs to
  113969. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113970. * @param color Defines a color for the layer
  113971. */
  113972. constructor(
  113973. /**
  113974. * Define the name of the layer.
  113975. */
  113976. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113977. private _createIndexBuffer;
  113978. /** @hidden */
  113979. _rebuild(): void;
  113980. /**
  113981. * Renders the layer in the scene.
  113982. */
  113983. render(): void;
  113984. /**
  113985. * Disposes and releases the associated ressources.
  113986. */
  113987. dispose(): void;
  113988. }
  113989. }
  113990. declare module BABYLON {
  113991. /** @hidden */
  113992. export var lensFlarePixelShader: {
  113993. name: string;
  113994. shader: string;
  113995. };
  113996. }
  113997. declare module BABYLON {
  113998. /** @hidden */
  113999. export var lensFlareVertexShader: {
  114000. name: string;
  114001. shader: string;
  114002. };
  114003. }
  114004. declare module BABYLON {
  114005. /**
  114006. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114007. * It is usually composed of several `lensFlare`.
  114008. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114009. */
  114010. export class LensFlareSystem {
  114011. /**
  114012. * Define the name of the lens flare system
  114013. */
  114014. name: string;
  114015. /**
  114016. * List of lens flares used in this system.
  114017. */
  114018. lensFlares: LensFlare[];
  114019. /**
  114020. * Define a limit from the border the lens flare can be visible.
  114021. */
  114022. borderLimit: number;
  114023. /**
  114024. * Define a viewport border we do not want to see the lens flare in.
  114025. */
  114026. viewportBorder: number;
  114027. /**
  114028. * Define a predicate which could limit the list of meshes able to occlude the effect.
  114029. */
  114030. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114031. /**
  114032. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  114033. */
  114034. layerMask: number;
  114035. /**
  114036. * Define the id of the lens flare system in the scene.
  114037. * (equal to name by default)
  114038. */
  114039. id: string;
  114040. private _scene;
  114041. private _emitter;
  114042. private _vertexBuffers;
  114043. private _indexBuffer;
  114044. private _effect;
  114045. private _positionX;
  114046. private _positionY;
  114047. private _isEnabled;
  114048. /** @hidden */
  114049. static _SceneComponentInitialization: (scene: Scene) => void;
  114050. /**
  114051. * Instantiates a lens flare system.
  114052. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114053. * It is usually composed of several `lensFlare`.
  114054. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114055. * @param name Define the name of the lens flare system in the scene
  114056. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  114057. * @param scene Define the scene the lens flare system belongs to
  114058. */
  114059. constructor(
  114060. /**
  114061. * Define the name of the lens flare system
  114062. */
  114063. name: string, emitter: any, scene: Scene);
  114064. /**
  114065. * Define if the lens flare system is enabled.
  114066. */
  114067. isEnabled: boolean;
  114068. /**
  114069. * Get the scene the effects belongs to.
  114070. * @returns the scene holding the lens flare system
  114071. */
  114072. getScene(): Scene;
  114073. /**
  114074. * Get the emitter of the lens flare system.
  114075. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114076. * @returns the emitter of the lens flare system
  114077. */
  114078. getEmitter(): any;
  114079. /**
  114080. * Set the emitter of the lens flare system.
  114081. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114082. * @param newEmitter Define the new emitter of the system
  114083. */
  114084. setEmitter(newEmitter: any): void;
  114085. /**
  114086. * Get the lens flare system emitter position.
  114087. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  114088. * @returns the position
  114089. */
  114090. getEmitterPosition(): Vector3;
  114091. /**
  114092. * @hidden
  114093. */
  114094. computeEffectivePosition(globalViewport: Viewport): boolean;
  114095. /** @hidden */
  114096. _isVisible(): boolean;
  114097. /**
  114098. * @hidden
  114099. */
  114100. render(): boolean;
  114101. /**
  114102. * Dispose and release the lens flare with its associated resources.
  114103. */
  114104. dispose(): void;
  114105. /**
  114106. * Parse a lens flare system from a JSON repressentation
  114107. * @param parsedLensFlareSystem Define the JSON to parse
  114108. * @param scene Define the scene the parsed system should be instantiated in
  114109. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  114110. * @returns the parsed system
  114111. */
  114112. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  114113. /**
  114114. * Serialize the current Lens Flare System into a JSON representation.
  114115. * @returns the serialized JSON
  114116. */
  114117. serialize(): any;
  114118. }
  114119. }
  114120. declare module BABYLON {
  114121. /**
  114122. * This represents one of the lens effect in a `lensFlareSystem`.
  114123. * It controls one of the indiviual texture used in the effect.
  114124. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114125. */
  114126. export class LensFlare {
  114127. /**
  114128. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114129. */
  114130. size: number;
  114131. /**
  114132. * 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.
  114133. */
  114134. position: number;
  114135. /**
  114136. * Define the lens color.
  114137. */
  114138. color: Color3;
  114139. /**
  114140. * Define the lens texture.
  114141. */
  114142. texture: Nullable<Texture>;
  114143. /**
  114144. * Define the alpha mode to render this particular lens.
  114145. */
  114146. alphaMode: number;
  114147. private _system;
  114148. /**
  114149. * Creates a new Lens Flare.
  114150. * This represents one of the lens effect in a `lensFlareSystem`.
  114151. * It controls one of the indiviual texture used in the effect.
  114152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114153. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  114154. * @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.
  114155. * @param color Define the lens color
  114156. * @param imgUrl Define the lens texture url
  114157. * @param system Define the `lensFlareSystem` this flare is part of
  114158. * @returns The newly created Lens Flare
  114159. */
  114160. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114161. /**
  114162. * Instantiates a new Lens Flare.
  114163. * This represents one of the lens effect in a `lensFlareSystem`.
  114164. * It controls one of the indiviual texture used in the effect.
  114165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114166. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114167. * @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.
  114168. * @param color Define the lens color
  114169. * @param imgUrl Define the lens texture url
  114170. * @param system Define the `lensFlareSystem` this flare is part of
  114171. */
  114172. constructor(
  114173. /**
  114174. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114175. */
  114176. size: number,
  114177. /**
  114178. * 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.
  114179. */
  114180. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114181. /**
  114182. * Dispose and release the lens flare with its associated resources.
  114183. */
  114184. dispose(): void;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. interface AbstractScene {
  114189. /**
  114190. * The list of lens flare system added to the scene
  114191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114192. */
  114193. lensFlareSystems: Array<LensFlareSystem>;
  114194. /**
  114195. * Removes the given lens flare system from this scene.
  114196. * @param toRemove The lens flare system to remove
  114197. * @returns The index of the removed lens flare system
  114198. */
  114199. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114200. /**
  114201. * Adds the given lens flare system to this scene
  114202. * @param newLensFlareSystem The lens flare system to add
  114203. */
  114204. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114205. /**
  114206. * Gets a lens flare system using its name
  114207. * @param name defines the name to look for
  114208. * @returns the lens flare system or null if not found
  114209. */
  114210. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114211. /**
  114212. * Gets a lens flare system using its id
  114213. * @param id defines the id to look for
  114214. * @returns the lens flare system or null if not found
  114215. */
  114216. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114217. }
  114218. /**
  114219. * Defines the lens flare scene component responsible to manage any lens flares
  114220. * in a given scene.
  114221. */
  114222. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114223. /**
  114224. * The component name helpfull to identify the component in the list of scene components.
  114225. */
  114226. readonly name: string;
  114227. /**
  114228. * The scene the component belongs to.
  114229. */
  114230. scene: Scene;
  114231. /**
  114232. * Creates a new instance of the component for the given scene
  114233. * @param scene Defines the scene to register the component in
  114234. */
  114235. constructor(scene: Scene);
  114236. /**
  114237. * Registers the component in a given scene
  114238. */
  114239. register(): void;
  114240. /**
  114241. * Rebuilds the elements related to this component in case of
  114242. * context lost for instance.
  114243. */
  114244. rebuild(): void;
  114245. /**
  114246. * Adds all the elements from the container to the scene
  114247. * @param container the container holding the elements
  114248. */
  114249. addFromContainer(container: AbstractScene): void;
  114250. /**
  114251. * Removes all the elements in the container from the scene
  114252. * @param container contains the elements to remove
  114253. * @param dispose if the removed element should be disposed (default: false)
  114254. */
  114255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114256. /**
  114257. * Serializes the component data to the specified json object
  114258. * @param serializationObject The object to serialize to
  114259. */
  114260. serialize(serializationObject: any): void;
  114261. /**
  114262. * Disposes the component and the associated ressources.
  114263. */
  114264. dispose(): void;
  114265. private _draw;
  114266. }
  114267. }
  114268. declare module BABYLON {
  114269. /**
  114270. * Defines the shadow generator component responsible to manage any shadow generators
  114271. * in a given scene.
  114272. */
  114273. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114274. /**
  114275. * The component name helpfull to identify the component in the list of scene components.
  114276. */
  114277. readonly name: string;
  114278. /**
  114279. * The scene the component belongs to.
  114280. */
  114281. scene: Scene;
  114282. /**
  114283. * Creates a new instance of the component for the given scene
  114284. * @param scene Defines the scene to register the component in
  114285. */
  114286. constructor(scene: Scene);
  114287. /**
  114288. * Registers the component in a given scene
  114289. */
  114290. register(): void;
  114291. /**
  114292. * Rebuilds the elements related to this component in case of
  114293. * context lost for instance.
  114294. */
  114295. rebuild(): void;
  114296. /**
  114297. * Serializes the component data to the specified json object
  114298. * @param serializationObject The object to serialize to
  114299. */
  114300. serialize(serializationObject: any): void;
  114301. /**
  114302. * Adds all the elements from the container to the scene
  114303. * @param container the container holding the elements
  114304. */
  114305. addFromContainer(container: AbstractScene): void;
  114306. /**
  114307. * Removes all the elements in the container from the scene
  114308. * @param container contains the elements to remove
  114309. * @param dispose if the removed element should be disposed (default: false)
  114310. */
  114311. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114312. /**
  114313. * Rebuilds the elements related to this component in case of
  114314. * context lost for instance.
  114315. */
  114316. dispose(): void;
  114317. private _gatherRenderTargets;
  114318. }
  114319. }
  114320. declare module BABYLON {
  114321. /**
  114322. * A point light is a light defined by an unique point in world space.
  114323. * The light is emitted in every direction from this point.
  114324. * A good example of a point light is a standard light bulb.
  114325. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114326. */
  114327. export class PointLight extends ShadowLight {
  114328. private _shadowAngle;
  114329. /**
  114330. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114331. * This specifies what angle the shadow will use to be created.
  114332. *
  114333. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114334. */
  114335. /**
  114336. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114337. * This specifies what angle the shadow will use to be created.
  114338. *
  114339. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114340. */
  114341. shadowAngle: number;
  114342. /**
  114343. * Gets the direction if it has been set.
  114344. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114345. */
  114346. /**
  114347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114348. */
  114349. direction: Vector3;
  114350. /**
  114351. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114352. * A PointLight emits the light in every direction.
  114353. * It can cast shadows.
  114354. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114355. * ```javascript
  114356. * var pointLight = new PointLight("pl", camera.position, scene);
  114357. * ```
  114358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114359. * @param name The light friendly name
  114360. * @param position The position of the point light in the scene
  114361. * @param scene The scene the lights belongs to
  114362. */
  114363. constructor(name: string, position: Vector3, scene: Scene);
  114364. /**
  114365. * Returns the string "PointLight"
  114366. * @returns the class name
  114367. */
  114368. getClassName(): string;
  114369. /**
  114370. * Returns the integer 0.
  114371. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114372. */
  114373. getTypeID(): number;
  114374. /**
  114375. * Specifies wether or not the shadowmap should be a cube texture.
  114376. * @returns true if the shadowmap needs to be a cube texture.
  114377. */
  114378. needCube(): boolean;
  114379. /**
  114380. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114381. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114382. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114383. */
  114384. getShadowDirection(faceIndex?: number): Vector3;
  114385. /**
  114386. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114387. * - fov = PI / 2
  114388. * - aspect ratio : 1.0
  114389. * - z-near and far equal to the active camera minZ and maxZ.
  114390. * Returns the PointLight.
  114391. */
  114392. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114393. protected _buildUniformLayout(): void;
  114394. /**
  114395. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114396. * @param effect The effect to update
  114397. * @param lightIndex The index of the light in the effect to update
  114398. * @returns The point light
  114399. */
  114400. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114401. /**
  114402. * Prepares the list of defines specific to the light type.
  114403. * @param defines the list of defines
  114404. * @param lightIndex defines the index of the light for the effect
  114405. */
  114406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114407. }
  114408. }
  114409. declare module BABYLON {
  114410. /**
  114411. * Header information of HDR texture files.
  114412. */
  114413. export interface HDRInfo {
  114414. /**
  114415. * The height of the texture in pixels.
  114416. */
  114417. height: number;
  114418. /**
  114419. * The width of the texture in pixels.
  114420. */
  114421. width: number;
  114422. /**
  114423. * The index of the beginning of the data in the binary file.
  114424. */
  114425. dataPosition: number;
  114426. }
  114427. /**
  114428. * This groups tools to convert HDR texture to native colors array.
  114429. */
  114430. export class HDRTools {
  114431. private static Ldexp;
  114432. private static Rgbe2float;
  114433. private static readStringLine;
  114434. /**
  114435. * Reads header information from an RGBE texture stored in a native array.
  114436. * More information on this format are available here:
  114437. * https://en.wikipedia.org/wiki/RGBE_image_format
  114438. *
  114439. * @param uint8array The binary file stored in native array.
  114440. * @return The header information.
  114441. */
  114442. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114443. /**
  114444. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114445. * This RGBE texture needs to store the information as a panorama.
  114446. *
  114447. * More information on this format are available here:
  114448. * https://en.wikipedia.org/wiki/RGBE_image_format
  114449. *
  114450. * @param buffer The binary file stored in an array buffer.
  114451. * @param size The expected size of the extracted cubemap.
  114452. * @return The Cube Map information.
  114453. */
  114454. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114455. /**
  114456. * Returns the pixels data extracted from an RGBE texture.
  114457. * This pixels will be stored left to right up to down in the R G B order in one array.
  114458. *
  114459. * More information on this format are available here:
  114460. * https://en.wikipedia.org/wiki/RGBE_image_format
  114461. *
  114462. * @param uint8array The binary file stored in an array buffer.
  114463. * @param hdrInfo The header information of the file.
  114464. * @return The pixels data in RGB right to left up to down order.
  114465. */
  114466. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114467. private static RGBE_ReadPixels_RLE;
  114468. }
  114469. }
  114470. declare module BABYLON {
  114471. /**
  114472. * This represents a texture coming from an HDR input.
  114473. *
  114474. * The only supported format is currently panorama picture stored in RGBE format.
  114475. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114476. */
  114477. export class HDRCubeTexture extends BaseTexture {
  114478. private static _facesMapping;
  114479. private _generateHarmonics;
  114480. private _noMipmap;
  114481. private _textureMatrix;
  114482. private _size;
  114483. private _onLoad;
  114484. private _onError;
  114485. /**
  114486. * The texture URL.
  114487. */
  114488. url: string;
  114489. /**
  114490. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114491. */
  114492. coordinatesMode: number;
  114493. protected _isBlocking: boolean;
  114494. /**
  114495. * Sets wether or not the texture is blocking during loading.
  114496. */
  114497. /**
  114498. * Gets wether or not the texture is blocking during loading.
  114499. */
  114500. isBlocking: boolean;
  114501. protected _rotationY: number;
  114502. /**
  114503. * Sets texture matrix rotation angle around Y axis in radians.
  114504. */
  114505. /**
  114506. * Gets texture matrix rotation angle around Y axis radians.
  114507. */
  114508. rotationY: number;
  114509. /**
  114510. * Gets or sets the center of the bounding box associated with the cube texture
  114511. * It must define where the camera used to render the texture was set
  114512. */
  114513. boundingBoxPosition: Vector3;
  114514. private _boundingBoxSize;
  114515. /**
  114516. * Gets or sets the size of the bounding box associated with the cube texture
  114517. * When defined, the cubemap will switch to local mode
  114518. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114519. * @example https://www.babylonjs-playground.com/#RNASML
  114520. */
  114521. boundingBoxSize: Vector3;
  114522. /**
  114523. * Instantiates an HDRTexture from the following parameters.
  114524. *
  114525. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114526. * @param scene The scene the texture will be used in
  114527. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114528. * @param noMipmap Forces to not generate the mipmap if true
  114529. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114530. * @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)
  114531. * @param reserved Reserved flag for internal use.
  114532. */
  114533. 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>);
  114534. /**
  114535. * Get the current class name of the texture useful for serialization or dynamic coding.
  114536. * @returns "HDRCubeTexture"
  114537. */
  114538. getClassName(): string;
  114539. /**
  114540. * Occurs when the file is raw .hdr file.
  114541. */
  114542. private loadTexture;
  114543. clone(): HDRCubeTexture;
  114544. delayLoad(): void;
  114545. /**
  114546. * Get the texture reflection matrix used to rotate/transform the reflection.
  114547. * @returns the reflection matrix
  114548. */
  114549. getReflectionTextureMatrix(): Matrix;
  114550. /**
  114551. * Set the texture reflection matrix used to rotate/transform the reflection.
  114552. * @param value Define the reflection matrix to set
  114553. */
  114554. setReflectionTextureMatrix(value: Matrix): void;
  114555. /**
  114556. * Parses a JSON representation of an HDR Texture in order to create the texture
  114557. * @param parsedTexture Define the JSON representation
  114558. * @param scene Define the scene the texture should be created in
  114559. * @param rootUrl Define the root url in case we need to load relative dependencies
  114560. * @returns the newly created texture after parsing
  114561. */
  114562. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114563. serialize(): any;
  114564. }
  114565. }
  114566. declare module BABYLON {
  114567. /**
  114568. * Class used to control physics engine
  114569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114570. */
  114571. export class PhysicsEngine implements IPhysicsEngine {
  114572. private _physicsPlugin;
  114573. /**
  114574. * Global value used to control the smallest number supported by the simulation
  114575. */
  114576. static Epsilon: number;
  114577. private _impostors;
  114578. private _joints;
  114579. /**
  114580. * Gets the gravity vector used by the simulation
  114581. */
  114582. gravity: Vector3;
  114583. /**
  114584. * Factory used to create the default physics plugin.
  114585. * @returns The default physics plugin
  114586. */
  114587. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114588. /**
  114589. * Creates a new Physics Engine
  114590. * @param gravity defines the gravity vector used by the simulation
  114591. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114592. */
  114593. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114594. /**
  114595. * Sets the gravity vector used by the simulation
  114596. * @param gravity defines the gravity vector to use
  114597. */
  114598. setGravity(gravity: Vector3): void;
  114599. /**
  114600. * Set the time step of the physics engine.
  114601. * Default is 1/60.
  114602. * To slow it down, enter 1/600 for example.
  114603. * To speed it up, 1/30
  114604. * @param newTimeStep defines the new timestep to apply to this world.
  114605. */
  114606. setTimeStep(newTimeStep?: number): void;
  114607. /**
  114608. * Get the time step of the physics engine.
  114609. * @returns the current time step
  114610. */
  114611. getTimeStep(): number;
  114612. /**
  114613. * Release all resources
  114614. */
  114615. dispose(): void;
  114616. /**
  114617. * Gets the name of the current physics plugin
  114618. * @returns the name of the plugin
  114619. */
  114620. getPhysicsPluginName(): string;
  114621. /**
  114622. * Adding a new impostor for the impostor tracking.
  114623. * This will be done by the impostor itself.
  114624. * @param impostor the impostor to add
  114625. */
  114626. addImpostor(impostor: PhysicsImpostor): void;
  114627. /**
  114628. * Remove an impostor from the engine.
  114629. * This impostor and its mesh will not longer be updated by the physics engine.
  114630. * @param impostor the impostor to remove
  114631. */
  114632. removeImpostor(impostor: PhysicsImpostor): void;
  114633. /**
  114634. * Add a joint to the physics engine
  114635. * @param mainImpostor defines the main impostor to which the joint is added.
  114636. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114637. * @param joint defines the joint that will connect both impostors.
  114638. */
  114639. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114640. /**
  114641. * Removes a joint from the simulation
  114642. * @param mainImpostor defines the impostor used with the joint
  114643. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114644. * @param joint defines the joint to remove
  114645. */
  114646. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114647. /**
  114648. * Called by the scene. No need to call it.
  114649. * @param delta defines the timespam between frames
  114650. */
  114651. _step(delta: number): void;
  114652. /**
  114653. * Gets the current plugin used to run the simulation
  114654. * @returns current plugin
  114655. */
  114656. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114657. /**
  114658. * Gets the list of physic impostors
  114659. * @returns an array of PhysicsImpostor
  114660. */
  114661. getImpostors(): Array<PhysicsImpostor>;
  114662. /**
  114663. * Gets the impostor for a physics enabled object
  114664. * @param object defines the object impersonated by the impostor
  114665. * @returns the PhysicsImpostor or null if not found
  114666. */
  114667. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114668. /**
  114669. * Gets the impostor for a physics body object
  114670. * @param body defines physics body used by the impostor
  114671. * @returns the PhysicsImpostor or null if not found
  114672. */
  114673. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114674. /**
  114675. * Does a raycast in the physics world
  114676. * @param from when should the ray start?
  114677. * @param to when should the ray end?
  114678. * @returns PhysicsRaycastResult
  114679. */
  114680. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114681. }
  114682. }
  114683. declare module BABYLON {
  114684. /** @hidden */
  114685. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114686. private _useDeltaForWorldStep;
  114687. world: any;
  114688. name: string;
  114689. private _physicsMaterials;
  114690. private _fixedTimeStep;
  114691. private _cannonRaycastResult;
  114692. private _raycastResult;
  114693. private _physicsBodysToRemoveAfterStep;
  114694. BJSCANNON: any;
  114695. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114696. setGravity(gravity: Vector3): void;
  114697. setTimeStep(timeStep: number): void;
  114698. getTimeStep(): number;
  114699. executeStep(delta: number): void;
  114700. private _removeMarkedPhysicsBodiesFromWorld;
  114701. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114702. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114703. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114704. private _processChildMeshes;
  114705. removePhysicsBody(impostor: PhysicsImpostor): void;
  114706. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114707. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114708. private _addMaterial;
  114709. private _checkWithEpsilon;
  114710. private _createShape;
  114711. private _createHeightmap;
  114712. private _minus90X;
  114713. private _plus90X;
  114714. private _tmpPosition;
  114715. private _tmpDeltaPosition;
  114716. private _tmpUnityRotation;
  114717. private _updatePhysicsBodyTransformation;
  114718. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114720. isSupported(): boolean;
  114721. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114724. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114726. getBodyMass(impostor: PhysicsImpostor): number;
  114727. getBodyFriction(impostor: PhysicsImpostor): number;
  114728. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114729. getBodyRestitution(impostor: PhysicsImpostor): number;
  114730. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114731. sleepBody(impostor: PhysicsImpostor): void;
  114732. wakeUpBody(impostor: PhysicsImpostor): void;
  114733. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114734. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114735. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114736. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114737. getRadius(impostor: PhysicsImpostor): number;
  114738. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114739. dispose(): void;
  114740. private _extendNamespace;
  114741. /**
  114742. * Does a raycast in the physics world
  114743. * @param from when should the ray start?
  114744. * @param to when should the ray end?
  114745. * @returns PhysicsRaycastResult
  114746. */
  114747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114748. }
  114749. }
  114750. declare module BABYLON {
  114751. /** @hidden */
  114752. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114753. world: any;
  114754. name: string;
  114755. BJSOIMO: any;
  114756. private _raycastResult;
  114757. constructor(iterations?: number, oimoInjection?: any);
  114758. setGravity(gravity: Vector3): void;
  114759. setTimeStep(timeStep: number): void;
  114760. getTimeStep(): number;
  114761. private _tmpImpostorsArray;
  114762. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114763. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114764. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114765. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114766. private _tmpPositionVector;
  114767. removePhysicsBody(impostor: PhysicsImpostor): void;
  114768. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114769. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114770. isSupported(): boolean;
  114771. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114772. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114773. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114774. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114775. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114776. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114777. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114778. getBodyMass(impostor: PhysicsImpostor): number;
  114779. getBodyFriction(impostor: PhysicsImpostor): number;
  114780. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114781. getBodyRestitution(impostor: PhysicsImpostor): number;
  114782. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114783. sleepBody(impostor: PhysicsImpostor): void;
  114784. wakeUpBody(impostor: PhysicsImpostor): void;
  114785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114786. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114787. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114789. getRadius(impostor: PhysicsImpostor): number;
  114790. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114791. dispose(): void;
  114792. /**
  114793. * Does a raycast in the physics world
  114794. * @param from when should the ray start?
  114795. * @param to when should the ray end?
  114796. * @returns PhysicsRaycastResult
  114797. */
  114798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114799. }
  114800. }
  114801. declare module BABYLON {
  114802. /**
  114803. * Class containing static functions to help procedurally build meshes
  114804. */
  114805. export class RibbonBuilder {
  114806. /**
  114807. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114808. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114809. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114810. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114811. * * 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
  114812. * * 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
  114813. * * 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
  114814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114816. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114817. * * 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
  114818. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114819. * * 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
  114820. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114822. * @param name defines the name of the mesh
  114823. * @param options defines the options used to create the mesh
  114824. * @param scene defines the hosting scene
  114825. * @returns the ribbon mesh
  114826. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114828. */
  114829. static CreateRibbon(name: string, options: {
  114830. pathArray: Vector3[][];
  114831. closeArray?: boolean;
  114832. closePath?: boolean;
  114833. offset?: number;
  114834. updatable?: boolean;
  114835. sideOrientation?: number;
  114836. frontUVs?: Vector4;
  114837. backUVs?: Vector4;
  114838. instance?: Mesh;
  114839. invertUV?: boolean;
  114840. uvs?: Vector2[];
  114841. colors?: Color4[];
  114842. }, scene?: Nullable<Scene>): Mesh;
  114843. }
  114844. }
  114845. declare module BABYLON {
  114846. /**
  114847. * Class containing static functions to help procedurally build meshes
  114848. */
  114849. export class ShapeBuilder {
  114850. /**
  114851. * 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.
  114852. * * 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.
  114853. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114854. * * 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.
  114855. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114856. * * 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
  114857. * * 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
  114858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114863. * @param name defines the name of the mesh
  114864. * @param options defines the options used to create the mesh
  114865. * @param scene defines the hosting scene
  114866. * @returns the extruded shape mesh
  114867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114869. */
  114870. static ExtrudeShape(name: string, options: {
  114871. shape: Vector3[];
  114872. path: Vector3[];
  114873. scale?: number;
  114874. rotation?: number;
  114875. cap?: number;
  114876. updatable?: boolean;
  114877. sideOrientation?: number;
  114878. frontUVs?: Vector4;
  114879. backUVs?: Vector4;
  114880. instance?: Mesh;
  114881. invertUV?: boolean;
  114882. }, scene?: Nullable<Scene>): Mesh;
  114883. /**
  114884. * Creates an custom extruded shape mesh.
  114885. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114886. * * 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.
  114887. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114888. * * 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
  114889. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114890. * * 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
  114891. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114892. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114893. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114894. * * 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
  114895. * * 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
  114896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114901. * @param name defines the name of the mesh
  114902. * @param options defines the options used to create the mesh
  114903. * @param scene defines the hosting scene
  114904. * @returns the custom extruded shape mesh
  114905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114908. */
  114909. static ExtrudeShapeCustom(name: string, options: {
  114910. shape: Vector3[];
  114911. path: Vector3[];
  114912. scaleFunction?: any;
  114913. rotationFunction?: any;
  114914. ribbonCloseArray?: boolean;
  114915. ribbonClosePath?: boolean;
  114916. cap?: number;
  114917. updatable?: boolean;
  114918. sideOrientation?: number;
  114919. frontUVs?: Vector4;
  114920. backUVs?: Vector4;
  114921. instance?: Mesh;
  114922. invertUV?: boolean;
  114923. }, scene?: Nullable<Scene>): Mesh;
  114924. private static _ExtrudeShapeGeneric;
  114925. }
  114926. }
  114927. declare module BABYLON {
  114928. /**
  114929. * AmmoJS Physics plugin
  114930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114931. * @see https://github.com/kripken/ammo.js/
  114932. */
  114933. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114934. private _useDeltaForWorldStep;
  114935. /**
  114936. * Reference to the Ammo library
  114937. */
  114938. bjsAMMO: any;
  114939. /**
  114940. * Created ammoJS world which physics bodies are added to
  114941. */
  114942. world: any;
  114943. /**
  114944. * Name of the plugin
  114945. */
  114946. name: string;
  114947. private _timeStep;
  114948. private _fixedTimeStep;
  114949. private _maxSteps;
  114950. private _tmpQuaternion;
  114951. private _tmpAmmoTransform;
  114952. private _tmpAmmoQuaternion;
  114953. private _tmpAmmoConcreteContactResultCallback;
  114954. private _collisionConfiguration;
  114955. private _dispatcher;
  114956. private _overlappingPairCache;
  114957. private _solver;
  114958. private _softBodySolver;
  114959. private _tmpAmmoVectorA;
  114960. private _tmpAmmoVectorB;
  114961. private _tmpAmmoVectorC;
  114962. private _tmpAmmoVectorD;
  114963. private _tmpContactCallbackResult;
  114964. private _tmpAmmoVectorRCA;
  114965. private _tmpAmmoVectorRCB;
  114966. private _raycastResult;
  114967. private static readonly DISABLE_COLLISION_FLAG;
  114968. private static readonly KINEMATIC_FLAG;
  114969. private static readonly DISABLE_DEACTIVATION_FLAG;
  114970. /**
  114971. * Initializes the ammoJS plugin
  114972. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114973. * @param ammoInjection can be used to inject your own ammo reference
  114974. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114975. */
  114976. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114977. /**
  114978. * Sets the gravity of the physics world (m/(s^2))
  114979. * @param gravity Gravity to set
  114980. */
  114981. setGravity(gravity: Vector3): void;
  114982. /**
  114983. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114984. * @param timeStep timestep to use in seconds
  114985. */
  114986. setTimeStep(timeStep: number): void;
  114987. /**
  114988. * 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)
  114989. * @param fixedTimeStep fixedTimeStep to use in seconds
  114990. */
  114991. setFixedTimeStep(fixedTimeStep: number): void;
  114992. /**
  114993. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114994. * @param maxSteps the maximum number of steps by the physics engine per frame
  114995. */
  114996. setMaxSteps(maxSteps: number): void;
  114997. /**
  114998. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114999. * @returns the current timestep in seconds
  115000. */
  115001. getTimeStep(): number;
  115002. private _isImpostorInContact;
  115003. private _isImpostorPairInContact;
  115004. private _stepSimulation;
  115005. /**
  115006. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  115007. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  115008. * After the step the babylon meshes are set to the position of the physics imposters
  115009. * @param delta amount of time to step forward
  115010. * @param impostors array of imposters to update before/after the step
  115011. */
  115012. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115013. /**
  115014. * Update babylon mesh to match physics world object
  115015. * @param impostor imposter to match
  115016. */
  115017. private _afterSoftStep;
  115018. /**
  115019. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115020. * @param impostor imposter to match
  115021. */
  115022. private _ropeStep;
  115023. /**
  115024. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115025. * @param impostor imposter to match
  115026. */
  115027. private _softbodyOrClothStep;
  115028. private _tmpVector;
  115029. private _tmpMatrix;
  115030. /**
  115031. * Applies an impulse on the imposter
  115032. * @param impostor imposter to apply impulse to
  115033. * @param force amount of force to be applied to the imposter
  115034. * @param contactPoint the location to apply the impulse on the imposter
  115035. */
  115036. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115037. /**
  115038. * Applies a force on the imposter
  115039. * @param impostor imposter to apply force
  115040. * @param force amount of force to be applied to the imposter
  115041. * @param contactPoint the location to apply the force on the imposter
  115042. */
  115043. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115044. /**
  115045. * Creates a physics body using the plugin
  115046. * @param impostor the imposter to create the physics body on
  115047. */
  115048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115049. /**
  115050. * Removes the physics body from the imposter and disposes of the body's memory
  115051. * @param impostor imposter to remove the physics body from
  115052. */
  115053. removePhysicsBody(impostor: PhysicsImpostor): void;
  115054. /**
  115055. * Generates a joint
  115056. * @param impostorJoint the imposter joint to create the joint with
  115057. */
  115058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115059. /**
  115060. * Removes a joint
  115061. * @param impostorJoint the imposter joint to remove the joint from
  115062. */
  115063. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115064. private _addMeshVerts;
  115065. /**
  115066. * Initialise the soft body vertices to match its object's (mesh) vertices
  115067. * Softbody vertices (nodes) are in world space and to match this
  115068. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  115069. * @param impostor to create the softbody for
  115070. */
  115071. private _softVertexData;
  115072. /**
  115073. * Create an impostor's soft body
  115074. * @param impostor to create the softbody for
  115075. */
  115076. private _createSoftbody;
  115077. /**
  115078. * Create cloth for an impostor
  115079. * @param impostor to create the softbody for
  115080. */
  115081. private _createCloth;
  115082. /**
  115083. * Create rope for an impostor
  115084. * @param impostor to create the softbody for
  115085. */
  115086. private _createRope;
  115087. private _addHullVerts;
  115088. private _createShape;
  115089. /**
  115090. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  115091. * @param impostor imposter containing the physics body and babylon object
  115092. */
  115093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115094. /**
  115095. * Sets the babylon object's position/rotation from the physics body's position/rotation
  115096. * @param impostor imposter containing the physics body and babylon object
  115097. * @param newPosition new position
  115098. * @param newRotation new rotation
  115099. */
  115100. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115101. /**
  115102. * If this plugin is supported
  115103. * @returns true if its supported
  115104. */
  115105. isSupported(): boolean;
  115106. /**
  115107. * Sets the linear velocity of the physics body
  115108. * @param impostor imposter to set the velocity on
  115109. * @param velocity velocity to set
  115110. */
  115111. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115112. /**
  115113. * Sets the angular velocity of the physics body
  115114. * @param impostor imposter to set the velocity on
  115115. * @param velocity velocity to set
  115116. */
  115117. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115118. /**
  115119. * gets the linear velocity
  115120. * @param impostor imposter to get linear velocity from
  115121. * @returns linear velocity
  115122. */
  115123. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115124. /**
  115125. * gets the angular velocity
  115126. * @param impostor imposter to get angular velocity from
  115127. * @returns angular velocity
  115128. */
  115129. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115130. /**
  115131. * Sets the mass of physics body
  115132. * @param impostor imposter to set the mass on
  115133. * @param mass mass to set
  115134. */
  115135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115136. /**
  115137. * Gets the mass of the physics body
  115138. * @param impostor imposter to get the mass from
  115139. * @returns mass
  115140. */
  115141. getBodyMass(impostor: PhysicsImpostor): number;
  115142. /**
  115143. * Gets friction of the impostor
  115144. * @param impostor impostor to get friction from
  115145. * @returns friction value
  115146. */
  115147. getBodyFriction(impostor: PhysicsImpostor): number;
  115148. /**
  115149. * Sets friction of the impostor
  115150. * @param impostor impostor to set friction on
  115151. * @param friction friction value
  115152. */
  115153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115154. /**
  115155. * Gets restitution of the impostor
  115156. * @param impostor impostor to get restitution from
  115157. * @returns restitution value
  115158. */
  115159. getBodyRestitution(impostor: PhysicsImpostor): number;
  115160. /**
  115161. * Sets resitution of the impostor
  115162. * @param impostor impostor to set resitution on
  115163. * @param restitution resitution value
  115164. */
  115165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115166. /**
  115167. * Gets pressure inside the impostor
  115168. * @param impostor impostor to get pressure from
  115169. * @returns pressure value
  115170. */
  115171. getBodyPressure(impostor: PhysicsImpostor): number;
  115172. /**
  115173. * Sets pressure inside a soft body impostor
  115174. * Cloth and rope must remain 0 pressure
  115175. * @param impostor impostor to set pressure on
  115176. * @param pressure pressure value
  115177. */
  115178. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115179. /**
  115180. * Gets stiffness of the impostor
  115181. * @param impostor impostor to get stiffness from
  115182. * @returns pressure value
  115183. */
  115184. getBodyStiffness(impostor: PhysicsImpostor): number;
  115185. /**
  115186. * Sets stiffness of the impostor
  115187. * @param impostor impostor to set stiffness on
  115188. * @param stiffness stiffness value from 0 to 1
  115189. */
  115190. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115191. /**
  115192. * Gets velocityIterations of the impostor
  115193. * @param impostor impostor to get velocity iterations from
  115194. * @returns velocityIterations value
  115195. */
  115196. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115197. /**
  115198. * Sets velocityIterations of the impostor
  115199. * @param impostor impostor to set velocity iterations on
  115200. * @param velocityIterations velocityIterations value
  115201. */
  115202. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115203. /**
  115204. * Gets positionIterations of the impostor
  115205. * @param impostor impostor to get position iterations from
  115206. * @returns positionIterations value
  115207. */
  115208. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115209. /**
  115210. * Sets positionIterations of the impostor
  115211. * @param impostor impostor to set position on
  115212. * @param positionIterations positionIterations value
  115213. */
  115214. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115215. /**
  115216. * Append an anchor to a cloth object
  115217. * @param impostor is the cloth impostor to add anchor to
  115218. * @param otherImpostor is the rigid impostor to anchor to
  115219. * @param width ratio across width from 0 to 1
  115220. * @param height ratio up height from 0 to 1
  115221. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115222. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115223. */
  115224. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115225. /**
  115226. * Append an hook to a rope object
  115227. * @param impostor is the rope impostor to add hook to
  115228. * @param otherImpostor is the rigid impostor to hook to
  115229. * @param length ratio along the rope from 0 to 1
  115230. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115231. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115232. */
  115233. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115234. /**
  115235. * Sleeps the physics body and stops it from being active
  115236. * @param impostor impostor to sleep
  115237. */
  115238. sleepBody(impostor: PhysicsImpostor): void;
  115239. /**
  115240. * Activates the physics body
  115241. * @param impostor impostor to activate
  115242. */
  115243. wakeUpBody(impostor: PhysicsImpostor): void;
  115244. /**
  115245. * Updates the distance parameters of the joint
  115246. * @param joint joint to update
  115247. * @param maxDistance maximum distance of the joint
  115248. * @param minDistance minimum distance of the joint
  115249. */
  115250. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115251. /**
  115252. * Sets a motor on the joint
  115253. * @param joint joint to set motor on
  115254. * @param speed speed of the motor
  115255. * @param maxForce maximum force of the motor
  115256. * @param motorIndex index of the motor
  115257. */
  115258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115259. /**
  115260. * Sets the motors limit
  115261. * @param joint joint to set limit on
  115262. * @param upperLimit upper limit
  115263. * @param lowerLimit lower limit
  115264. */
  115265. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115266. /**
  115267. * Syncs the position and rotation of a mesh with the impostor
  115268. * @param mesh mesh to sync
  115269. * @param impostor impostor to update the mesh with
  115270. */
  115271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115272. /**
  115273. * Gets the radius of the impostor
  115274. * @param impostor impostor to get radius from
  115275. * @returns the radius
  115276. */
  115277. getRadius(impostor: PhysicsImpostor): number;
  115278. /**
  115279. * Gets the box size of the impostor
  115280. * @param impostor impostor to get box size from
  115281. * @param result the resulting box size
  115282. */
  115283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115284. /**
  115285. * Disposes of the impostor
  115286. */
  115287. dispose(): void;
  115288. /**
  115289. * Does a raycast in the physics world
  115290. * @param from when should the ray start?
  115291. * @param to when should the ray end?
  115292. * @returns PhysicsRaycastResult
  115293. */
  115294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115295. }
  115296. }
  115297. declare module BABYLON {
  115298. interface AbstractScene {
  115299. /**
  115300. * The list of reflection probes added to the scene
  115301. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115302. */
  115303. reflectionProbes: Array<ReflectionProbe>;
  115304. /**
  115305. * Removes the given reflection probe from this scene.
  115306. * @param toRemove The reflection probe to remove
  115307. * @returns The index of the removed reflection probe
  115308. */
  115309. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115310. /**
  115311. * Adds the given reflection probe to this scene.
  115312. * @param newReflectionProbe The reflection probe to add
  115313. */
  115314. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115315. }
  115316. /**
  115317. * Class used to generate realtime reflection / refraction cube textures
  115318. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115319. */
  115320. export class ReflectionProbe {
  115321. /** defines the name of the probe */
  115322. name: string;
  115323. private _scene;
  115324. private _renderTargetTexture;
  115325. private _projectionMatrix;
  115326. private _viewMatrix;
  115327. private _target;
  115328. private _add;
  115329. private _attachedMesh;
  115330. private _invertYAxis;
  115331. /** Gets or sets probe position (center of the cube map) */
  115332. position: Vector3;
  115333. /**
  115334. * Creates a new reflection probe
  115335. * @param name defines the name of the probe
  115336. * @param size defines the texture resolution (for each face)
  115337. * @param scene defines the hosting scene
  115338. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115339. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115340. */
  115341. constructor(
  115342. /** defines the name of the probe */
  115343. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115344. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115345. samples: number;
  115346. /** Gets or sets the refresh rate to use (on every frame by default) */
  115347. refreshRate: number;
  115348. /**
  115349. * Gets the hosting scene
  115350. * @returns a Scene
  115351. */
  115352. getScene(): Scene;
  115353. /** Gets the internal CubeTexture used to render to */
  115354. readonly cubeTexture: RenderTargetTexture;
  115355. /** Gets the list of meshes to render */
  115356. readonly renderList: Nullable<AbstractMesh[]>;
  115357. /**
  115358. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115359. * @param mesh defines the mesh to attach to
  115360. */
  115361. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115362. /**
  115363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115364. * @param renderingGroupId The rendering group id corresponding to its index
  115365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115366. */
  115367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115368. /**
  115369. * Clean all associated resources
  115370. */
  115371. dispose(): void;
  115372. /**
  115373. * Converts the reflection probe information to a readable string for debug purpose.
  115374. * @param fullDetails Supports for multiple levels of logging within scene loading
  115375. * @returns the human readable reflection probe info
  115376. */
  115377. toString(fullDetails?: boolean): string;
  115378. /**
  115379. * Get the class name of the relfection probe.
  115380. * @returns "ReflectionProbe"
  115381. */
  115382. getClassName(): string;
  115383. /**
  115384. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115385. * @returns The JSON representation of the texture
  115386. */
  115387. serialize(): any;
  115388. /**
  115389. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115390. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115391. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115392. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115393. * @returns The parsed reflection probe if successful
  115394. */
  115395. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115396. }
  115397. }
  115398. declare module BABYLON {
  115399. /** @hidden */
  115400. export var _BabylonLoaderRegistered: boolean;
  115401. }
  115402. declare module BABYLON {
  115403. /**
  115404. * The Physically based simple base material of BJS.
  115405. *
  115406. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115407. * It is used as the base class for both the specGloss and metalRough conventions.
  115408. */
  115409. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115410. /**
  115411. * Number of Simultaneous lights allowed on the material.
  115412. */
  115413. maxSimultaneousLights: number;
  115414. /**
  115415. * If sets to true, disables all the lights affecting the material.
  115416. */
  115417. disableLighting: boolean;
  115418. /**
  115419. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115420. */
  115421. environmentTexture: BaseTexture;
  115422. /**
  115423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115424. */
  115425. invertNormalMapX: boolean;
  115426. /**
  115427. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115428. */
  115429. invertNormalMapY: boolean;
  115430. /**
  115431. * Normal map used in the model.
  115432. */
  115433. normalTexture: BaseTexture;
  115434. /**
  115435. * Emissivie color used to self-illuminate the model.
  115436. */
  115437. emissiveColor: Color3;
  115438. /**
  115439. * Emissivie texture used to self-illuminate the model.
  115440. */
  115441. emissiveTexture: BaseTexture;
  115442. /**
  115443. * Occlusion Channel Strenght.
  115444. */
  115445. occlusionStrength: number;
  115446. /**
  115447. * Occlusion Texture of the material (adding extra occlusion effects).
  115448. */
  115449. occlusionTexture: BaseTexture;
  115450. /**
  115451. * Defines the alpha limits in alpha test mode.
  115452. */
  115453. alphaCutOff: number;
  115454. /**
  115455. * Gets the current double sided mode.
  115456. */
  115457. /**
  115458. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115459. */
  115460. doubleSided: boolean;
  115461. /**
  115462. * Stores the pre-calculated light information of a mesh in a texture.
  115463. */
  115464. lightmapTexture: BaseTexture;
  115465. /**
  115466. * If true, the light map contains occlusion information instead of lighting info.
  115467. */
  115468. useLightmapAsShadowmap: boolean;
  115469. /**
  115470. * Instantiates a new PBRMaterial instance.
  115471. *
  115472. * @param name The material name
  115473. * @param scene The scene the material will be use in.
  115474. */
  115475. constructor(name: string, scene: Scene);
  115476. getClassName(): string;
  115477. }
  115478. }
  115479. declare module BABYLON {
  115480. /**
  115481. * The PBR material of BJS following the metal roughness convention.
  115482. *
  115483. * This fits to the PBR convention in the GLTF definition:
  115484. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115485. */
  115486. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115487. /**
  115488. * The base color has two different interpretations depending on the value of metalness.
  115489. * When the material is a metal, the base color is the specific measured reflectance value
  115490. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115491. * of the material.
  115492. */
  115493. baseColor: Color3;
  115494. /**
  115495. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115496. * well as opacity information in the alpha channel.
  115497. */
  115498. baseTexture: BaseTexture;
  115499. /**
  115500. * Specifies the metallic scalar value of the material.
  115501. * Can also be used to scale the metalness values of the metallic texture.
  115502. */
  115503. metallic: number;
  115504. /**
  115505. * Specifies the roughness scalar value of the material.
  115506. * Can also be used to scale the roughness values of the metallic texture.
  115507. */
  115508. roughness: number;
  115509. /**
  115510. * Texture containing both the metallic value in the B channel and the
  115511. * roughness value in the G channel to keep better precision.
  115512. */
  115513. metallicRoughnessTexture: BaseTexture;
  115514. /**
  115515. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115516. *
  115517. * @param name The material name
  115518. * @param scene The scene the material will be use in.
  115519. */
  115520. constructor(name: string, scene: Scene);
  115521. /**
  115522. * Return the currrent class name of the material.
  115523. */
  115524. getClassName(): string;
  115525. /**
  115526. * Makes a duplicate of the current material.
  115527. * @param name - name to use for the new material.
  115528. */
  115529. clone(name: string): PBRMetallicRoughnessMaterial;
  115530. /**
  115531. * Serialize the material to a parsable JSON object.
  115532. */
  115533. serialize(): any;
  115534. /**
  115535. * Parses a JSON object correponding to the serialize function.
  115536. */
  115537. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115538. }
  115539. }
  115540. declare module BABYLON {
  115541. /**
  115542. * The PBR material of BJS following the specular glossiness convention.
  115543. *
  115544. * This fits to the PBR convention in the GLTF definition:
  115545. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115546. */
  115547. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115548. /**
  115549. * Specifies the diffuse color of the material.
  115550. */
  115551. diffuseColor: Color3;
  115552. /**
  115553. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115554. * channel.
  115555. */
  115556. diffuseTexture: BaseTexture;
  115557. /**
  115558. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115559. */
  115560. specularColor: Color3;
  115561. /**
  115562. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115563. */
  115564. glossiness: number;
  115565. /**
  115566. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115567. */
  115568. specularGlossinessTexture: BaseTexture;
  115569. /**
  115570. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115571. *
  115572. * @param name The material name
  115573. * @param scene The scene the material will be use in.
  115574. */
  115575. constructor(name: string, scene: Scene);
  115576. /**
  115577. * Return the currrent class name of the material.
  115578. */
  115579. getClassName(): string;
  115580. /**
  115581. * Makes a duplicate of the current material.
  115582. * @param name - name to use for the new material.
  115583. */
  115584. clone(name: string): PBRSpecularGlossinessMaterial;
  115585. /**
  115586. * Serialize the material to a parsable JSON object.
  115587. */
  115588. serialize(): any;
  115589. /**
  115590. * Parses a JSON object correponding to the serialize function.
  115591. */
  115592. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115593. }
  115594. }
  115595. declare module BABYLON {
  115596. /**
  115597. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115598. * It can help converting any input color in a desired output one. This can then be used to create effects
  115599. * from sepia, black and white to sixties or futuristic rendering...
  115600. *
  115601. * The only supported format is currently 3dl.
  115602. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115603. */
  115604. export class ColorGradingTexture extends BaseTexture {
  115605. /**
  115606. * The current texture matrix. (will always be identity in color grading texture)
  115607. */
  115608. private _textureMatrix;
  115609. /**
  115610. * The texture URL.
  115611. */
  115612. url: string;
  115613. /**
  115614. * Empty line regex stored for GC.
  115615. */
  115616. private static _noneEmptyLineRegex;
  115617. private _engine;
  115618. /**
  115619. * Instantiates a ColorGradingTexture from the following parameters.
  115620. *
  115621. * @param url The location of the color gradind data (currently only supporting 3dl)
  115622. * @param scene The scene the texture will be used in
  115623. */
  115624. constructor(url: string, scene: Scene);
  115625. /**
  115626. * Returns the texture matrix used in most of the material.
  115627. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115628. */
  115629. getTextureMatrix(): Matrix;
  115630. /**
  115631. * Occurs when the file being loaded is a .3dl LUT file.
  115632. */
  115633. private load3dlTexture;
  115634. /**
  115635. * Starts the loading process of the texture.
  115636. */
  115637. private loadTexture;
  115638. /**
  115639. * Clones the color gradind texture.
  115640. */
  115641. clone(): ColorGradingTexture;
  115642. /**
  115643. * Called during delayed load for textures.
  115644. */
  115645. delayLoad(): void;
  115646. /**
  115647. * Parses a color grading texture serialized by Babylon.
  115648. * @param parsedTexture The texture information being parsedTexture
  115649. * @param scene The scene to load the texture in
  115650. * @param rootUrl The root url of the data assets to load
  115651. * @return A color gradind texture
  115652. */
  115653. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115654. /**
  115655. * Serializes the LUT texture to json format.
  115656. */
  115657. serialize(): any;
  115658. }
  115659. }
  115660. declare module BABYLON {
  115661. /**
  115662. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115663. */
  115664. export class EquiRectangularCubeTexture extends BaseTexture {
  115665. /** The six faces of the cube. */
  115666. private static _FacesMapping;
  115667. private _noMipmap;
  115668. private _onLoad;
  115669. private _onError;
  115670. /** The size of the cubemap. */
  115671. private _size;
  115672. /** The buffer of the image. */
  115673. private _buffer;
  115674. /** The width of the input image. */
  115675. private _width;
  115676. /** The height of the input image. */
  115677. private _height;
  115678. /** The URL to the image. */
  115679. url: string;
  115680. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115681. coordinatesMode: number;
  115682. /**
  115683. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115684. * @param url The location of the image
  115685. * @param scene The scene the texture will be used in
  115686. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115687. * @param noMipmap Forces to not generate the mipmap if true
  115688. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115689. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115690. * @param onLoad — defines a callback called when texture is loaded
  115691. * @param onError — defines a callback called if there is an error
  115692. */
  115693. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115694. /**
  115695. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115696. */
  115697. private loadImage;
  115698. /**
  115699. * Convert the image buffer into a cubemap and create a CubeTexture.
  115700. */
  115701. private loadTexture;
  115702. /**
  115703. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115704. * @param buffer The ArrayBuffer that should be converted.
  115705. * @returns The buffer as Float32Array.
  115706. */
  115707. private getFloat32ArrayFromArrayBuffer;
  115708. /**
  115709. * Get the current class name of the texture useful for serialization or dynamic coding.
  115710. * @returns "EquiRectangularCubeTexture"
  115711. */
  115712. getClassName(): string;
  115713. /**
  115714. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115715. * @returns A clone of the current EquiRectangularCubeTexture.
  115716. */
  115717. clone(): EquiRectangularCubeTexture;
  115718. }
  115719. }
  115720. declare module BABYLON {
  115721. /**
  115722. * Based on jsTGALoader - Javascript loader for TGA file
  115723. * By Vincent Thibault
  115724. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115725. */
  115726. export class TGATools {
  115727. private static _TYPE_INDEXED;
  115728. private static _TYPE_RGB;
  115729. private static _TYPE_GREY;
  115730. private static _TYPE_RLE_INDEXED;
  115731. private static _TYPE_RLE_RGB;
  115732. private static _TYPE_RLE_GREY;
  115733. private static _ORIGIN_MASK;
  115734. private static _ORIGIN_SHIFT;
  115735. private static _ORIGIN_BL;
  115736. private static _ORIGIN_BR;
  115737. private static _ORIGIN_UL;
  115738. private static _ORIGIN_UR;
  115739. /**
  115740. * Gets the header of a TGA file
  115741. * @param data defines the TGA data
  115742. * @returns the header
  115743. */
  115744. static GetTGAHeader(data: Uint8Array): any;
  115745. /**
  115746. * Uploads TGA content to a Babylon Texture
  115747. * @hidden
  115748. */
  115749. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115750. /** @hidden */
  115751. 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;
  115752. /** @hidden */
  115753. 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;
  115754. /** @hidden */
  115755. 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;
  115756. /** @hidden */
  115757. 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;
  115758. /** @hidden */
  115759. 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;
  115760. /** @hidden */
  115761. 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;
  115762. }
  115763. }
  115764. declare module BABYLON {
  115765. /**
  115766. * Implementation of the TGA Texture Loader.
  115767. * @hidden
  115768. */
  115769. export class _TGATextureLoader implements IInternalTextureLoader {
  115770. /**
  115771. * Defines wether the loader supports cascade loading the different faces.
  115772. */
  115773. readonly supportCascades: boolean;
  115774. /**
  115775. * This returns if the loader support the current file information.
  115776. * @param extension defines the file extension of the file being loaded
  115777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115778. * @param fallback defines the fallback internal texture if any
  115779. * @param isBase64 defines whether the texture is encoded as a base64
  115780. * @param isBuffer defines whether the texture data are stored as a buffer
  115781. * @returns true if the loader can load the specified file
  115782. */
  115783. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115784. /**
  115785. * Transform the url before loading if required.
  115786. * @param rootUrl the url of the texture
  115787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115788. * @returns the transformed texture
  115789. */
  115790. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115791. /**
  115792. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115793. * @param rootUrl the url of the texture
  115794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115795. * @returns the fallback texture
  115796. */
  115797. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115798. /**
  115799. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115800. * @param data contains the texture data
  115801. * @param texture defines the BabylonJS internal texture
  115802. * @param createPolynomials will be true if polynomials have been requested
  115803. * @param onLoad defines the callback to trigger once the texture is ready
  115804. * @param onError defines the callback to trigger in case of error
  115805. */
  115806. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115807. /**
  115808. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115809. * @param data contains the texture data
  115810. * @param texture defines the BabylonJS internal texture
  115811. * @param callback defines the method to call once ready to upload
  115812. */
  115813. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115814. }
  115815. }
  115816. declare module BABYLON {
  115817. /**
  115818. * Info about the .basis files
  115819. */
  115820. class BasisFileInfo {
  115821. /**
  115822. * If the file has alpha
  115823. */
  115824. hasAlpha: boolean;
  115825. /**
  115826. * Info about each image of the basis file
  115827. */
  115828. images: Array<{
  115829. levels: Array<{
  115830. width: number;
  115831. height: number;
  115832. transcodedPixels: ArrayBufferView;
  115833. }>;
  115834. }>;
  115835. }
  115836. /**
  115837. * Result of transcoding a basis file
  115838. */
  115839. class TranscodeResult {
  115840. /**
  115841. * Info about the .basis file
  115842. */
  115843. fileInfo: BasisFileInfo;
  115844. /**
  115845. * Format to use when loading the file
  115846. */
  115847. format: number;
  115848. }
  115849. /**
  115850. * Configuration options for the Basis transcoder
  115851. */
  115852. export class BasisTranscodeConfiguration {
  115853. /**
  115854. * Supported compression formats used to determine the supported output format of the transcoder
  115855. */
  115856. supportedCompressionFormats?: {
  115857. /**
  115858. * etc1 compression format
  115859. */
  115860. etc1?: boolean;
  115861. /**
  115862. * s3tc compression format
  115863. */
  115864. s3tc?: boolean;
  115865. /**
  115866. * pvrtc compression format
  115867. */
  115868. pvrtc?: boolean;
  115869. /**
  115870. * etc2 compression format
  115871. */
  115872. etc2?: boolean;
  115873. };
  115874. /**
  115875. * If mipmap levels should be loaded for transcoded images (Default: true)
  115876. */
  115877. loadMipmapLevels?: boolean;
  115878. /**
  115879. * Index of a single image to load (Default: all images)
  115880. */
  115881. loadSingleImage?: number;
  115882. }
  115883. /**
  115884. * Used to load .Basis files
  115885. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115886. */
  115887. export class BasisTools {
  115888. private static _IgnoreSupportedFormats;
  115889. /**
  115890. * URL to use when loading the basis transcoder
  115891. */
  115892. static JSModuleURL: string;
  115893. /**
  115894. * URL to use when loading the wasm module for the transcoder
  115895. */
  115896. static WasmModuleURL: string;
  115897. /**
  115898. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115899. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115900. * @returns internal format corresponding to the Basis format
  115901. */
  115902. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115903. private static _WorkerPromise;
  115904. private static _Worker;
  115905. private static _actionId;
  115906. private static _CreateWorkerAsync;
  115907. /**
  115908. * Transcodes a loaded image file to compressed pixel data
  115909. * @param imageData image data to transcode
  115910. * @param config configuration options for the transcoding
  115911. * @returns a promise resulting in the transcoded image
  115912. */
  115913. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115914. /**
  115915. * Loads a texture from the transcode result
  115916. * @param texture texture load to
  115917. * @param transcodeResult the result of transcoding the basis file to load from
  115918. */
  115919. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115920. }
  115921. }
  115922. declare module BABYLON {
  115923. /**
  115924. * Loader for .basis file format
  115925. */
  115926. export class _BasisTextureLoader implements IInternalTextureLoader {
  115927. /**
  115928. * Defines whether the loader supports cascade loading the different faces.
  115929. */
  115930. readonly supportCascades: boolean;
  115931. /**
  115932. * This returns if the loader support the current file information.
  115933. * @param extension defines the file extension of the file being loaded
  115934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115935. * @param fallback defines the fallback internal texture if any
  115936. * @param isBase64 defines whether the texture is encoded as a base64
  115937. * @param isBuffer defines whether the texture data are stored as a buffer
  115938. * @returns true if the loader can load the specified file
  115939. */
  115940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115941. /**
  115942. * Transform the url before loading if required.
  115943. * @param rootUrl the url of the texture
  115944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115945. * @returns the transformed texture
  115946. */
  115947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115948. /**
  115949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115950. * @param rootUrl the url of the texture
  115951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115952. * @returns the fallback texture
  115953. */
  115954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115955. /**
  115956. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115957. * @param data contains the texture data
  115958. * @param texture defines the BabylonJS internal texture
  115959. * @param createPolynomials will be true if polynomials have been requested
  115960. * @param onLoad defines the callback to trigger once the texture is ready
  115961. * @param onError defines the callback to trigger in case of error
  115962. */
  115963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115964. /**
  115965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115966. * @param data contains the texture data
  115967. * @param texture defines the BabylonJS internal texture
  115968. * @param callback defines the method to call once ready to upload
  115969. */
  115970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115971. }
  115972. }
  115973. declare module BABYLON {
  115974. /**
  115975. * 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.
  115976. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115977. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115978. */
  115979. export class CustomProceduralTexture extends ProceduralTexture {
  115980. private _animate;
  115981. private _time;
  115982. private _config;
  115983. private _texturePath;
  115984. /**
  115985. * Instantiates a new Custom Procedural Texture.
  115986. * 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.
  115987. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115988. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115989. * @param name Define the name of the texture
  115990. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115991. * @param size Define the size of the texture to create
  115992. * @param scene Define the scene the texture belongs to
  115993. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115994. * @param generateMipMaps Define if the texture should creates mip maps or not
  115995. */
  115996. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115997. private _loadJson;
  115998. /**
  115999. * Is the texture ready to be used ? (rendered at least once)
  116000. * @returns true if ready, otherwise, false.
  116001. */
  116002. isReady(): boolean;
  116003. /**
  116004. * Render the texture to its associated render target.
  116005. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  116006. */
  116007. render(useCameraPostProcess?: boolean): void;
  116008. /**
  116009. * Update the list of dependant textures samplers in the shader.
  116010. */
  116011. updateTextures(): void;
  116012. /**
  116013. * Update the uniform values of the procedural texture in the shader.
  116014. */
  116015. updateShaderUniforms(): void;
  116016. /**
  116017. * Define if the texture animates or not.
  116018. */
  116019. animate: boolean;
  116020. }
  116021. }
  116022. declare module BABYLON {
  116023. /** @hidden */
  116024. export var noisePixelShader: {
  116025. name: string;
  116026. shader: string;
  116027. };
  116028. }
  116029. declare module BABYLON {
  116030. /**
  116031. * Class used to generate noise procedural textures
  116032. */
  116033. export class NoiseProceduralTexture extends ProceduralTexture {
  116034. private _time;
  116035. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  116036. brightness: number;
  116037. /** Defines the number of octaves to process */
  116038. octaves: number;
  116039. /** Defines the level of persistence (0.8 by default) */
  116040. persistence: number;
  116041. /** Gets or sets animation speed factor (default is 1) */
  116042. animationSpeedFactor: number;
  116043. /**
  116044. * Creates a new NoiseProceduralTexture
  116045. * @param name defines the name fo the texture
  116046. * @param size defines the size of the texture (default is 256)
  116047. * @param scene defines the hosting scene
  116048. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  116049. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  116050. */
  116051. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116052. private _updateShaderUniforms;
  116053. protected _getDefines(): string;
  116054. /** Generate the current state of the procedural texture */
  116055. render(useCameraPostProcess?: boolean): void;
  116056. /**
  116057. * Serializes this noise procedural texture
  116058. * @returns a serialized noise procedural texture object
  116059. */
  116060. serialize(): any;
  116061. /**
  116062. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  116063. * @param parsedTexture defines parsed texture data
  116064. * @param scene defines the current scene
  116065. * @param rootUrl defines the root URL containing noise procedural texture information
  116066. * @returns a parsed NoiseProceduralTexture
  116067. */
  116068. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  116069. }
  116070. }
  116071. declare module BABYLON {
  116072. /**
  116073. * Raw cube texture where the raw buffers are passed in
  116074. */
  116075. export class RawCubeTexture extends CubeTexture {
  116076. /**
  116077. * Creates a cube texture where the raw buffers are passed in.
  116078. * @param scene defines the scene the texture is attached to
  116079. * @param data defines the array of data to use to create each face
  116080. * @param size defines the size of the textures
  116081. * @param format defines the format of the data
  116082. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  116083. * @param generateMipMaps defines if the engine should generate the mip levels
  116084. * @param invertY defines if data must be stored with Y axis inverted
  116085. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  116086. * @param compression defines the compression used (null by default)
  116087. */
  116088. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  116089. /**
  116090. * Updates the raw cube texture.
  116091. * @param data defines the data to store
  116092. * @param format defines the data format
  116093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  116094. * @param invertY defines if data must be stored with Y axis inverted
  116095. * @param compression defines the compression used (null by default)
  116096. * @param level defines which level of the texture to update
  116097. */
  116098. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  116099. /**
  116100. * Updates a raw cube texture with RGBD encoded data.
  116101. * @param data defines the array of data [mipmap][face] to use to create each face
  116102. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  116103. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116104. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116105. * @returns a promsie that resolves when the operation is complete
  116106. */
  116107. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  116108. /**
  116109. * Clones the raw cube texture.
  116110. * @return a new cube texture
  116111. */
  116112. clone(): CubeTexture;
  116113. /** @hidden */
  116114. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116115. }
  116116. }
  116117. declare module BABYLON {
  116118. /**
  116119. * Class used to store 3D textures containing user data
  116120. */
  116121. export class RawTexture3D extends Texture {
  116122. /** Gets or sets the texture format to use */
  116123. format: number;
  116124. private _engine;
  116125. /**
  116126. * Create a new RawTexture3D
  116127. * @param data defines the data of the texture
  116128. * @param width defines the width of the texture
  116129. * @param height defines the height of the texture
  116130. * @param depth defines the depth of the texture
  116131. * @param format defines the texture format to use
  116132. * @param scene defines the hosting scene
  116133. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  116134. * @param invertY defines if texture must be stored with Y axis inverted
  116135. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  116136. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  116137. */
  116138. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  116139. /** Gets or sets the texture format to use */
  116140. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  116141. /**
  116142. * Update the texture with new data
  116143. * @param data defines the data to store in the texture
  116144. */
  116145. update(data: ArrayBufferView): void;
  116146. }
  116147. }
  116148. declare module BABYLON {
  116149. /**
  116150. * Creates a refraction texture used by refraction channel of the standard material.
  116151. * It is like a mirror but to see through a material.
  116152. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116153. */
  116154. export class RefractionTexture extends RenderTargetTexture {
  116155. /**
  116156. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  116157. * 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.
  116158. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116159. */
  116160. refractionPlane: Plane;
  116161. /**
  116162. * Define how deep under the surface we should see.
  116163. */
  116164. depth: number;
  116165. /**
  116166. * Creates a refraction texture used by refraction channel of the standard material.
  116167. * It is like a mirror but to see through a material.
  116168. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116169. * @param name Define the texture name
  116170. * @param size Define the size of the underlying texture
  116171. * @param scene Define the scene the refraction belongs to
  116172. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116173. */
  116174. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116175. /**
  116176. * Clone the refraction texture.
  116177. * @returns the cloned texture
  116178. */
  116179. clone(): RefractionTexture;
  116180. /**
  116181. * Serialize the texture to a JSON representation you could use in Parse later on
  116182. * @returns the serialized JSON representation
  116183. */
  116184. serialize(): any;
  116185. }
  116186. }
  116187. declare module BABYLON {
  116188. /**
  116189. * Defines the options related to the creation of an HtmlElementTexture
  116190. */
  116191. export interface IHtmlElementTextureOptions {
  116192. /**
  116193. * Defines wether mip maps should be created or not.
  116194. */
  116195. generateMipMaps?: boolean;
  116196. /**
  116197. * Defines the sampling mode of the texture.
  116198. */
  116199. samplingMode?: number;
  116200. /**
  116201. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116202. */
  116203. engine: Nullable<Engine>;
  116204. /**
  116205. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116206. */
  116207. scene: Nullable<Scene>;
  116208. }
  116209. /**
  116210. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116211. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116212. * is automatically managed.
  116213. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116214. * in your application.
  116215. *
  116216. * As the update is not automatic, you need to call them manually.
  116217. */
  116218. export class HtmlElementTexture extends BaseTexture {
  116219. /**
  116220. * The texture URL.
  116221. */
  116222. element: HTMLVideoElement | HTMLCanvasElement;
  116223. private static readonly DefaultOptions;
  116224. private _textureMatrix;
  116225. private _engine;
  116226. private _isVideo;
  116227. private _generateMipMaps;
  116228. private _samplingMode;
  116229. /**
  116230. * Instantiates a HtmlElementTexture from the following parameters.
  116231. *
  116232. * @param name Defines the name of the texture
  116233. * @param element Defines the video or canvas the texture is filled with
  116234. * @param options Defines the other none mandatory texture creation options
  116235. */
  116236. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116237. private _createInternalTexture;
  116238. /**
  116239. * Returns the texture matrix used in most of the material.
  116240. */
  116241. getTextureMatrix(): Matrix;
  116242. /**
  116243. * Updates the content of the texture.
  116244. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116245. */
  116246. update(invertY?: Nullable<boolean>): void;
  116247. }
  116248. }
  116249. declare module BABYLON {
  116250. /**
  116251. * Enum used to define the target of a block
  116252. */
  116253. export enum NodeMaterialBlockTargets {
  116254. /** Vertex shader */
  116255. Vertex = 1,
  116256. /** Fragment shader */
  116257. Fragment = 2,
  116258. /** Neutral */
  116259. Neutral = 4,
  116260. /** Vertex and Fragment */
  116261. VertexAndFragment = 3
  116262. }
  116263. }
  116264. declare module BABYLON {
  116265. /**
  116266. * Defines the kind of connection point for node based material
  116267. */
  116268. export enum NodeMaterialBlockConnectionPointTypes {
  116269. /** Float */
  116270. Float = 1,
  116271. /** Int */
  116272. Int = 2,
  116273. /** Vector2 */
  116274. Vector2 = 4,
  116275. /** Vector3 */
  116276. Vector3 = 8,
  116277. /** Vector4 */
  116278. Vector4 = 16,
  116279. /** Color3 */
  116280. Color3 = 32,
  116281. /** Color4 */
  116282. Color4 = 64,
  116283. /** Matrix */
  116284. Matrix = 128,
  116285. /** Detect type based on connection */
  116286. AutoDetect = 1024,
  116287. /** Output type that will be defined by input type */
  116288. BasedOnInput = 2048
  116289. }
  116290. }
  116291. declare module BABYLON {
  116292. /**
  116293. * Root class for all node material optimizers
  116294. */
  116295. export class NodeMaterialOptimizer {
  116296. /**
  116297. * Function used to optimize a NodeMaterial graph
  116298. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116299. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116300. */
  116301. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116302. }
  116303. }
  116304. declare module BABYLON {
  116305. /**
  116306. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116307. */
  116308. export class TransformBlock extends NodeMaterialBlock {
  116309. /**
  116310. * Defines the value to use to complement W value to transform it to a Vector4
  116311. */
  116312. complementW: number;
  116313. /**
  116314. * Defines the value to use to complement z value to transform it to a Vector4
  116315. */
  116316. complementZ: number;
  116317. /**
  116318. * Creates a new TransformBlock
  116319. * @param name defines the block name
  116320. */
  116321. constructor(name: string);
  116322. /**
  116323. * Gets the current class name
  116324. * @returns the class name
  116325. */
  116326. getClassName(): string;
  116327. /**
  116328. * Gets the vector input
  116329. */
  116330. readonly vector: NodeMaterialConnectionPoint;
  116331. /**
  116332. * Gets the output component
  116333. */
  116334. readonly output: NodeMaterialConnectionPoint;
  116335. /**
  116336. * Gets the matrix transform input
  116337. */
  116338. readonly transform: NodeMaterialConnectionPoint;
  116339. protected _buildBlock(state: NodeMaterialBuildState): this;
  116340. serialize(): any;
  116341. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116342. }
  116343. }
  116344. declare module BABYLON {
  116345. /**
  116346. * Block used to output the vertex position
  116347. */
  116348. export class VertexOutputBlock extends NodeMaterialBlock {
  116349. /**
  116350. * Creates a new VertexOutputBlock
  116351. * @param name defines the block name
  116352. */
  116353. constructor(name: string);
  116354. /**
  116355. * Gets the current class name
  116356. * @returns the class name
  116357. */
  116358. getClassName(): string;
  116359. /**
  116360. * Gets the vector input component
  116361. */
  116362. readonly vector: NodeMaterialConnectionPoint;
  116363. protected _buildBlock(state: NodeMaterialBuildState): this;
  116364. }
  116365. }
  116366. declare module BABYLON {
  116367. /**
  116368. * Block used to output the final color
  116369. */
  116370. export class FragmentOutputBlock extends NodeMaterialBlock {
  116371. /**
  116372. * Create a new FragmentOutputBlock
  116373. * @param name defines the block name
  116374. */
  116375. constructor(name: string);
  116376. /**
  116377. * Gets the current class name
  116378. * @returns the class name
  116379. */
  116380. getClassName(): string;
  116381. /**
  116382. * Gets the rgba input component
  116383. */
  116384. readonly rgba: NodeMaterialConnectionPoint;
  116385. /**
  116386. * Gets the rgb input component
  116387. */
  116388. readonly rgb: NodeMaterialConnectionPoint;
  116389. /**
  116390. * Gets the a input component
  116391. */
  116392. readonly a: NodeMaterialConnectionPoint;
  116393. protected _buildBlock(state: NodeMaterialBuildState): this;
  116394. }
  116395. }
  116396. declare module BABYLON {
  116397. /**
  116398. * Interface used to configure the node material editor
  116399. */
  116400. export interface INodeMaterialEditorOptions {
  116401. /** Define the URl to load node editor script */
  116402. editorURL?: string;
  116403. }
  116404. /** @hidden */
  116405. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116406. /** BONES */
  116407. NUM_BONE_INFLUENCERS: number;
  116408. BonesPerMesh: number;
  116409. BONETEXTURE: boolean;
  116410. /** MORPH TARGETS */
  116411. MORPHTARGETS: boolean;
  116412. MORPHTARGETS_NORMAL: boolean;
  116413. MORPHTARGETS_TANGENT: boolean;
  116414. MORPHTARGETS_UV: boolean;
  116415. NUM_MORPH_INFLUENCERS: number;
  116416. /** IMAGE PROCESSING */
  116417. IMAGEPROCESSING: boolean;
  116418. VIGNETTE: boolean;
  116419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116420. VIGNETTEBLENDMODEOPAQUE: boolean;
  116421. TONEMAPPING: boolean;
  116422. TONEMAPPING_ACES: boolean;
  116423. CONTRAST: boolean;
  116424. EXPOSURE: boolean;
  116425. COLORCURVES: boolean;
  116426. COLORGRADING: boolean;
  116427. COLORGRADING3D: boolean;
  116428. SAMPLER3DGREENDEPTH: boolean;
  116429. SAMPLER3DBGRMAP: boolean;
  116430. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116431. constructor();
  116432. setValue(name: string, value: boolean): void;
  116433. }
  116434. /**
  116435. * Class used to configure NodeMaterial
  116436. */
  116437. export interface INodeMaterialOptions {
  116438. /**
  116439. * Defines if blocks should emit comments
  116440. */
  116441. emitComments: boolean;
  116442. }
  116443. /**
  116444. * Class used to create a node based material built by assembling shader blocks
  116445. */
  116446. export class NodeMaterial extends PushMaterial {
  116447. private static _BuildIdGenerator;
  116448. private _options;
  116449. private _vertexCompilationState;
  116450. private _fragmentCompilationState;
  116451. private _sharedData;
  116452. private _buildId;
  116453. private _buildWasSuccessful;
  116454. private _cachedWorldViewMatrix;
  116455. private _cachedWorldViewProjectionMatrix;
  116456. private _optimizers;
  116457. private _animationFrame;
  116458. /** Define the URl to load node editor script */
  116459. static EditorURL: string;
  116460. private BJSNODEMATERIALEDITOR;
  116461. /** Get the inspector from bundle or global */
  116462. private _getGlobalNodeMaterialEditor;
  116463. /**
  116464. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  116465. */
  116466. ignoreAlpha: boolean;
  116467. /**
  116468. * Defines the maximum number of lights that can be used in the material
  116469. */
  116470. maxSimultaneousLights: number;
  116471. /**
  116472. * Observable raised when the material is built
  116473. */
  116474. onBuildObservable: Observable<NodeMaterial>;
  116475. /**
  116476. * Gets or sets the root nodes of the material vertex shader
  116477. */
  116478. _vertexOutputNodes: NodeMaterialBlock[];
  116479. /**
  116480. * Gets or sets the root nodes of the material fragment (pixel) shader
  116481. */
  116482. _fragmentOutputNodes: NodeMaterialBlock[];
  116483. /** Gets or sets options to control the node material overall behavior */
  116484. options: INodeMaterialOptions;
  116485. /**
  116486. * Default configuration related to image processing available in the standard Material.
  116487. */
  116488. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116489. /**
  116490. * Gets the image processing configuration used either in this material.
  116491. */
  116492. /**
  116493. * Sets the Default image processing configuration used either in the this material.
  116494. *
  116495. * If sets to null, the scene one is in use.
  116496. */
  116497. imageProcessingConfiguration: ImageProcessingConfiguration;
  116498. /**
  116499. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116500. */
  116501. attachedBlocks: NodeMaterialBlock[];
  116502. /**
  116503. * Create a new node based material
  116504. * @param name defines the material name
  116505. * @param scene defines the hosting scene
  116506. * @param options defines creation option
  116507. */
  116508. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116509. /**
  116510. * Gets the current class name of the material e.g. "NodeMaterial"
  116511. * @returns the class name
  116512. */
  116513. getClassName(): string;
  116514. /**
  116515. * Keep track of the image processing observer to allow dispose and replace.
  116516. */
  116517. private _imageProcessingObserver;
  116518. /**
  116519. * Attaches a new image processing configuration to the Standard Material.
  116520. * @param configuration
  116521. */
  116522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116523. /**
  116524. * Get a block by its name
  116525. * @param name defines the name of the block to retrieve
  116526. * @returns the required block or null if not found
  116527. */
  116528. getBlockByName(name: string): NodeMaterialBlock | null;
  116529. /**
  116530. * Gets the list of input blocks attached to this material
  116531. * @returns an array of InputBlocks
  116532. */
  116533. getInputBlocks(): InputBlock[];
  116534. /**
  116535. * Adds a new optimizer to the list of optimizers
  116536. * @param optimizer defines the optimizers to add
  116537. * @returns the current material
  116538. */
  116539. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116540. /**
  116541. * Remove an optimizer from the list of optimizers
  116542. * @param optimizer defines the optimizers to remove
  116543. * @returns the current material
  116544. */
  116545. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116546. /**
  116547. * Add a new block to the list of output nodes
  116548. * @param node defines the node to add
  116549. * @returns the current material
  116550. */
  116551. addOutputNode(node: NodeMaterialBlock): this;
  116552. /**
  116553. * Remove a block from the list of root nodes
  116554. * @param node defines the node to remove
  116555. * @returns the current material
  116556. */
  116557. removeOutputNode(node: NodeMaterialBlock): this;
  116558. private _addVertexOutputNode;
  116559. private _removeVertexOutputNode;
  116560. private _addFragmentOutputNode;
  116561. private _removeFragmentOutputNode;
  116562. /**
  116563. * Specifies if the material will require alpha blending
  116564. * @returns a boolean specifying if alpha blending is needed
  116565. */
  116566. needAlphaBlending(): boolean;
  116567. /**
  116568. * Specifies if this material should be rendered in alpha test mode
  116569. * @returns a boolean specifying if an alpha test is needed.
  116570. */
  116571. needAlphaTesting(): boolean;
  116572. private _initializeBlock;
  116573. private _resetDualBlocks;
  116574. /**
  116575. * Build the material and generates the inner effect
  116576. * @param verbose defines if the build should log activity
  116577. */
  116578. build(verbose?: boolean): void;
  116579. /**
  116580. * Runs an otpimization phase to try to improve the shader code
  116581. */
  116582. optimize(): void;
  116583. private _prepareDefinesForAttributes;
  116584. /**
  116585. * Get if the submesh is ready to be used and all its information available.
  116586. * Child classes can use it to update shaders
  116587. * @param mesh defines the mesh to check
  116588. * @param subMesh defines which submesh to check
  116589. * @param useInstances specifies that instances should be used
  116590. * @returns a boolean indicating that the submesh is ready or not
  116591. */
  116592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116593. /**
  116594. * Get a string representing the shaders built by the current node graph
  116595. */
  116596. readonly compiledShaders: string;
  116597. /**
  116598. * Binds the world matrix to the material
  116599. * @param world defines the world transformation matrix
  116600. */
  116601. bindOnlyWorldMatrix(world: Matrix): void;
  116602. /**
  116603. * Binds the submesh to this material by preparing the effect and shader to draw
  116604. * @param world defines the world transformation matrix
  116605. * @param mesh defines the mesh containing the submesh
  116606. * @param subMesh defines the submesh to bind the material to
  116607. */
  116608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116609. /**
  116610. * Gets the active textures from the material
  116611. * @returns an array of textures
  116612. */
  116613. getActiveTextures(): BaseTexture[];
  116614. /**
  116615. * Specifies if the material uses a texture
  116616. * @param texture defines the texture to check against the material
  116617. * @returns a boolean specifying if the material uses the texture
  116618. */
  116619. hasTexture(texture: BaseTexture): boolean;
  116620. /**
  116621. * Disposes the material
  116622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116624. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116625. */
  116626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116627. /** Creates the node editor window. */
  116628. private _createNodeEditor;
  116629. /**
  116630. * Launch the node material editor
  116631. * @param config Define the configuration of the editor
  116632. * @return a promise fulfilled when the node editor is visible
  116633. */
  116634. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116635. /**
  116636. * Clear the current material
  116637. */
  116638. clear(): void;
  116639. /**
  116640. * Clear the current material and set it to a default state
  116641. */
  116642. setToDefault(): void;
  116643. private _gatherBlocks;
  116644. /**
  116645. * Serializes this material in a JSON representation
  116646. * @returns the serialized material object
  116647. */
  116648. serialize(): any;
  116649. /**
  116650. * Clear the current graph and load a new one from a serialization object
  116651. * @param source defines the JSON representation of the material
  116652. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116653. */
  116654. loadFromSerialization(source: any, rootUrl?: string): void;
  116655. /**
  116656. * Creates a node material from parsed material data
  116657. * @param source defines the JSON representation of the material
  116658. * @param scene defines the hosting scene
  116659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116660. * @returns a new node material
  116661. */
  116662. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116663. /**
  116664. * Creates a new node material set to default basic configuration
  116665. * @param name defines the name of the material
  116666. * @param scene defines the hosting scene
  116667. * @returns a new NodeMaterial
  116668. */
  116669. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  116670. }
  116671. }
  116672. declare module BABYLON {
  116673. /**
  116674. * Block used to read a texture from a sampler
  116675. */
  116676. export class TextureBlock extends NodeMaterialBlock {
  116677. private _defineName;
  116678. private _samplerName;
  116679. private _transformedUVName;
  116680. private _textureTransformName;
  116681. private _textureInfoName;
  116682. private _mainUVName;
  116683. private _mainUVDefineName;
  116684. /**
  116685. * Gets or sets the texture associated with the node
  116686. */
  116687. texture: Nullable<BaseTexture>;
  116688. /**
  116689. * Create a new TextureBlock
  116690. * @param name defines the block name
  116691. */
  116692. constructor(name: string);
  116693. /**
  116694. * Gets the current class name
  116695. * @returns the class name
  116696. */
  116697. getClassName(): string;
  116698. /**
  116699. * Gets the uv input component
  116700. */
  116701. readonly uv: NodeMaterialConnectionPoint;
  116702. /**
  116703. * Gets the rgba output component
  116704. */
  116705. readonly rgba: NodeMaterialConnectionPoint;
  116706. /**
  116707. * Gets the rgb output component
  116708. */
  116709. readonly rgb: NodeMaterialConnectionPoint;
  116710. /**
  116711. * Gets the r output component
  116712. */
  116713. readonly r: NodeMaterialConnectionPoint;
  116714. /**
  116715. * Gets the g output component
  116716. */
  116717. readonly g: NodeMaterialConnectionPoint;
  116718. /**
  116719. * Gets the b output component
  116720. */
  116721. readonly b: NodeMaterialConnectionPoint;
  116722. /**
  116723. * Gets the a output component
  116724. */
  116725. readonly a: NodeMaterialConnectionPoint;
  116726. autoConfigure(): void;
  116727. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116729. isReady(): boolean;
  116730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116731. private _injectVertexCode;
  116732. private _writeOutput;
  116733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116734. serialize(): any;
  116735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116736. }
  116737. }
  116738. declare module BABYLON {
  116739. /**
  116740. * Enum used to define well known values e.g. values automatically provided by the system
  116741. */
  116742. export enum NodeMaterialWellKnownValues {
  116743. /** World */
  116744. World = 1,
  116745. /** View */
  116746. View = 2,
  116747. /** Projection */
  116748. Projection = 3,
  116749. /** ViewProjection */
  116750. ViewProjection = 4,
  116751. /** WorldView */
  116752. WorldView = 5,
  116753. /** WorldViewProjection */
  116754. WorldViewProjection = 6,
  116755. /** CameraPosition */
  116756. CameraPosition = 7,
  116757. /** Fog Color */
  116758. FogColor = 8
  116759. }
  116760. }
  116761. declare module BABYLON {
  116762. /**
  116763. * Block used to read a reflection texture from a sampler
  116764. */
  116765. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116766. private _define3DName;
  116767. private _defineCubicName;
  116768. private _defineExplicitName;
  116769. private _defineProjectionName;
  116770. private _defineLocalCubicName;
  116771. private _defineSphericalName;
  116772. private _definePlanarName;
  116773. private _defineEquirectangularName;
  116774. private _defineMirroredEquirectangularFixedName;
  116775. private _defineEquirectangularFixedName;
  116776. private _defineSkyboxName;
  116777. private _cubeSamplerName;
  116778. private _2DSamplerName;
  116779. private _positionUVWName;
  116780. private _directionWName;
  116781. private _reflectionCoordsName;
  116782. private _reflection2DCoordsName;
  116783. private _reflectionColorName;
  116784. private _reflectionMatrixName;
  116785. /**
  116786. * Gets or sets the texture associated with the node
  116787. */
  116788. texture: Nullable<BaseTexture>;
  116789. /**
  116790. * Create a new TextureBlock
  116791. * @param name defines the block name
  116792. */
  116793. constructor(name: string);
  116794. /**
  116795. * Gets the current class name
  116796. * @returns the class name
  116797. */
  116798. getClassName(): string;
  116799. /**
  116800. * Gets the world position input component
  116801. */
  116802. readonly position: NodeMaterialConnectionPoint;
  116803. /**
  116804. * Gets the world position input component
  116805. */
  116806. readonly worldPosition: NodeMaterialConnectionPoint;
  116807. /**
  116808. * Gets the world normal input component
  116809. */
  116810. readonly worldNormal: NodeMaterialConnectionPoint;
  116811. /**
  116812. * Gets the world input component
  116813. */
  116814. readonly world: NodeMaterialConnectionPoint;
  116815. /**
  116816. * Gets the camera (or eye) position component
  116817. */
  116818. readonly cameraPosition: NodeMaterialConnectionPoint;
  116819. /**
  116820. * Gets the view input component
  116821. */
  116822. readonly view: NodeMaterialConnectionPoint;
  116823. /**
  116824. * Gets the rgb output component
  116825. */
  116826. readonly rgb: NodeMaterialConnectionPoint;
  116827. /**
  116828. * Gets the r output component
  116829. */
  116830. readonly r: NodeMaterialConnectionPoint;
  116831. /**
  116832. * Gets the g output component
  116833. */
  116834. readonly g: NodeMaterialConnectionPoint;
  116835. /**
  116836. * Gets the b output component
  116837. */
  116838. readonly b: NodeMaterialConnectionPoint;
  116839. autoConfigure(): void;
  116840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116841. isReady(): boolean;
  116842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116843. private _injectVertexCode;
  116844. private _writeOutput;
  116845. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116846. serialize(): any;
  116847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116848. }
  116849. }
  116850. declare module BABYLON {
  116851. /**
  116852. * Class used to store shared data between 2 NodeMaterialBuildState
  116853. */
  116854. export class NodeMaterialBuildStateSharedData {
  116855. /**
  116856. * Gets the list of emitted varyings
  116857. */
  116858. temps: string[];
  116859. /**
  116860. * Gets the list of emitted varyings
  116861. */
  116862. varyings: string[];
  116863. /**
  116864. * Gets the varying declaration string
  116865. */
  116866. varyingDeclaration: string;
  116867. /**
  116868. * Input blocks
  116869. */
  116870. inputBlocks: InputBlock[];
  116871. /**
  116872. * Input blocks
  116873. */
  116874. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  116875. /**
  116876. * Bindable blocks (Blocks that need to set data to the effect)
  116877. */
  116878. bindableBlocks: NodeMaterialBlock[];
  116879. /**
  116880. * List of blocks that can provide a compilation fallback
  116881. */
  116882. blocksWithFallbacks: NodeMaterialBlock[];
  116883. /**
  116884. * List of blocks that can provide a define update
  116885. */
  116886. blocksWithDefines: NodeMaterialBlock[];
  116887. /**
  116888. * List of blocks that can provide a repeatable content
  116889. */
  116890. repeatableContentBlocks: NodeMaterialBlock[];
  116891. /**
  116892. * List of blocks that can provide a dynamic list of uniforms
  116893. */
  116894. dynamicUniformBlocks: NodeMaterialBlock[];
  116895. /**
  116896. * List of blocks that can block the isReady function for the material
  116897. */
  116898. blockingBlocks: NodeMaterialBlock[];
  116899. /**
  116900. * Gets the list of animated inputs
  116901. */
  116902. animatedInputs: InputBlock[];
  116903. /**
  116904. * Build Id used to avoid multiple recompilations
  116905. */
  116906. buildId: number;
  116907. /** List of emitted variables */
  116908. variableNames: {
  116909. [key: string]: number;
  116910. };
  116911. /** List of emitted defines */
  116912. defineNames: {
  116913. [key: string]: number;
  116914. };
  116915. /** Should emit comments? */
  116916. emitComments: boolean;
  116917. /** Emit build activity */
  116918. verbose: boolean;
  116919. /**
  116920. * Gets the compilation hints emitted at compilation time
  116921. */
  116922. hints: {
  116923. needWorldViewMatrix: boolean;
  116924. needWorldViewProjectionMatrix: boolean;
  116925. needAlphaBlending: boolean;
  116926. needAlphaTesting: boolean;
  116927. };
  116928. /**
  116929. * List of compilation checks
  116930. */
  116931. checks: {
  116932. emitVertex: boolean;
  116933. emitFragment: boolean;
  116934. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116935. };
  116936. /** Creates a new shared data */
  116937. constructor();
  116938. /**
  116939. * Emits console errors and exceptions if there is a failing check
  116940. */
  116941. emitErrors(): void;
  116942. }
  116943. }
  116944. declare module BABYLON {
  116945. /**
  116946. * Class used to store node based material build state
  116947. */
  116948. export class NodeMaterialBuildState {
  116949. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116950. supportUniformBuffers: boolean;
  116951. /**
  116952. * Gets the list of emitted attributes
  116953. */
  116954. attributes: string[];
  116955. /**
  116956. * Gets the list of emitted uniforms
  116957. */
  116958. uniforms: string[];
  116959. /**
  116960. * Gets the list of emitted uniform buffers
  116961. */
  116962. uniformBuffers: string[];
  116963. /**
  116964. * Gets the list of emitted samplers
  116965. */
  116966. samplers: string[];
  116967. /**
  116968. * Gets the list of emitted functions
  116969. */
  116970. functions: {
  116971. [key: string]: string;
  116972. };
  116973. /**
  116974. * Gets the target of the compilation state
  116975. */
  116976. target: NodeMaterialBlockTargets;
  116977. /**
  116978. * Gets the list of emitted counters
  116979. */
  116980. counters: {
  116981. [key: string]: number;
  116982. };
  116983. /**
  116984. * Shared data between multiple NodeMaterialBuildState instances
  116985. */
  116986. sharedData: NodeMaterialBuildStateSharedData;
  116987. /** @hidden */
  116988. _vertexState: NodeMaterialBuildState;
  116989. /** @hidden */
  116990. _attributeDeclaration: string;
  116991. /** @hidden */
  116992. _uniformDeclaration: string;
  116993. /** @hidden */
  116994. _samplerDeclaration: string;
  116995. /** @hidden */
  116996. _varyingTransfer: string;
  116997. private _repeatableContentAnchorIndex;
  116998. /** @hidden */
  116999. _builtCompilationString: string;
  117000. /**
  117001. * Gets the emitted compilation strings
  117002. */
  117003. compilationString: string;
  117004. /**
  117005. * Finalize the compilation strings
  117006. * @param state defines the current compilation state
  117007. */
  117008. finalize(state: NodeMaterialBuildState): void;
  117009. /** @hidden */
  117010. readonly _repeatableContentAnchor: string;
  117011. /** @hidden */
  117012. _getFreeVariableName(prefix: string): string;
  117013. /** @hidden */
  117014. _getFreeDefineName(prefix: string): string;
  117015. /** @hidden */
  117016. _excludeVariableName(name: string): void;
  117017. /** @hidden */
  117018. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  117019. /** @hidden */
  117020. _emitFunction(name: string, code: string, comments: string): void;
  117021. /** @hidden */
  117022. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  117023. replaceStrings?: {
  117024. search: RegExp;
  117025. replace: string;
  117026. }[];
  117027. repeatKey?: string;
  117028. }): string;
  117029. /** @hidden */
  117030. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  117031. repeatKey?: string;
  117032. removeAttributes?: boolean;
  117033. removeUniforms?: boolean;
  117034. removeVaryings?: boolean;
  117035. removeIfDef?: boolean;
  117036. replaceStrings?: {
  117037. search: RegExp;
  117038. replace: string;
  117039. }[];
  117040. }, storeKey?: string): void;
  117041. /** @hidden */
  117042. _registerTempVariable(name: string): boolean;
  117043. /** @hidden */
  117044. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  117045. /** @hidden */
  117046. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  117047. }
  117048. }
  117049. declare module BABYLON {
  117050. /**
  117051. * Defines a block that can be used inside a node based material
  117052. */
  117053. export class NodeMaterialBlock {
  117054. private _buildId;
  117055. private _buildTarget;
  117056. private _target;
  117057. private _isFinalMerger;
  117058. private _isInput;
  117059. /** @hidden */
  117060. _inputs: NodeMaterialConnectionPoint[];
  117061. /** @hidden */
  117062. _outputs: NodeMaterialConnectionPoint[];
  117063. /**
  117064. * Gets or sets the name of the block
  117065. */
  117066. name: string;
  117067. /**
  117068. * Gets or sets the unique id of the node
  117069. */
  117070. uniqueId: number;
  117071. /**
  117072. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  117073. */
  117074. readonly isFinalMerger: boolean;
  117075. /**
  117076. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  117077. */
  117078. readonly isInput: boolean;
  117079. /**
  117080. * Gets or sets the build Id
  117081. */
  117082. buildId: number;
  117083. /**
  117084. * Gets or sets the target of the block
  117085. */
  117086. target: NodeMaterialBlockTargets;
  117087. /**
  117088. * Gets the list of input points
  117089. */
  117090. readonly inputs: NodeMaterialConnectionPoint[];
  117091. /** Gets the list of output points */
  117092. readonly outputs: NodeMaterialConnectionPoint[];
  117093. /**
  117094. * Find an input by its name
  117095. * @param name defines the name of the input to look for
  117096. * @returns the input or null if not found
  117097. */
  117098. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117099. /**
  117100. * Find an output by its name
  117101. * @param name defines the name of the outputto look for
  117102. * @returns the output or null if not found
  117103. */
  117104. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117105. /**
  117106. * Creates a new NodeMaterialBlock
  117107. * @param name defines the block name
  117108. * @param target defines the target of that block (Vertex by default)
  117109. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  117110. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  117111. */
  117112. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  117113. /**
  117114. * Initialize the block and prepare the context for build
  117115. * @param state defines the state that will be used for the build
  117116. */
  117117. initialize(state: NodeMaterialBuildState): void;
  117118. /**
  117119. * Bind data to effect. Will only be called for blocks with isBindable === true
  117120. * @param effect defines the effect to bind data to
  117121. * @param nodeMaterial defines the hosting NodeMaterial
  117122. * @param mesh defines the mesh that will be rendered
  117123. */
  117124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117125. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  117126. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  117127. protected _writeFloat(value: number): string;
  117128. /**
  117129. * Gets the current class name e.g. "NodeMaterialBlock"
  117130. * @returns the class name
  117131. */
  117132. getClassName(): string;
  117133. /**
  117134. * Register a new input. Must be called inside a block constructor
  117135. * @param name defines the connection point name
  117136. * @param type defines the connection point type
  117137. * @param isOptional defines a boolean indicating that this input can be omitted
  117138. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  117139. * @returns the current block
  117140. */
  117141. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  117142. /**
  117143. * Register a new output. Must be called inside a block constructor
  117144. * @param name defines the connection point name
  117145. * @param type defines the connection point type
  117146. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  117147. * @returns the current block
  117148. */
  117149. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  117150. /**
  117151. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  117152. * @param forOutput defines an optional connection point to check compatibility with
  117153. * @returns the first available input or null
  117154. */
  117155. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  117156. /**
  117157. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  117158. * @param forBlock defines an optional block to check compatibility with
  117159. * @returns the first available input or null
  117160. */
  117161. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  117162. /**
  117163. * Gets the sibling of the given output
  117164. * @param current defines the current output
  117165. * @returns the next output in the list or null
  117166. */
  117167. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  117168. /**
  117169. * Connect current block with another block
  117170. * @param other defines the block to connect with
  117171. * @param options define the various options to help pick the right connections
  117172. * @returns the current block
  117173. */
  117174. connectTo(other: NodeMaterialBlock, options?: {
  117175. input?: string;
  117176. output?: string;
  117177. outputSwizzle?: string;
  117178. }): this | undefined;
  117179. protected _buildBlock(state: NodeMaterialBuildState): void;
  117180. /**
  117181. * Add uniforms, samplers and uniform buffers at compilation time
  117182. * @param state defines the state to update
  117183. * @param nodeMaterial defines the node material requesting the update
  117184. * @param defines defines the material defines to update
  117185. */
  117186. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117187. /**
  117188. * Add potential fallbacks if shader compilation fails
  117189. * @param mesh defines the mesh to be rendered
  117190. * @param fallbacks defines the current prioritized list of fallbacks
  117191. */
  117192. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117193. /**
  117194. * Update defines for shader compilation
  117195. * @param mesh defines the mesh to be rendered
  117196. * @param nodeMaterial defines the node material requesting the update
  117197. * @param defines defines the material defines to update
  117198. * @param useInstances specifies that instances should be used
  117199. */
  117200. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117201. /**
  117202. * Initialize defines for shader compilation
  117203. * @param mesh defines the mesh to be rendered
  117204. * @param nodeMaterial defines the node material requesting the update
  117205. * @param defines defines the material defines to be prepared
  117206. * @param useInstances specifies that instances should be used
  117207. */
  117208. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117209. /**
  117210. * Lets the block try to connect some inputs automatically
  117211. */
  117212. autoConfigure(): void;
  117213. /**
  117214. * Function called when a block is declared as repeatable content generator
  117215. * @param vertexShaderState defines the current compilation state for the vertex shader
  117216. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117217. * @param mesh defines the mesh to be rendered
  117218. * @param defines defines the material defines to update
  117219. */
  117220. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117221. /**
  117222. * Checks if the block is ready
  117223. * @param mesh defines the mesh to be rendered
  117224. * @param nodeMaterial defines the node material requesting the update
  117225. * @param defines defines the material defines to update
  117226. * @param useInstances specifies that instances should be used
  117227. * @returns true if the block is ready
  117228. */
  117229. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117230. private _processBuild;
  117231. /**
  117232. * Compile the current node and generate the shader code
  117233. * @param state defines the current compilation state (uniforms, samplers, current string)
  117234. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  117235. * @returns true if already built
  117236. */
  117237. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  117238. /**
  117239. * Clone the current block to a new identical block
  117240. * @param scene defines the hosting scene
  117241. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117242. * @returns a copy of the current block
  117243. */
  117244. clone(scene: Scene, rootUrl?: string): NodeMaterialBlock | null;
  117245. /**
  117246. * Serializes this block in a JSON representation
  117247. * @returns the serialized block object
  117248. */
  117249. serialize(): any;
  117250. /** @hidden */
  117251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117252. }
  117253. }
  117254. declare module BABYLON {
  117255. /**
  117256. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117257. */
  117258. export enum NodeMaterialBlockConnectionPointMode {
  117259. /** Value is an uniform */
  117260. Uniform = 0,
  117261. /** Value is a mesh attribute */
  117262. Attribute = 1,
  117263. /** Value is a varying between vertex and fragment shaders */
  117264. Varying = 2,
  117265. /** Mode is undefined */
  117266. Undefined = 3
  117267. }
  117268. }
  117269. declare module BABYLON {
  117270. /**
  117271. * Enum defining the type of animations supported by InputBlock
  117272. */
  117273. export enum AnimatedInputBlockTypes {
  117274. /** No animation */
  117275. None = 0,
  117276. /** Time based animation. Will only work for floats */
  117277. Time = 1
  117278. }
  117279. }
  117280. declare module BABYLON {
  117281. /**
  117282. * Block used to expose an input value
  117283. */
  117284. export class InputBlock extends NodeMaterialBlock {
  117285. private _mode;
  117286. private _associatedVariableName;
  117287. private _storedValue;
  117288. private _valueCallback;
  117289. private _type;
  117290. private _animationType;
  117291. /** @hidden */
  117292. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117293. /** Gets or sets a boolean indicating that this input can be edited in the Inspector */
  117294. visibleInInspector: boolean;
  117295. /**
  117296. * Gets or sets the connection point type (default is float)
  117297. */
  117298. readonly type: NodeMaterialBlockConnectionPointTypes;
  117299. /**
  117300. * Creates a new InputBlock
  117301. * @param name defines the block name
  117302. * @param target defines the target of that block (Vertex by default)
  117303. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117304. */
  117305. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117306. /**
  117307. * Gets the output component
  117308. */
  117309. readonly output: NodeMaterialConnectionPoint;
  117310. /**
  117311. * Set the source of this connection point to a vertex attribute
  117312. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117313. * @returns the current connection point
  117314. */
  117315. setAsAttribute(attributeName?: string): InputBlock;
  117316. /**
  117317. * Set the source of this connection point to a well known value
  117318. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117319. * @returns the current connection point
  117320. */
  117321. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117322. /**
  117323. * Gets or sets the value of that point.
  117324. * Please note that this value will be ignored if valueCallback is defined
  117325. */
  117326. value: any;
  117327. /**
  117328. * Gets or sets a callback used to get the value of that point.
  117329. * Please note that setting this value will force the connection point to ignore the value property
  117330. */
  117331. valueCallback: () => any;
  117332. /**
  117333. * Gets or sets the associated variable name in the shader
  117334. */
  117335. associatedVariableName: string;
  117336. /** Gets or sets the type of animation applied to the input */
  117337. animationType: AnimatedInputBlockTypes;
  117338. /**
  117339. * Gets a boolean indicating that this connection point not defined yet
  117340. */
  117341. readonly isUndefined: boolean;
  117342. /**
  117343. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117344. * In this case the connection point name must be the name of the uniform to use.
  117345. * Can only be set on inputs
  117346. */
  117347. isUniform: boolean;
  117348. /**
  117349. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117350. * In this case the connection point name must be the name of the attribute to use
  117351. * Can only be set on inputs
  117352. */
  117353. isAttribute: boolean;
  117354. /**
  117355. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117356. * Can only be set on exit points
  117357. */
  117358. isVarying: boolean;
  117359. /**
  117360. * Gets a boolean indicating that the current connection point is a well known value
  117361. */
  117362. readonly isWellKnownValue: boolean;
  117363. /**
  117364. * Gets or sets the current well known value or null if not defined as well know value
  117365. */
  117366. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117367. /**
  117368. * Gets the current class name
  117369. * @returns the class name
  117370. */
  117371. getClassName(): string;
  117372. /**
  117373. * Animate the input if animationType !== None
  117374. * @param scene defines the rendering scene
  117375. */
  117376. animate(scene: Scene): void;
  117377. private _emitDefine;
  117378. /**
  117379. * Set the input block to its default value (based on its type)
  117380. */
  117381. setDefaultValue(): void;
  117382. private _emit;
  117383. /** @hidden */
  117384. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117385. /** @hidden */
  117386. _transmit(effect: Effect, scene: Scene): void;
  117387. protected _buildBlock(state: NodeMaterialBuildState): void;
  117388. serialize(): any;
  117389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117390. }
  117391. }
  117392. declare module BABYLON {
  117393. /**
  117394. * Defines a connection point for a block
  117395. */
  117396. export class NodeMaterialConnectionPoint {
  117397. /** @hidden */
  117398. _ownerBlock: NodeMaterialBlock;
  117399. /** @hidden */
  117400. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117401. private _endpoints;
  117402. private _associatedVariableName;
  117403. /** @hidden */
  117404. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117405. private _type;
  117406. /** @hidden */
  117407. _enforceAssociatedVariableName: boolean;
  117408. /**
  117409. * Gets or sets the additional types supported byt this connection point
  117410. */
  117411. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117412. /**
  117413. * Gets or sets the associated variable name in the shader
  117414. */
  117415. associatedVariableName: string;
  117416. /**
  117417. * Gets or sets the connection point type (default is float)
  117418. */
  117419. type: NodeMaterialBlockConnectionPointTypes;
  117420. /**
  117421. * Gets or sets the connection point name
  117422. */
  117423. name: string;
  117424. /**
  117425. * Gets or sets a boolean indicating that this connection point can be omitted
  117426. */
  117427. isOptional: boolean;
  117428. /**
  117429. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117430. */
  117431. define: string;
  117432. /** Gets or sets the target of that connection point */
  117433. target: NodeMaterialBlockTargets;
  117434. /**
  117435. * Gets a boolean indicating that the current point is connected
  117436. */
  117437. readonly isConnected: boolean;
  117438. /**
  117439. * Gets a boolean indicating that the current point is connected to an input block
  117440. */
  117441. readonly isConnectedToInputBlock: boolean;
  117442. /**
  117443. * Gets a the connected input block (if any)
  117444. */
  117445. readonly connectInputBlock: Nullable<InputBlock>;
  117446. /** Get the other side of the connection (if any) */
  117447. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117448. /** Get the block that owns this connection point */
  117449. readonly ownerBlock: NodeMaterialBlock;
  117450. /** Get the block connected on the other side of this connection (if any) */
  117451. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117452. /** Get the block connected on the endpoints of this connection (if any) */
  117453. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117454. /** Gets the list of connected endpoints */
  117455. readonly endpoints: NodeMaterialConnectionPoint[];
  117456. /** Gets a boolean indicating if that output point is connected to at least one input */
  117457. readonly hasEndpoints: boolean;
  117458. /**
  117459. * Creates a new connection point
  117460. * @param name defines the connection point name
  117461. * @param ownerBlock defines the block hosting this connection point
  117462. */
  117463. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117464. /**
  117465. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117466. * @returns the class name
  117467. */
  117468. getClassName(): string;
  117469. /**
  117470. * Gets an boolean indicating if the current point can be connected to another point
  117471. * @param connectionPoint defines the other connection point
  117472. * @returns true if the connection is possible
  117473. */
  117474. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117475. /**
  117476. * Connect this point to another connection point
  117477. * @param connectionPoint defines the other connection point
  117478. * @returns the current connection point
  117479. */
  117480. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117481. /**
  117482. * Disconnect this point from one of his endpoint
  117483. * @param endpoint defines the other connection point
  117484. * @returns the current connection point
  117485. */
  117486. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117487. /**
  117488. * Serializes this point in a JSON representation
  117489. * @returns the serialized point object
  117490. */
  117491. serialize(): any;
  117492. }
  117493. }
  117494. declare module BABYLON {
  117495. /**
  117496. * Block used to add support for vertex skinning (bones)
  117497. */
  117498. export class BonesBlock extends NodeMaterialBlock {
  117499. /**
  117500. * Creates a new BonesBlock
  117501. * @param name defines the block name
  117502. */
  117503. constructor(name: string);
  117504. /**
  117505. * Initialize the block and prepare the context for build
  117506. * @param state defines the state that will be used for the build
  117507. */
  117508. initialize(state: NodeMaterialBuildState): void;
  117509. /**
  117510. * Gets the current class name
  117511. * @returns the class name
  117512. */
  117513. getClassName(): string;
  117514. /**
  117515. * Gets the matrix indices input component
  117516. */
  117517. readonly matricesIndices: NodeMaterialConnectionPoint;
  117518. /**
  117519. * Gets the matrix weights input component
  117520. */
  117521. readonly matricesWeights: NodeMaterialConnectionPoint;
  117522. /**
  117523. * Gets the extra matrix indices input component
  117524. */
  117525. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117526. /**
  117527. * Gets the extra matrix weights input component
  117528. */
  117529. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117530. /**
  117531. * Gets the world input component
  117532. */
  117533. readonly world: NodeMaterialConnectionPoint;
  117534. /**
  117535. * Gets the output component
  117536. */
  117537. readonly output: NodeMaterialConnectionPoint;
  117538. autoConfigure(): void;
  117539. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117541. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117542. protected _buildBlock(state: NodeMaterialBuildState): this;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * Block used to add support for instances
  117548. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117549. */
  117550. export class InstancesBlock extends NodeMaterialBlock {
  117551. /**
  117552. * Creates a new InstancesBlock
  117553. * @param name defines the block name
  117554. */
  117555. constructor(name: string);
  117556. /**
  117557. * Gets the current class name
  117558. * @returns the class name
  117559. */
  117560. getClassName(): string;
  117561. /**
  117562. * Gets the first world row input component
  117563. */
  117564. readonly world0: NodeMaterialConnectionPoint;
  117565. /**
  117566. * Gets the second world row input component
  117567. */
  117568. readonly world1: NodeMaterialConnectionPoint;
  117569. /**
  117570. * Gets the third world row input component
  117571. */
  117572. readonly world2: NodeMaterialConnectionPoint;
  117573. /**
  117574. * Gets the forth world row input component
  117575. */
  117576. readonly world3: NodeMaterialConnectionPoint;
  117577. /**
  117578. * Gets the world input component
  117579. */
  117580. readonly world: NodeMaterialConnectionPoint;
  117581. /**
  117582. * Gets the output component
  117583. */
  117584. readonly output: NodeMaterialConnectionPoint;
  117585. autoConfigure(): void;
  117586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117587. protected _buildBlock(state: NodeMaterialBuildState): this;
  117588. }
  117589. }
  117590. declare module BABYLON {
  117591. /**
  117592. * Block used to add morph targets support to vertex shader
  117593. */
  117594. export class MorphTargetsBlock extends NodeMaterialBlock {
  117595. private _repeatableContentAnchor;
  117596. private _repeatebleContentGenerated;
  117597. /**
  117598. * Create a new MorphTargetsBlock
  117599. * @param name defines the block name
  117600. */
  117601. constructor(name: string);
  117602. /**
  117603. * Gets the current class name
  117604. * @returns the class name
  117605. */
  117606. getClassName(): string;
  117607. /**
  117608. * Gets the position input component
  117609. */
  117610. readonly position: NodeMaterialConnectionPoint;
  117611. /**
  117612. * Gets the normal input component
  117613. */
  117614. readonly normal: NodeMaterialConnectionPoint;
  117615. /**
  117616. * Gets the tangent input component
  117617. */
  117618. readonly tangent: NodeMaterialConnectionPoint;
  117619. /**
  117620. * Gets the tangent input component
  117621. */
  117622. readonly uv: NodeMaterialConnectionPoint;
  117623. /**
  117624. * Gets the position output component
  117625. */
  117626. readonly positionOutput: NodeMaterialConnectionPoint;
  117627. /**
  117628. * Gets the normal output component
  117629. */
  117630. readonly normalOutput: NodeMaterialConnectionPoint;
  117631. /**
  117632. * Gets the tangent output component
  117633. */
  117634. readonly tangentOutput: NodeMaterialConnectionPoint;
  117635. /**
  117636. * Gets the tangent output component
  117637. */
  117638. readonly uvOutput: NodeMaterialConnectionPoint;
  117639. initialize(state: NodeMaterialBuildState): void;
  117640. autoConfigure(): void;
  117641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117643. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117644. protected _buildBlock(state: NodeMaterialBuildState): this;
  117645. }
  117646. }
  117647. declare module BABYLON {
  117648. /**
  117649. * Block used to add an alpha test in the fragment shader
  117650. */
  117651. export class AlphaTestBlock extends NodeMaterialBlock {
  117652. /**
  117653. * Gets or sets the alpha value where alpha testing happens
  117654. */
  117655. alphaCutOff: number;
  117656. /**
  117657. * Create a new AlphaTestBlock
  117658. * @param name defines the block name
  117659. */
  117660. constructor(name: string);
  117661. /**
  117662. * Gets the current class name
  117663. * @returns the class name
  117664. */
  117665. getClassName(): string;
  117666. /**
  117667. * Gets the color input component
  117668. */
  117669. readonly color: NodeMaterialConnectionPoint;
  117670. /**
  117671. * Gets the alpha input component
  117672. */
  117673. readonly alpha: NodeMaterialConnectionPoint;
  117674. protected _buildBlock(state: NodeMaterialBuildState): this;
  117675. }
  117676. }
  117677. declare module BABYLON {
  117678. /**
  117679. * Block used to compute fresnel value
  117680. */
  117681. export class FresnelBlock extends NodeMaterialBlock {
  117682. /**
  117683. * Create a new FresnelBlock
  117684. * @param name defines the block name
  117685. */
  117686. constructor(name: string);
  117687. /**
  117688. * Gets the current class name
  117689. * @returns the class name
  117690. */
  117691. getClassName(): string;
  117692. /**
  117693. * Gets the world position input component
  117694. */
  117695. readonly worldPosition: NodeMaterialConnectionPoint;
  117696. /**
  117697. * Gets the world normal input component
  117698. */
  117699. readonly worldNormal: NodeMaterialConnectionPoint;
  117700. /**
  117701. * Gets the camera (or eye) position component
  117702. */
  117703. readonly cameraPosition: NodeMaterialConnectionPoint;
  117704. /**
  117705. * Gets the bias input component
  117706. */
  117707. readonly bias: NodeMaterialConnectionPoint;
  117708. /**
  117709. * Gets the camera (or eye) position component
  117710. */
  117711. readonly power: NodeMaterialConnectionPoint;
  117712. /**
  117713. * Gets the fresnel output component
  117714. */
  117715. readonly fresnel: NodeMaterialConnectionPoint;
  117716. autoConfigure(): void;
  117717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117718. }
  117719. }
  117720. declare module BABYLON {
  117721. /**
  117722. * Block used to add image processing support to fragment shader
  117723. */
  117724. export class ImageProcessingBlock extends NodeMaterialBlock {
  117725. /**
  117726. * Create a new ImageProcessingBlock
  117727. * @param name defines the block name
  117728. */
  117729. constructor(name: string);
  117730. /**
  117731. * Gets the current class name
  117732. * @returns the class name
  117733. */
  117734. getClassName(): string;
  117735. /**
  117736. * Gets the color input component
  117737. */
  117738. readonly color: NodeMaterialConnectionPoint;
  117739. /**
  117740. * Gets the output component
  117741. */
  117742. readonly output: NodeMaterialConnectionPoint;
  117743. /**
  117744. * Initialize the block and prepare the context for build
  117745. * @param state defines the state that will be used for the build
  117746. */
  117747. initialize(state: NodeMaterialBuildState): void;
  117748. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117751. protected _buildBlock(state: NodeMaterialBuildState): this;
  117752. }
  117753. }
  117754. declare module BABYLON {
  117755. /**
  117756. * Block used to add support for scene fog
  117757. */
  117758. export class FogBlock extends NodeMaterialBlock {
  117759. private _fogDistanceName;
  117760. private _fogParameters;
  117761. /**
  117762. * Create a new FogBlock
  117763. * @param name defines the block name
  117764. */
  117765. constructor(name: string);
  117766. /**
  117767. * Gets the current class name
  117768. * @returns the class name
  117769. */
  117770. getClassName(): string;
  117771. /**
  117772. * Gets the world position input component
  117773. */
  117774. readonly worldPosition: NodeMaterialConnectionPoint;
  117775. /**
  117776. * Gets the view input component
  117777. */
  117778. readonly view: NodeMaterialConnectionPoint;
  117779. /**
  117780. * Gets the color input component
  117781. */
  117782. readonly color: NodeMaterialConnectionPoint;
  117783. /**
  117784. * Gets the fog color input component
  117785. */
  117786. readonly fogColor: NodeMaterialConnectionPoint;
  117787. /**
  117788. * Gets the output component
  117789. */
  117790. readonly output: NodeMaterialConnectionPoint;
  117791. autoConfigure(): void;
  117792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117794. protected _buildBlock(state: NodeMaterialBuildState): this;
  117795. }
  117796. }
  117797. declare module BABYLON {
  117798. /**
  117799. * Block used to add light in the fragment shader
  117800. */
  117801. export class LightBlock extends NodeMaterialBlock {
  117802. private _lightId;
  117803. /**
  117804. * Gets or sets the light associated with this block
  117805. */
  117806. light: Nullable<Light>;
  117807. /**
  117808. * Create a new LightBlock
  117809. * @param name defines the block name
  117810. */
  117811. constructor(name: string);
  117812. /**
  117813. * Gets the current class name
  117814. * @returns the class name
  117815. */
  117816. getClassName(): string;
  117817. /**
  117818. * Gets the world position input component
  117819. */
  117820. readonly worldPosition: NodeMaterialConnectionPoint;
  117821. /**
  117822. * Gets the world normal input component
  117823. */
  117824. readonly worldNormal: NodeMaterialConnectionPoint;
  117825. /**
  117826. * Gets the camera (or eye) position component
  117827. */
  117828. readonly cameraPosition: NodeMaterialConnectionPoint;
  117829. /**
  117830. * Gets the diffuse output component
  117831. */
  117832. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117833. /**
  117834. * Gets the specular output component
  117835. */
  117836. readonly specularOutput: NodeMaterialConnectionPoint;
  117837. autoConfigure(): void;
  117838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117839. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117841. private _injectVertexCode;
  117842. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117843. serialize(): any;
  117844. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117845. }
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * Block used to multiply 2 values
  117850. */
  117851. export class MultiplyBlock extends NodeMaterialBlock {
  117852. /**
  117853. * Creates a new MultiplyBlock
  117854. * @param name defines the block name
  117855. */
  117856. constructor(name: string);
  117857. /**
  117858. * Gets the current class name
  117859. * @returns the class name
  117860. */
  117861. getClassName(): string;
  117862. /**
  117863. * Gets the left operand input component
  117864. */
  117865. readonly left: NodeMaterialConnectionPoint;
  117866. /**
  117867. * Gets the right operand input component
  117868. */
  117869. readonly right: NodeMaterialConnectionPoint;
  117870. /**
  117871. * Gets the output component
  117872. */
  117873. readonly output: NodeMaterialConnectionPoint;
  117874. protected _buildBlock(state: NodeMaterialBuildState): this;
  117875. }
  117876. }
  117877. declare module BABYLON {
  117878. /**
  117879. * Block used to add 2 vectors
  117880. */
  117881. export class AddBlock extends NodeMaterialBlock {
  117882. /**
  117883. * Creates a new AddBlock
  117884. * @param name defines the block name
  117885. */
  117886. constructor(name: string);
  117887. /**
  117888. * Gets the current class name
  117889. * @returns the class name
  117890. */
  117891. getClassName(): string;
  117892. /**
  117893. * Gets the left operand input component
  117894. */
  117895. readonly left: NodeMaterialConnectionPoint;
  117896. /**
  117897. * Gets the right operand input component
  117898. */
  117899. readonly right: NodeMaterialConnectionPoint;
  117900. /**
  117901. * Gets the output component
  117902. */
  117903. readonly output: NodeMaterialConnectionPoint;
  117904. protected _buildBlock(state: NodeMaterialBuildState): this;
  117905. }
  117906. }
  117907. declare module BABYLON {
  117908. /**
  117909. * Block used to scale a vector by a float
  117910. */
  117911. export class ScaleBlock extends NodeMaterialBlock {
  117912. /**
  117913. * Creates a new ScaleBlock
  117914. * @param name defines the block name
  117915. */
  117916. constructor(name: string);
  117917. /**
  117918. * Gets the current class name
  117919. * @returns the class name
  117920. */
  117921. getClassName(): string;
  117922. /**
  117923. * Gets the input component
  117924. */
  117925. readonly input: NodeMaterialConnectionPoint;
  117926. /**
  117927. * Gets the factor input component
  117928. */
  117929. readonly factor: NodeMaterialConnectionPoint;
  117930. /**
  117931. * Gets the output component
  117932. */
  117933. readonly output: NodeMaterialConnectionPoint;
  117934. protected _buildBlock(state: NodeMaterialBuildState): this;
  117935. }
  117936. }
  117937. declare module BABYLON {
  117938. /**
  117939. * Block used to clamp a float
  117940. */
  117941. export class ClampBlock extends NodeMaterialBlock {
  117942. /** Gets or sets the minimum range */
  117943. minimum: number;
  117944. /** Gets or sets the maximum range */
  117945. maximum: number;
  117946. /**
  117947. * Creates a new ClampBlock
  117948. * @param name defines the block name
  117949. */
  117950. constructor(name: string);
  117951. /**
  117952. * Gets the current class name
  117953. * @returns the class name
  117954. */
  117955. getClassName(): string;
  117956. /**
  117957. * Gets the value input component
  117958. */
  117959. readonly value: NodeMaterialConnectionPoint;
  117960. /**
  117961. * Gets the output component
  117962. */
  117963. readonly output: NodeMaterialConnectionPoint;
  117964. protected _buildBlock(state: NodeMaterialBuildState): this;
  117965. }
  117966. }
  117967. declare module BABYLON {
  117968. /**
  117969. * Block used to apply a cross product between 2 vectors
  117970. */
  117971. export class CrossBlock extends NodeMaterialBlock {
  117972. /**
  117973. * Creates a new CrossBlock
  117974. * @param name defines the block name
  117975. */
  117976. constructor(name: string);
  117977. /**
  117978. * Gets the current class name
  117979. * @returns the class name
  117980. */
  117981. getClassName(): string;
  117982. /**
  117983. * Gets the left operand input component
  117984. */
  117985. readonly left: NodeMaterialConnectionPoint;
  117986. /**
  117987. * Gets the right operand input component
  117988. */
  117989. readonly right: NodeMaterialConnectionPoint;
  117990. /**
  117991. * Gets the output component
  117992. */
  117993. readonly output: NodeMaterialConnectionPoint;
  117994. protected _buildBlock(state: NodeMaterialBuildState): this;
  117995. }
  117996. }
  117997. declare module BABYLON {
  117998. /**
  117999. * Block used to apply a dot product between 2 vectors
  118000. */
  118001. export class DotBlock extends NodeMaterialBlock {
  118002. /**
  118003. * Creates a new DotBlock
  118004. * @param name defines the block name
  118005. */
  118006. constructor(name: string);
  118007. /**
  118008. * Gets the current class name
  118009. * @returns the class name
  118010. */
  118011. getClassName(): string;
  118012. /**
  118013. * Gets the left operand input component
  118014. */
  118015. readonly left: NodeMaterialConnectionPoint;
  118016. /**
  118017. * Gets the right operand input component
  118018. */
  118019. readonly right: NodeMaterialConnectionPoint;
  118020. /**
  118021. * Gets the output component
  118022. */
  118023. readonly output: NodeMaterialConnectionPoint;
  118024. protected _buildBlock(state: NodeMaterialBuildState): this;
  118025. }
  118026. }
  118027. declare module BABYLON {
  118028. /**
  118029. * Block used to remap a float from a range to a new one
  118030. */
  118031. export class RemapBlock extends NodeMaterialBlock {
  118032. /**
  118033. * Gets or sets the source range
  118034. */
  118035. sourceRange: Vector2;
  118036. /**
  118037. * Gets or sets the target range
  118038. */
  118039. targetRange: Vector2;
  118040. /**
  118041. * Creates a new RemapBlock
  118042. * @param name defines the block name
  118043. */
  118044. constructor(name: string);
  118045. /**
  118046. * Gets the current class name
  118047. * @returns the class name
  118048. */
  118049. getClassName(): string;
  118050. /**
  118051. * Gets the input component
  118052. */
  118053. readonly input: NodeMaterialConnectionPoint;
  118054. /**
  118055. * Gets the output component
  118056. */
  118057. readonly output: NodeMaterialConnectionPoint;
  118058. protected _buildBlock(state: NodeMaterialBuildState): this;
  118059. }
  118060. }
  118061. declare module BABYLON {
  118062. /**
  118063. * Block used to normalize a vector
  118064. */
  118065. export class NormalizeBlock extends NodeMaterialBlock {
  118066. /**
  118067. * Creates a new NormalizeBlock
  118068. * @param name defines the block name
  118069. */
  118070. constructor(name: string);
  118071. /**
  118072. * Gets the current class name
  118073. * @returns the class name
  118074. */
  118075. getClassName(): string;
  118076. /**
  118077. * Gets the input component
  118078. */
  118079. readonly input: NodeMaterialConnectionPoint;
  118080. /**
  118081. * Gets the output component
  118082. */
  118083. readonly output: NodeMaterialConnectionPoint;
  118084. protected _buildBlock(state: NodeMaterialBuildState): this;
  118085. }
  118086. }
  118087. declare module BABYLON {
  118088. /**
  118089. * Operations supported by the Trigonometry block
  118090. */
  118091. export enum TrigonometryBlockOperations {
  118092. /** Cos */
  118093. Cos = 0,
  118094. /** Sin */
  118095. Sin = 1,
  118096. /** Abs */
  118097. Abs = 2
  118098. }
  118099. /**
  118100. * Block used to apply trigonometry operation to floats
  118101. */
  118102. export class TrigonometryBlock extends NodeMaterialBlock {
  118103. /**
  118104. * Gets or sets the operation applied by the block
  118105. */
  118106. operation: TrigonometryBlockOperations;
  118107. /**
  118108. * Creates a new TrigonometryBlock
  118109. * @param name defines the block name
  118110. */
  118111. constructor(name: string);
  118112. /**
  118113. * Gets the current class name
  118114. * @returns the class name
  118115. */
  118116. getClassName(): string;
  118117. /**
  118118. * Gets the input component
  118119. */
  118120. readonly input: NodeMaterialConnectionPoint;
  118121. /**
  118122. * Gets the output component
  118123. */
  118124. readonly output: NodeMaterialConnectionPoint;
  118125. protected _buildBlock(state: NodeMaterialBuildState): this;
  118126. }
  118127. }
  118128. declare module BABYLON {
  118129. /**
  118130. * Block used to create a Color3/4 out of individual inputs (one for each component)
  118131. */
  118132. export class ColorMergerBlock extends NodeMaterialBlock {
  118133. /**
  118134. * Create a new ColorMergerBlock
  118135. * @param name defines the block name
  118136. */
  118137. constructor(name: string);
  118138. /**
  118139. * Gets the current class name
  118140. * @returns the class name
  118141. */
  118142. getClassName(): string;
  118143. /**
  118144. * Gets the r component (input)
  118145. */
  118146. readonly r: NodeMaterialConnectionPoint;
  118147. /**
  118148. * Gets the g component (input)
  118149. */
  118150. readonly g: NodeMaterialConnectionPoint;
  118151. /**
  118152. * Gets the b component (input)
  118153. */
  118154. readonly b: NodeMaterialConnectionPoint;
  118155. /**
  118156. * Gets the a component (input)
  118157. */
  118158. readonly a: NodeMaterialConnectionPoint;
  118159. /**
  118160. * Gets the rgba component (output)
  118161. */
  118162. readonly rgba: NodeMaterialConnectionPoint;
  118163. /**
  118164. * Gets the rgb component (output)
  118165. */
  118166. readonly rgb: NodeMaterialConnectionPoint;
  118167. protected _buildBlock(state: NodeMaterialBuildState): this;
  118168. }
  118169. }
  118170. declare module BABYLON {
  118171. /**
  118172. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  118173. */
  118174. export class VectorMergerBlock extends NodeMaterialBlock {
  118175. /**
  118176. * Create a new VectorMergerBlock
  118177. * @param name defines the block name
  118178. */
  118179. constructor(name: string);
  118180. /**
  118181. * Gets the current class name
  118182. * @returns the class name
  118183. */
  118184. getClassName(): string;
  118185. /**
  118186. * Gets the x component (input)
  118187. */
  118188. readonly x: NodeMaterialConnectionPoint;
  118189. /**
  118190. * Gets the y component (input)
  118191. */
  118192. readonly y: NodeMaterialConnectionPoint;
  118193. /**
  118194. * Gets the z component (input)
  118195. */
  118196. readonly z: NodeMaterialConnectionPoint;
  118197. /**
  118198. * Gets the w component (input)
  118199. */
  118200. readonly w: NodeMaterialConnectionPoint;
  118201. /**
  118202. * Gets the xyzw component (output)
  118203. */
  118204. readonly xyzw: NodeMaterialConnectionPoint;
  118205. /**
  118206. * Gets the xyz component (output)
  118207. */
  118208. readonly xyz: NodeMaterialConnectionPoint;
  118209. /**
  118210. * Gets the xy component (output)
  118211. */
  118212. readonly xy: NodeMaterialConnectionPoint;
  118213. protected _buildBlock(state: NodeMaterialBuildState): this;
  118214. }
  118215. }
  118216. declare module BABYLON {
  118217. /**
  118218. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  118219. */
  118220. export class ColorSplitterBlock extends NodeMaterialBlock {
  118221. /**
  118222. * Create a new ColorSplitterBlock
  118223. * @param name defines the block name
  118224. */
  118225. constructor(name: string);
  118226. /**
  118227. * Gets the current class name
  118228. * @returns the class name
  118229. */
  118230. getClassName(): string;
  118231. /**
  118232. * Gets the rgba component (input)
  118233. */
  118234. readonly rgba: NodeMaterialConnectionPoint;
  118235. /**
  118236. * Gets the rgb component (input)
  118237. */
  118238. readonly rgbIn: NodeMaterialConnectionPoint;
  118239. /**
  118240. * Gets the rgb component (output)
  118241. */
  118242. readonly rgbOut: NodeMaterialConnectionPoint;
  118243. /**
  118244. * Gets the r component (output)
  118245. */
  118246. readonly r: NodeMaterialConnectionPoint;
  118247. /**
  118248. * Gets the g component (output)
  118249. */
  118250. readonly g: NodeMaterialConnectionPoint;
  118251. /**
  118252. * Gets the b component (output)
  118253. */
  118254. readonly b: NodeMaterialConnectionPoint;
  118255. /**
  118256. * Gets the a component (output)
  118257. */
  118258. readonly a: NodeMaterialConnectionPoint;
  118259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /**
  118264. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  118265. */
  118266. export class VectorSplitterBlock extends NodeMaterialBlock {
  118267. /**
  118268. * Create a new VectorSplitterBlock
  118269. * @param name defines the block name
  118270. */
  118271. constructor(name: string);
  118272. /**
  118273. * Gets the current class name
  118274. * @returns the class name
  118275. */
  118276. getClassName(): string;
  118277. /**
  118278. * Gets the xyzw component (input)
  118279. */
  118280. readonly xyzw: NodeMaterialConnectionPoint;
  118281. /**
  118282. * Gets the xyz component (input)
  118283. */
  118284. readonly xyzIn: NodeMaterialConnectionPoint;
  118285. /**
  118286. * Gets the xy component (input)
  118287. */
  118288. readonly xyIn: NodeMaterialConnectionPoint;
  118289. /**
  118290. * Gets the xyz component (output)
  118291. */
  118292. readonly xyzOut: NodeMaterialConnectionPoint;
  118293. /**
  118294. * Gets the xy component (output)
  118295. */
  118296. readonly xyOut: NodeMaterialConnectionPoint;
  118297. /**
  118298. * Gets the x component (output)
  118299. */
  118300. readonly x: NodeMaterialConnectionPoint;
  118301. /**
  118302. * Gets the y component (output)
  118303. */
  118304. readonly y: NodeMaterialConnectionPoint;
  118305. /**
  118306. * Gets the z component (output)
  118307. */
  118308. readonly z: NodeMaterialConnectionPoint;
  118309. /**
  118310. * Gets the w component (output)
  118311. */
  118312. readonly w: NodeMaterialConnectionPoint;
  118313. protected _buildBlock(state: NodeMaterialBuildState): this;
  118314. }
  118315. }
  118316. declare module BABYLON {
  118317. /**
  118318. * Effect Render Options
  118319. */
  118320. export interface IEffectRendererOptions {
  118321. /**
  118322. * Defines the vertices positions.
  118323. */
  118324. positions?: number[];
  118325. /**
  118326. * Defines the indices.
  118327. */
  118328. indices?: number[];
  118329. }
  118330. /**
  118331. * Helper class to render one or more effects
  118332. */
  118333. export class EffectRenderer {
  118334. private engine;
  118335. private static _DefaultOptions;
  118336. private _vertexBuffers;
  118337. private _indexBuffer;
  118338. private _ringBufferIndex;
  118339. private _ringScreenBuffer;
  118340. private _fullscreenViewport;
  118341. private _getNextFrameBuffer;
  118342. /**
  118343. * Creates an effect renderer
  118344. * @param engine the engine to use for rendering
  118345. * @param options defines the options of the effect renderer
  118346. */
  118347. constructor(engine: Engine, options?: IEffectRendererOptions);
  118348. /**
  118349. * Sets the current viewport in normalized coordinates 0-1
  118350. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118351. */
  118352. setViewport(viewport?: Viewport): void;
  118353. /**
  118354. * Sets the current effect wrapper to use during draw.
  118355. * The effect needs to be ready before calling this api.
  118356. * This also sets the default full screen position attribute.
  118357. * @param effectWrapper Defines the effect to draw with
  118358. */
  118359. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118360. /**
  118361. * Draws a full screen quad.
  118362. */
  118363. draw(): void;
  118364. /**
  118365. * renders one or more effects to a specified texture
  118366. * @param effectWrappers list of effects to renderer
  118367. * @param outputTexture texture to draw to, if null it will render to the screen
  118368. */
  118369. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  118370. /**
  118371. * Disposes of the effect renderer
  118372. */
  118373. dispose(): void;
  118374. }
  118375. /**
  118376. * Options to create an EffectWrapper
  118377. */
  118378. interface EffectWrapperCreationOptions {
  118379. /**
  118380. * Engine to use to create the effect
  118381. */
  118382. engine: Engine;
  118383. /**
  118384. * Fragment shader for the effect
  118385. */
  118386. fragmentShader: string;
  118387. /**
  118388. * Vertex shader for the effect
  118389. */
  118390. vertexShader?: string;
  118391. /**
  118392. * Attributes to use in the shader
  118393. */
  118394. attributeNames?: Array<string>;
  118395. /**
  118396. * Uniforms to use in the shader
  118397. */
  118398. uniformNames?: Array<string>;
  118399. /**
  118400. * Texture sampler names to use in the shader
  118401. */
  118402. samplerNames?: Array<string>;
  118403. /**
  118404. * The friendly name of the effect displayed in Spector.
  118405. */
  118406. name?: string;
  118407. }
  118408. /**
  118409. * Wraps an effect to be used for rendering
  118410. */
  118411. export class EffectWrapper {
  118412. /**
  118413. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  118414. */
  118415. onApplyObservable: Observable<{}>;
  118416. /**
  118417. * The underlying effect
  118418. */
  118419. effect: Effect;
  118420. /**
  118421. * Creates an effect to be renderer
  118422. * @param creationOptions options to create the effect
  118423. */
  118424. constructor(creationOptions: EffectWrapperCreationOptions);
  118425. /**
  118426. * Disposes of the effect wrapper
  118427. */
  118428. dispose(): void;
  118429. }
  118430. }
  118431. declare module BABYLON {
  118432. /**
  118433. * Helper class to push actions to a pool of workers.
  118434. */
  118435. export class WorkerPool implements IDisposable {
  118436. private _workerInfos;
  118437. private _pendingActions;
  118438. /**
  118439. * Constructor
  118440. * @param workers Array of workers to use for actions
  118441. */
  118442. constructor(workers: Array<Worker>);
  118443. /**
  118444. * Terminates all workers and clears any pending actions.
  118445. */
  118446. dispose(): void;
  118447. /**
  118448. * Pushes an action to the worker pool. If all the workers are active, the action will be
  118449. * pended until a worker has completed its action.
  118450. * @param action The action to perform. Call onComplete when the action is complete.
  118451. */
  118452. push(action: (worker: Worker, onComplete: () => void) => void): void;
  118453. private _execute;
  118454. }
  118455. }
  118456. declare module BABYLON {
  118457. /**
  118458. * Configuration for Draco compression
  118459. */
  118460. export interface IDracoCompressionConfiguration {
  118461. /**
  118462. * Configuration for the decoder.
  118463. */
  118464. decoder: {
  118465. /**
  118466. * The url to the WebAssembly module.
  118467. */
  118468. wasmUrl?: string;
  118469. /**
  118470. * The url to the WebAssembly binary.
  118471. */
  118472. wasmBinaryUrl?: string;
  118473. /**
  118474. * The url to the fallback JavaScript module.
  118475. */
  118476. fallbackUrl?: string;
  118477. };
  118478. }
  118479. /**
  118480. * Draco compression (https://google.github.io/draco/)
  118481. *
  118482. * This class wraps the Draco module.
  118483. *
  118484. * **Encoder**
  118485. *
  118486. * The encoder is not currently implemented.
  118487. *
  118488. * **Decoder**
  118489. *
  118490. * 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.
  118491. *
  118492. * To update the configuration, use the following code:
  118493. * ```javascript
  118494. * DracoCompression.Configuration = {
  118495. * decoder: {
  118496. * wasmUrl: "<url to the WebAssembly library>",
  118497. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  118498. * fallbackUrl: "<url to the fallback JavaScript library>",
  118499. * }
  118500. * };
  118501. * ```
  118502. *
  118503. * 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.
  118504. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118505. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118506. *
  118507. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118508. * ```javascript
  118509. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118510. * ```
  118511. *
  118512. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118513. */
  118514. export class DracoCompression implements IDisposable {
  118515. private _workerPoolPromise?;
  118516. private _decoderModulePromise?;
  118517. /**
  118518. * The configuration. Defaults to the following urls:
  118519. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  118520. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  118521. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  118522. */
  118523. static Configuration: IDracoCompressionConfiguration;
  118524. /**
  118525. * Returns true if the decoder configuration is available.
  118526. */
  118527. static readonly DecoderAvailable: boolean;
  118528. /**
  118529. * Default number of workers to create when creating the draco compression object.
  118530. */
  118531. static DefaultNumWorkers: number;
  118532. private static GetDefaultNumWorkers;
  118533. private static _Default;
  118534. /**
  118535. * Default instance for the draco compression object.
  118536. */
  118537. static readonly Default: DracoCompression;
  118538. /**
  118539. * Constructor
  118540. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  118541. */
  118542. constructor(numWorkers?: number);
  118543. /**
  118544. * Stop all async operations and release resources.
  118545. */
  118546. dispose(): void;
  118547. /**
  118548. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  118549. * @returns a promise that resolves when ready
  118550. */
  118551. whenReadyAsync(): Promise<void>;
  118552. /**
  118553. * Decode Draco compressed mesh data to vertex data.
  118554. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  118555. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  118556. * @returns A promise that resolves with the decoded vertex data
  118557. */
  118558. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  118559. [kind: string]: number;
  118560. }): Promise<VertexData>;
  118561. }
  118562. }
  118563. declare module BABYLON {
  118564. /**
  118565. * Class for building Constructive Solid Geometry
  118566. */
  118567. export class CSG {
  118568. private polygons;
  118569. /**
  118570. * The world matrix
  118571. */
  118572. matrix: Matrix;
  118573. /**
  118574. * Stores the position
  118575. */
  118576. position: Vector3;
  118577. /**
  118578. * Stores the rotation
  118579. */
  118580. rotation: Vector3;
  118581. /**
  118582. * Stores the rotation quaternion
  118583. */
  118584. rotationQuaternion: Nullable<Quaternion>;
  118585. /**
  118586. * Stores the scaling vector
  118587. */
  118588. scaling: Vector3;
  118589. /**
  118590. * Convert the Mesh to CSG
  118591. * @param mesh The Mesh to convert to CSG
  118592. * @returns A new CSG from the Mesh
  118593. */
  118594. static FromMesh(mesh: Mesh): CSG;
  118595. /**
  118596. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  118597. * @param polygons Polygons used to construct a CSG solid
  118598. */
  118599. private static FromPolygons;
  118600. /**
  118601. * Clones, or makes a deep copy, of the CSG
  118602. * @returns A new CSG
  118603. */
  118604. clone(): CSG;
  118605. /**
  118606. * Unions this CSG with another CSG
  118607. * @param csg The CSG to union against this CSG
  118608. * @returns The unioned CSG
  118609. */
  118610. union(csg: CSG): CSG;
  118611. /**
  118612. * Unions this CSG with another CSG in place
  118613. * @param csg The CSG to union against this CSG
  118614. */
  118615. unionInPlace(csg: CSG): void;
  118616. /**
  118617. * Subtracts this CSG with another CSG
  118618. * @param csg The CSG to subtract against this CSG
  118619. * @returns A new CSG
  118620. */
  118621. subtract(csg: CSG): CSG;
  118622. /**
  118623. * Subtracts this CSG with another CSG in place
  118624. * @param csg The CSG to subtact against this CSG
  118625. */
  118626. subtractInPlace(csg: CSG): void;
  118627. /**
  118628. * Intersect this CSG with another CSG
  118629. * @param csg The CSG to intersect against this CSG
  118630. * @returns A new CSG
  118631. */
  118632. intersect(csg: CSG): CSG;
  118633. /**
  118634. * Intersects this CSG with another CSG in place
  118635. * @param csg The CSG to intersect against this CSG
  118636. */
  118637. intersectInPlace(csg: CSG): void;
  118638. /**
  118639. * Return a new CSG solid with solid and empty space switched. This solid is
  118640. * not modified.
  118641. * @returns A new CSG solid with solid and empty space switched
  118642. */
  118643. inverse(): CSG;
  118644. /**
  118645. * Inverses the CSG in place
  118646. */
  118647. inverseInPlace(): void;
  118648. /**
  118649. * This is used to keep meshes transformations so they can be restored
  118650. * when we build back a Babylon Mesh
  118651. * NB : All CSG operations are performed in world coordinates
  118652. * @param csg The CSG to copy the transform attributes from
  118653. * @returns This CSG
  118654. */
  118655. copyTransformAttributes(csg: CSG): CSG;
  118656. /**
  118657. * Build Raw mesh from CSG
  118658. * Coordinates here are in world space
  118659. * @param name The name of the mesh geometry
  118660. * @param scene The Scene
  118661. * @param keepSubMeshes Specifies if the submeshes should be kept
  118662. * @returns A new Mesh
  118663. */
  118664. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  118665. /**
  118666. * Build Mesh from CSG taking material and transforms into account
  118667. * @param name The name of the Mesh
  118668. * @param material The material of the Mesh
  118669. * @param scene The Scene
  118670. * @param keepSubMeshes Specifies if submeshes should be kept
  118671. * @returns The new Mesh
  118672. */
  118673. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  118674. }
  118675. }
  118676. declare module BABYLON {
  118677. /**
  118678. * Class used to create a trail following a mesh
  118679. */
  118680. export class TrailMesh extends Mesh {
  118681. private _generator;
  118682. private _autoStart;
  118683. private _running;
  118684. private _diameter;
  118685. private _length;
  118686. private _sectionPolygonPointsCount;
  118687. private _sectionVectors;
  118688. private _sectionNormalVectors;
  118689. private _beforeRenderObserver;
  118690. /**
  118691. * @constructor
  118692. * @param name The value used by scene.getMeshByName() to do a lookup.
  118693. * @param generator The mesh to generate a trail.
  118694. * @param scene The scene to add this mesh to.
  118695. * @param diameter Diameter of trailing mesh. Default is 1.
  118696. * @param length Length of trailing mesh. Default is 60.
  118697. * @param autoStart Automatically start trailing mesh. Default true.
  118698. */
  118699. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  118700. /**
  118701. * "TrailMesh"
  118702. * @returns "TrailMesh"
  118703. */
  118704. getClassName(): string;
  118705. private _createMesh;
  118706. /**
  118707. * Start trailing mesh.
  118708. */
  118709. start(): void;
  118710. /**
  118711. * Stop trailing mesh.
  118712. */
  118713. stop(): void;
  118714. /**
  118715. * Update trailing mesh geometry.
  118716. */
  118717. update(): void;
  118718. /**
  118719. * Returns a new TrailMesh object.
  118720. * @param name is a string, the name given to the new mesh
  118721. * @param newGenerator use new generator object for cloned trail mesh
  118722. * @returns a new mesh
  118723. */
  118724. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  118725. /**
  118726. * Serializes this trail mesh
  118727. * @param serializationObject object to write serialization to
  118728. */
  118729. serialize(serializationObject: any): void;
  118730. /**
  118731. * Parses a serialized trail mesh
  118732. * @param parsedMesh the serialized mesh
  118733. * @param scene the scene to create the trail mesh in
  118734. * @returns the created trail mesh
  118735. */
  118736. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Class containing static functions to help procedurally build meshes
  118742. */
  118743. export class TiledBoxBuilder {
  118744. /**
  118745. * Creates a box mesh
  118746. * 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)
  118747. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118751. * @param name defines the name of the mesh
  118752. * @param options defines the options used to create the mesh
  118753. * @param scene defines the hosting scene
  118754. * @returns the box mesh
  118755. */
  118756. static CreateTiledBox(name: string, options: {
  118757. pattern?: number;
  118758. width?: number;
  118759. height?: number;
  118760. depth?: number;
  118761. tileSize?: number;
  118762. tileWidth?: number;
  118763. tileHeight?: number;
  118764. alignHorizontal?: number;
  118765. alignVertical?: number;
  118766. faceUV?: Vector4[];
  118767. faceColors?: Color4[];
  118768. sideOrientation?: number;
  118769. updatable?: boolean;
  118770. }, scene?: Nullable<Scene>): Mesh;
  118771. }
  118772. }
  118773. declare module BABYLON {
  118774. /**
  118775. * Class containing static functions to help procedurally build meshes
  118776. */
  118777. export class TorusKnotBuilder {
  118778. /**
  118779. * Creates a torus knot mesh
  118780. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118781. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118782. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118783. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118787. * @param name defines the name of the mesh
  118788. * @param options defines the options used to create the mesh
  118789. * @param scene defines the hosting scene
  118790. * @returns the torus knot mesh
  118791. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118792. */
  118793. static CreateTorusKnot(name: string, options: {
  118794. radius?: number;
  118795. tube?: number;
  118796. radialSegments?: number;
  118797. tubularSegments?: number;
  118798. p?: number;
  118799. q?: number;
  118800. updatable?: boolean;
  118801. sideOrientation?: number;
  118802. frontUVs?: Vector4;
  118803. backUVs?: Vector4;
  118804. }, scene: any): Mesh;
  118805. }
  118806. }
  118807. declare module BABYLON {
  118808. /**
  118809. * Polygon
  118810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118811. */
  118812. export class Polygon {
  118813. /**
  118814. * Creates a rectangle
  118815. * @param xmin bottom X coord
  118816. * @param ymin bottom Y coord
  118817. * @param xmax top X coord
  118818. * @param ymax top Y coord
  118819. * @returns points that make the resulting rectation
  118820. */
  118821. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  118822. /**
  118823. * Creates a circle
  118824. * @param radius radius of circle
  118825. * @param cx scale in x
  118826. * @param cy scale in y
  118827. * @param numberOfSides number of sides that make up the circle
  118828. * @returns points that make the resulting circle
  118829. */
  118830. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  118831. /**
  118832. * Creates a polygon from input string
  118833. * @param input Input polygon data
  118834. * @returns the parsed points
  118835. */
  118836. static Parse(input: string): Vector2[];
  118837. /**
  118838. * Starts building a polygon from x and y coordinates
  118839. * @param x x coordinate
  118840. * @param y y coordinate
  118841. * @returns the started path2
  118842. */
  118843. static StartingAt(x: number, y: number): Path2;
  118844. }
  118845. /**
  118846. * Builds a polygon
  118847. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118848. */
  118849. export class PolygonMeshBuilder {
  118850. private _points;
  118851. private _outlinepoints;
  118852. private _holes;
  118853. private _name;
  118854. private _scene;
  118855. private _epoints;
  118856. private _eholes;
  118857. private _addToepoint;
  118858. /**
  118859. * Babylon reference to the earcut plugin.
  118860. */
  118861. bjsEarcut: any;
  118862. /**
  118863. * Creates a PolygonMeshBuilder
  118864. * @param name name of the builder
  118865. * @param contours Path of the polygon
  118866. * @param scene scene to add to when creating the mesh
  118867. * @param earcutInjection can be used to inject your own earcut reference
  118868. */
  118869. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118870. /**
  118871. * Adds a whole within the polygon
  118872. * @param hole Array of points defining the hole
  118873. * @returns this
  118874. */
  118875. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118876. /**
  118877. * Creates the polygon
  118878. * @param updatable If the mesh should be updatable
  118879. * @param depth The depth of the mesh created
  118880. * @returns the created mesh
  118881. */
  118882. build(updatable?: boolean, depth?: number): Mesh;
  118883. /**
  118884. * Creates the polygon
  118885. * @param depth The depth of the mesh created
  118886. * @returns the created VertexData
  118887. */
  118888. buildVertexData(depth?: number): VertexData;
  118889. /**
  118890. * Adds a side to the polygon
  118891. * @param positions points that make the polygon
  118892. * @param normals normals of the polygon
  118893. * @param uvs uvs of the polygon
  118894. * @param indices indices of the polygon
  118895. * @param bounds bounds of the polygon
  118896. * @param points points of the polygon
  118897. * @param depth depth of the polygon
  118898. * @param flip flip of the polygon
  118899. */
  118900. private addSide;
  118901. }
  118902. }
  118903. declare module BABYLON {
  118904. /**
  118905. * Class containing static functions to help procedurally build meshes
  118906. */
  118907. export class PolygonBuilder {
  118908. /**
  118909. * Creates a polygon mesh
  118910. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118911. * * 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
  118912. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118915. * * Remember you can only change the shape positions, not their number when updating a polygon
  118916. * @param name defines the name of the mesh
  118917. * @param options defines the options used to create the mesh
  118918. * @param scene defines the hosting scene
  118919. * @param earcutInjection can be used to inject your own earcut reference
  118920. * @returns the polygon mesh
  118921. */
  118922. static CreatePolygon(name: string, options: {
  118923. shape: Vector3[];
  118924. holes?: Vector3[][];
  118925. depth?: number;
  118926. faceUV?: Vector4[];
  118927. faceColors?: Color4[];
  118928. updatable?: boolean;
  118929. sideOrientation?: number;
  118930. frontUVs?: Vector4;
  118931. backUVs?: Vector4;
  118932. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118933. /**
  118934. * Creates an extruded polygon mesh, with depth in the Y direction.
  118935. * * 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)
  118936. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118937. * @param name defines the name of the mesh
  118938. * @param options defines the options used to create the mesh
  118939. * @param scene defines the hosting scene
  118940. * @param earcutInjection can be used to inject your own earcut reference
  118941. * @returns the polygon mesh
  118942. */
  118943. static ExtrudePolygon(name: string, options: {
  118944. shape: Vector3[];
  118945. holes?: Vector3[][];
  118946. depth?: number;
  118947. faceUV?: Vector4[];
  118948. faceColors?: Color4[];
  118949. updatable?: boolean;
  118950. sideOrientation?: number;
  118951. frontUVs?: Vector4;
  118952. backUVs?: Vector4;
  118953. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118954. }
  118955. }
  118956. declare module BABYLON {
  118957. /**
  118958. * Class containing static functions to help procedurally build meshes
  118959. */
  118960. export class LatheBuilder {
  118961. /**
  118962. * Creates lathe mesh.
  118963. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118964. * * 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
  118965. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118966. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118967. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118968. * * 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
  118969. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118970. * * 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
  118971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118975. * @param name defines the name of the mesh
  118976. * @param options defines the options used to create the mesh
  118977. * @param scene defines the hosting scene
  118978. * @returns the lathe mesh
  118979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118980. */
  118981. static CreateLathe(name: string, options: {
  118982. shape: Vector3[];
  118983. radius?: number;
  118984. tessellation?: number;
  118985. clip?: number;
  118986. arc?: number;
  118987. closed?: boolean;
  118988. updatable?: boolean;
  118989. sideOrientation?: number;
  118990. frontUVs?: Vector4;
  118991. backUVs?: Vector4;
  118992. cap?: number;
  118993. invertUV?: boolean;
  118994. }, scene?: Nullable<Scene>): Mesh;
  118995. }
  118996. }
  118997. declare module BABYLON {
  118998. /**
  118999. * Class containing static functions to help procedurally build meshes
  119000. */
  119001. export class TiledPlaneBuilder {
  119002. /**
  119003. * Creates a tiled plane mesh
  119004. * * The parameter `pattern` will, depending on value, do nothing or
  119005. * * * flip (reflect about central vertical) alternate tiles across and up
  119006. * * * flip every tile on alternate rows
  119007. * * * rotate (180 degs) alternate tiles across and up
  119008. * * * rotate every tile on alternate rows
  119009. * * * flip and rotate alternate tiles across and up
  119010. * * * flip and rotate every tile on alternate rows
  119011. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  119012. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  119013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119015. * * 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)
  119016. * * 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)
  119017. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119018. * @param name defines the name of the mesh
  119019. * @param options defines the options used to create the mesh
  119020. * @param scene defines the hosting scene
  119021. * @returns the box mesh
  119022. */
  119023. static CreateTiledPlane(name: string, options: {
  119024. pattern?: number;
  119025. tileSize?: number;
  119026. tileWidth?: number;
  119027. tileHeight?: number;
  119028. size?: number;
  119029. width?: number;
  119030. height?: number;
  119031. alignHorizontal?: number;
  119032. alignVertical?: number;
  119033. sideOrientation?: number;
  119034. frontUVs?: Vector4;
  119035. backUVs?: Vector4;
  119036. updatable?: boolean;
  119037. }, scene?: Nullable<Scene>): Mesh;
  119038. }
  119039. }
  119040. declare module BABYLON {
  119041. /**
  119042. * Class containing static functions to help procedurally build meshes
  119043. */
  119044. export class TubeBuilder {
  119045. /**
  119046. * Creates a tube mesh.
  119047. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119048. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119049. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119050. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119051. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119052. * * 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)
  119053. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119054. * * 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
  119055. * * 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
  119056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119060. * @param name defines the name of the mesh
  119061. * @param options defines the options used to create the mesh
  119062. * @param scene defines the hosting scene
  119063. * @returns the tube mesh
  119064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119065. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119066. */
  119067. static CreateTube(name: string, options: {
  119068. path: Vector3[];
  119069. radius?: number;
  119070. tessellation?: number;
  119071. radiusFunction?: {
  119072. (i: number, distance: number): number;
  119073. };
  119074. cap?: number;
  119075. arc?: number;
  119076. updatable?: boolean;
  119077. sideOrientation?: number;
  119078. frontUVs?: Vector4;
  119079. backUVs?: Vector4;
  119080. instance?: Mesh;
  119081. invertUV?: boolean;
  119082. }, scene?: Nullable<Scene>): Mesh;
  119083. }
  119084. }
  119085. declare module BABYLON {
  119086. /**
  119087. * Class containing static functions to help procedurally build meshes
  119088. */
  119089. export class IcoSphereBuilder {
  119090. /**
  119091. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119092. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119093. * * 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`)
  119094. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119095. * * 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
  119096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119099. * @param name defines the name of the mesh
  119100. * @param options defines the options used to create the mesh
  119101. * @param scene defines the hosting scene
  119102. * @returns the icosahedron mesh
  119103. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119104. */
  119105. static CreateIcoSphere(name: string, options: {
  119106. radius?: number;
  119107. radiusX?: number;
  119108. radiusY?: number;
  119109. radiusZ?: number;
  119110. flat?: boolean;
  119111. subdivisions?: number;
  119112. sideOrientation?: number;
  119113. frontUVs?: Vector4;
  119114. backUVs?: Vector4;
  119115. updatable?: boolean;
  119116. }, scene?: Nullable<Scene>): Mesh;
  119117. }
  119118. }
  119119. declare module BABYLON {
  119120. /**
  119121. * Class containing static functions to help procedurally build meshes
  119122. */
  119123. export class DecalBuilder {
  119124. /**
  119125. * Creates a decal mesh.
  119126. * 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
  119127. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119128. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119129. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119130. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119131. * @param name defines the name of the mesh
  119132. * @param sourceMesh defines the mesh where the decal must be applied
  119133. * @param options defines the options used to create the mesh
  119134. * @param scene defines the hosting scene
  119135. * @returns the decal mesh
  119136. * @see https://doc.babylonjs.com/how_to/decals
  119137. */
  119138. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119139. position?: Vector3;
  119140. normal?: Vector3;
  119141. size?: Vector3;
  119142. angle?: number;
  119143. }): Mesh;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * Class containing static functions to help procedurally build meshes
  119149. */
  119150. export class MeshBuilder {
  119151. /**
  119152. * Creates a box mesh
  119153. * * The parameter `size` sets the size (float) of each box side (default 1)
  119154. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119155. * * 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)
  119156. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119160. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119161. * @param name defines the name of the mesh
  119162. * @param options defines the options used to create the mesh
  119163. * @param scene defines the hosting scene
  119164. * @returns the box mesh
  119165. */
  119166. static CreateBox(name: string, options: {
  119167. size?: number;
  119168. width?: number;
  119169. height?: number;
  119170. depth?: number;
  119171. faceUV?: Vector4[];
  119172. faceColors?: Color4[];
  119173. sideOrientation?: number;
  119174. frontUVs?: Vector4;
  119175. backUVs?: Vector4;
  119176. updatable?: boolean;
  119177. }, scene?: Nullable<Scene>): Mesh;
  119178. /**
  119179. * Creates a tiled box mesh
  119180. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119182. * @param name defines the name of the mesh
  119183. * @param options defines the options used to create the mesh
  119184. * @param scene defines the hosting scene
  119185. * @returns the tiled box mesh
  119186. */
  119187. static CreateTiledBox(name: string, options: {
  119188. pattern?: number;
  119189. size?: number;
  119190. width?: number;
  119191. height?: number;
  119192. depth: number;
  119193. tileSize?: number;
  119194. tileWidth?: number;
  119195. tileHeight?: number;
  119196. faceUV?: Vector4[];
  119197. faceColors?: Color4[];
  119198. alignHorizontal?: number;
  119199. alignVertical?: number;
  119200. sideOrientation?: number;
  119201. updatable?: boolean;
  119202. }, scene?: Nullable<Scene>): Mesh;
  119203. /**
  119204. * Creates a sphere mesh
  119205. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119206. * * 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`)
  119207. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119208. * * 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
  119209. * * 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)
  119210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119213. * @param name defines the name of the mesh
  119214. * @param options defines the options used to create the mesh
  119215. * @param scene defines the hosting scene
  119216. * @returns the sphere mesh
  119217. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119218. */
  119219. static CreateSphere(name: string, options: {
  119220. segments?: number;
  119221. diameter?: number;
  119222. diameterX?: number;
  119223. diameterY?: number;
  119224. diameterZ?: number;
  119225. arc?: number;
  119226. slice?: number;
  119227. sideOrientation?: number;
  119228. frontUVs?: Vector4;
  119229. backUVs?: Vector4;
  119230. updatable?: boolean;
  119231. }, scene?: Nullable<Scene>): Mesh;
  119232. /**
  119233. * Creates a plane polygonal mesh. By default, this is a disc
  119234. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119235. * * 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
  119236. * * 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
  119237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119240. * @param name defines the name of the mesh
  119241. * @param options defines the options used to create the mesh
  119242. * @param scene defines the hosting scene
  119243. * @returns the plane polygonal mesh
  119244. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119245. */
  119246. static CreateDisc(name: string, options: {
  119247. radius?: number;
  119248. tessellation?: number;
  119249. arc?: number;
  119250. updatable?: boolean;
  119251. sideOrientation?: number;
  119252. frontUVs?: Vector4;
  119253. backUVs?: Vector4;
  119254. }, scene?: Nullable<Scene>): Mesh;
  119255. /**
  119256. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119257. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119258. * * 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`)
  119259. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119260. * * 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
  119261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119264. * @param name defines the name of the mesh
  119265. * @param options defines the options used to create the mesh
  119266. * @param scene defines the hosting scene
  119267. * @returns the icosahedron mesh
  119268. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119269. */
  119270. static CreateIcoSphere(name: string, options: {
  119271. radius?: number;
  119272. radiusX?: number;
  119273. radiusY?: number;
  119274. radiusZ?: number;
  119275. flat?: boolean;
  119276. subdivisions?: number;
  119277. sideOrientation?: number;
  119278. frontUVs?: Vector4;
  119279. backUVs?: Vector4;
  119280. updatable?: boolean;
  119281. }, scene?: Nullable<Scene>): Mesh;
  119282. /**
  119283. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119284. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119285. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119286. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119287. * * 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
  119288. * * 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
  119289. * * 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
  119290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119293. * * 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
  119294. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119295. * * 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
  119296. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119298. * @param name defines the name of the mesh
  119299. * @param options defines the options used to create the mesh
  119300. * @param scene defines the hosting scene
  119301. * @returns the ribbon mesh
  119302. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119304. */
  119305. static CreateRibbon(name: string, options: {
  119306. pathArray: Vector3[][];
  119307. closeArray?: boolean;
  119308. closePath?: boolean;
  119309. offset?: number;
  119310. updatable?: boolean;
  119311. sideOrientation?: number;
  119312. frontUVs?: Vector4;
  119313. backUVs?: Vector4;
  119314. instance?: Mesh;
  119315. invertUV?: boolean;
  119316. uvs?: Vector2[];
  119317. colors?: Color4[];
  119318. }, scene?: Nullable<Scene>): Mesh;
  119319. /**
  119320. * Creates a cylinder or a cone mesh
  119321. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119322. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119323. * * 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.
  119324. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119325. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119326. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119327. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119328. * * 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).
  119329. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119330. * * 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).
  119331. * * 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
  119332. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119333. * * 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
  119334. * * 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.
  119335. * * If `enclose` is false, a ring surface is one element.
  119336. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119337. * * 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
  119338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119341. * @param name defines the name of the mesh
  119342. * @param options defines the options used to create the mesh
  119343. * @param scene defines the hosting scene
  119344. * @returns the cylinder mesh
  119345. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119346. */
  119347. static CreateCylinder(name: string, options: {
  119348. height?: number;
  119349. diameterTop?: number;
  119350. diameterBottom?: number;
  119351. diameter?: number;
  119352. tessellation?: number;
  119353. subdivisions?: number;
  119354. arc?: number;
  119355. faceColors?: Color4[];
  119356. faceUV?: Vector4[];
  119357. updatable?: boolean;
  119358. hasRings?: boolean;
  119359. enclose?: boolean;
  119360. cap?: number;
  119361. sideOrientation?: number;
  119362. frontUVs?: Vector4;
  119363. backUVs?: Vector4;
  119364. }, scene?: Nullable<Scene>): Mesh;
  119365. /**
  119366. * Creates a torus mesh
  119367. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119368. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119369. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119373. * @param name defines the name of the mesh
  119374. * @param options defines the options used to create the mesh
  119375. * @param scene defines the hosting scene
  119376. * @returns the torus mesh
  119377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119378. */
  119379. static CreateTorus(name: string, options: {
  119380. diameter?: number;
  119381. thickness?: number;
  119382. tessellation?: number;
  119383. updatable?: boolean;
  119384. sideOrientation?: number;
  119385. frontUVs?: Vector4;
  119386. backUVs?: Vector4;
  119387. }, scene?: Nullable<Scene>): Mesh;
  119388. /**
  119389. * Creates a torus knot mesh
  119390. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119391. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119392. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119393. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119397. * @param name defines the name of the mesh
  119398. * @param options defines the options used to create the mesh
  119399. * @param scene defines the hosting scene
  119400. * @returns the torus knot mesh
  119401. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119402. */
  119403. static CreateTorusKnot(name: string, options: {
  119404. radius?: number;
  119405. tube?: number;
  119406. radialSegments?: number;
  119407. tubularSegments?: number;
  119408. p?: number;
  119409. q?: number;
  119410. updatable?: boolean;
  119411. sideOrientation?: number;
  119412. frontUVs?: Vector4;
  119413. backUVs?: Vector4;
  119414. }, scene?: Nullable<Scene>): Mesh;
  119415. /**
  119416. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119417. * * 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
  119418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119419. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119420. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119421. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119422. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119423. * * 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
  119424. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119427. * @param name defines the name of the new line system
  119428. * @param options defines the options used to create the line system
  119429. * @param scene defines the hosting scene
  119430. * @returns a new line system mesh
  119431. */
  119432. static CreateLineSystem(name: string, options: {
  119433. lines: Vector3[][];
  119434. updatable?: boolean;
  119435. instance?: Nullable<LinesMesh>;
  119436. colors?: Nullable<Color4[][]>;
  119437. useVertexAlpha?: boolean;
  119438. }, scene: Nullable<Scene>): LinesMesh;
  119439. /**
  119440. * Creates a line mesh
  119441. * 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
  119442. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119443. * * The parameter `points` is an array successive Vector3
  119444. * * 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
  119445. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119446. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119447. * * When updating an instance, remember that only point positions can change, not the number of points
  119448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119450. * @param name defines the name of the new line system
  119451. * @param options defines the options used to create the line system
  119452. * @param scene defines the hosting scene
  119453. * @returns a new line mesh
  119454. */
  119455. static CreateLines(name: string, options: {
  119456. points: Vector3[];
  119457. updatable?: boolean;
  119458. instance?: Nullable<LinesMesh>;
  119459. colors?: Color4[];
  119460. useVertexAlpha?: boolean;
  119461. }, scene?: Nullable<Scene>): LinesMesh;
  119462. /**
  119463. * Creates a dashed line mesh
  119464. * * 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
  119465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119466. * * The parameter `points` is an array successive Vector3
  119467. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119468. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119469. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119470. * * 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
  119471. * * When updating an instance, remember that only point positions can change, not the number of points
  119472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119473. * @param name defines the name of the mesh
  119474. * @param options defines the options used to create the mesh
  119475. * @param scene defines the hosting scene
  119476. * @returns the dashed line mesh
  119477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119478. */
  119479. static CreateDashedLines(name: string, options: {
  119480. points: Vector3[];
  119481. dashSize?: number;
  119482. gapSize?: number;
  119483. dashNb?: number;
  119484. updatable?: boolean;
  119485. instance?: LinesMesh;
  119486. }, scene?: Nullable<Scene>): LinesMesh;
  119487. /**
  119488. * 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.
  119489. * * 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.
  119490. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119491. * * 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.
  119492. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119493. * * 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
  119494. * * 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
  119495. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119500. * @param name defines the name of the mesh
  119501. * @param options defines the options used to create the mesh
  119502. * @param scene defines the hosting scene
  119503. * @returns the extruded shape mesh
  119504. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119506. */
  119507. static ExtrudeShape(name: string, options: {
  119508. shape: Vector3[];
  119509. path: Vector3[];
  119510. scale?: number;
  119511. rotation?: number;
  119512. cap?: number;
  119513. updatable?: boolean;
  119514. sideOrientation?: number;
  119515. frontUVs?: Vector4;
  119516. backUVs?: Vector4;
  119517. instance?: Mesh;
  119518. invertUV?: boolean;
  119519. }, scene?: Nullable<Scene>): Mesh;
  119520. /**
  119521. * Creates an custom extruded shape mesh.
  119522. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119523. * * 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.
  119524. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119525. * * 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
  119526. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119527. * * 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
  119528. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119529. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119530. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119531. * * 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
  119532. * * 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
  119533. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119538. * @param name defines the name of the mesh
  119539. * @param options defines the options used to create the mesh
  119540. * @param scene defines the hosting scene
  119541. * @returns the custom extruded shape mesh
  119542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119543. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119545. */
  119546. static ExtrudeShapeCustom(name: string, options: {
  119547. shape: Vector3[];
  119548. path: Vector3[];
  119549. scaleFunction?: any;
  119550. rotationFunction?: any;
  119551. ribbonCloseArray?: boolean;
  119552. ribbonClosePath?: boolean;
  119553. cap?: number;
  119554. updatable?: boolean;
  119555. sideOrientation?: number;
  119556. frontUVs?: Vector4;
  119557. backUVs?: Vector4;
  119558. instance?: Mesh;
  119559. invertUV?: boolean;
  119560. }, scene?: Nullable<Scene>): Mesh;
  119561. /**
  119562. * Creates lathe mesh.
  119563. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119564. * * 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
  119565. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119566. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119567. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119568. * * 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
  119569. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119570. * * 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
  119571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119575. * @param name defines the name of the mesh
  119576. * @param options defines the options used to create the mesh
  119577. * @param scene defines the hosting scene
  119578. * @returns the lathe mesh
  119579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119580. */
  119581. static CreateLathe(name: string, options: {
  119582. shape: Vector3[];
  119583. radius?: number;
  119584. tessellation?: number;
  119585. clip?: number;
  119586. arc?: number;
  119587. closed?: boolean;
  119588. updatable?: boolean;
  119589. sideOrientation?: number;
  119590. frontUVs?: Vector4;
  119591. backUVs?: Vector4;
  119592. cap?: number;
  119593. invertUV?: boolean;
  119594. }, scene?: Nullable<Scene>): Mesh;
  119595. /**
  119596. * Creates a tiled plane mesh
  119597. * * You can set a limited pattern arrangement with the tiles
  119598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119601. * @param name defines the name of the mesh
  119602. * @param options defines the options used to create the mesh
  119603. * @param scene defines the hosting scene
  119604. * @returns the plane mesh
  119605. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119606. */
  119607. static CreateTiledPlane(name: string, options: {
  119608. pattern?: number;
  119609. tileSize?: number;
  119610. tileWidth?: number;
  119611. tileHeight?: number;
  119612. size?: number;
  119613. width?: number;
  119614. height?: number;
  119615. alignHorizontal?: number;
  119616. alignVertical?: number;
  119617. sideOrientation?: number;
  119618. frontUVs?: Vector4;
  119619. backUVs?: Vector4;
  119620. updatable?: boolean;
  119621. }, scene?: Nullable<Scene>): Mesh;
  119622. /**
  119623. * Creates a plane mesh
  119624. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119625. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119626. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119630. * @param name defines the name of the mesh
  119631. * @param options defines the options used to create the mesh
  119632. * @param scene defines the hosting scene
  119633. * @returns the plane mesh
  119634. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119635. */
  119636. static CreatePlane(name: string, options: {
  119637. size?: number;
  119638. width?: number;
  119639. height?: number;
  119640. sideOrientation?: number;
  119641. frontUVs?: Vector4;
  119642. backUVs?: Vector4;
  119643. updatable?: boolean;
  119644. sourcePlane?: Plane;
  119645. }, scene?: Nullable<Scene>): Mesh;
  119646. /**
  119647. * Creates a ground mesh
  119648. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  119649. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  119650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119651. * @param name defines the name of the mesh
  119652. * @param options defines the options used to create the mesh
  119653. * @param scene defines the hosting scene
  119654. * @returns the ground mesh
  119655. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  119656. */
  119657. static CreateGround(name: string, options: {
  119658. width?: number;
  119659. height?: number;
  119660. subdivisions?: number;
  119661. subdivisionsX?: number;
  119662. subdivisionsY?: number;
  119663. updatable?: boolean;
  119664. }, scene?: Nullable<Scene>): Mesh;
  119665. /**
  119666. * Creates a tiled ground mesh
  119667. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  119668. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  119669. * * 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
  119670. * * 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
  119671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119672. * @param name defines the name of the mesh
  119673. * @param options defines the options used to create the mesh
  119674. * @param scene defines the hosting scene
  119675. * @returns the tiled ground mesh
  119676. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  119677. */
  119678. static CreateTiledGround(name: string, options: {
  119679. xmin: number;
  119680. zmin: number;
  119681. xmax: number;
  119682. zmax: number;
  119683. subdivisions?: {
  119684. w: number;
  119685. h: number;
  119686. };
  119687. precision?: {
  119688. w: number;
  119689. h: number;
  119690. };
  119691. updatable?: boolean;
  119692. }, scene?: Nullable<Scene>): Mesh;
  119693. /**
  119694. * Creates a ground mesh from a height map
  119695. * * The parameter `url` sets the URL of the height map image resource.
  119696. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  119697. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  119698. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  119699. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  119700. * * 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.
  119701. * * 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).
  119702. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119704. * @param name defines the name of the mesh
  119705. * @param url defines the url to the height map
  119706. * @param options defines the options used to create the mesh
  119707. * @param scene defines the hosting scene
  119708. * @returns the ground mesh
  119709. * @see https://doc.babylonjs.com/babylon101/height_map
  119710. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119711. */
  119712. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119713. width?: number;
  119714. height?: number;
  119715. subdivisions?: number;
  119716. minHeight?: number;
  119717. maxHeight?: number;
  119718. colorFilter?: Color3;
  119719. alphaFilter?: number;
  119720. updatable?: boolean;
  119721. onReady?: (mesh: GroundMesh) => void;
  119722. }, scene?: Nullable<Scene>): GroundMesh;
  119723. /**
  119724. * Creates a polygon mesh
  119725. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119726. * * 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
  119727. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119730. * * Remember you can only change the shape positions, not their number when updating a polygon
  119731. * @param name defines the name of the mesh
  119732. * @param options defines the options used to create the mesh
  119733. * @param scene defines the hosting scene
  119734. * @param earcutInjection can be used to inject your own earcut reference
  119735. * @returns the polygon mesh
  119736. */
  119737. static CreatePolygon(name: string, options: {
  119738. shape: Vector3[];
  119739. holes?: Vector3[][];
  119740. depth?: number;
  119741. faceUV?: Vector4[];
  119742. faceColors?: Color4[];
  119743. updatable?: boolean;
  119744. sideOrientation?: number;
  119745. frontUVs?: Vector4;
  119746. backUVs?: Vector4;
  119747. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119748. /**
  119749. * Creates an extruded polygon mesh, with depth in the Y direction.
  119750. * * 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)
  119751. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119752. * @param name defines the name of the mesh
  119753. * @param options defines the options used to create the mesh
  119754. * @param scene defines the hosting scene
  119755. * @param earcutInjection can be used to inject your own earcut reference
  119756. * @returns the polygon mesh
  119757. */
  119758. static ExtrudePolygon(name: string, options: {
  119759. shape: Vector3[];
  119760. holes?: Vector3[][];
  119761. depth?: number;
  119762. faceUV?: Vector4[];
  119763. faceColors?: Color4[];
  119764. updatable?: boolean;
  119765. sideOrientation?: number;
  119766. frontUVs?: Vector4;
  119767. backUVs?: Vector4;
  119768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119769. /**
  119770. * Creates a tube mesh.
  119771. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119772. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119773. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119774. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119775. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119776. * * 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)
  119777. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119778. * * 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
  119779. * * 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
  119780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119784. * @param name defines the name of the mesh
  119785. * @param options defines the options used to create the mesh
  119786. * @param scene defines the hosting scene
  119787. * @returns the tube mesh
  119788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119789. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119790. */
  119791. static CreateTube(name: string, options: {
  119792. path: Vector3[];
  119793. radius?: number;
  119794. tessellation?: number;
  119795. radiusFunction?: {
  119796. (i: number, distance: number): number;
  119797. };
  119798. cap?: number;
  119799. arc?: number;
  119800. updatable?: boolean;
  119801. sideOrientation?: number;
  119802. frontUVs?: Vector4;
  119803. backUVs?: Vector4;
  119804. instance?: Mesh;
  119805. invertUV?: boolean;
  119806. }, scene?: Nullable<Scene>): Mesh;
  119807. /**
  119808. * Creates a polyhedron mesh
  119809. * * 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
  119810. * * The parameter `size` (positive float, default 1) sets the polygon size
  119811. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119812. * * 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`
  119813. * * 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
  119814. * * 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)`)
  119815. * * 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
  119816. * * 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
  119817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119820. * @param name defines the name of the mesh
  119821. * @param options defines the options used to create the mesh
  119822. * @param scene defines the hosting scene
  119823. * @returns the polyhedron mesh
  119824. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119825. */
  119826. static CreatePolyhedron(name: string, options: {
  119827. type?: number;
  119828. size?: number;
  119829. sizeX?: number;
  119830. sizeY?: number;
  119831. sizeZ?: number;
  119832. custom?: any;
  119833. faceUV?: Vector4[];
  119834. faceColors?: Color4[];
  119835. flat?: boolean;
  119836. updatable?: boolean;
  119837. sideOrientation?: number;
  119838. frontUVs?: Vector4;
  119839. backUVs?: Vector4;
  119840. }, scene?: Nullable<Scene>): Mesh;
  119841. /**
  119842. * Creates a decal mesh.
  119843. * 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
  119844. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119845. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119846. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119847. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119848. * @param name defines the name of the mesh
  119849. * @param sourceMesh defines the mesh where the decal must be applied
  119850. * @param options defines the options used to create the mesh
  119851. * @param scene defines the hosting scene
  119852. * @returns the decal mesh
  119853. * @see https://doc.babylonjs.com/how_to/decals
  119854. */
  119855. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119856. position?: Vector3;
  119857. normal?: Vector3;
  119858. size?: Vector3;
  119859. angle?: number;
  119860. }): Mesh;
  119861. }
  119862. }
  119863. declare module BABYLON {
  119864. /**
  119865. * A simplifier interface for future simplification implementations
  119866. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119867. */
  119868. export interface ISimplifier {
  119869. /**
  119870. * Simplification of a given mesh according to the given settings.
  119871. * Since this requires computation, it is assumed that the function runs async.
  119872. * @param settings The settings of the simplification, including quality and distance
  119873. * @param successCallback A callback that will be called after the mesh was simplified.
  119874. * @param errorCallback in case of an error, this callback will be called. optional.
  119875. */
  119876. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119877. }
  119878. /**
  119879. * Expected simplification settings.
  119880. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119881. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119882. */
  119883. export interface ISimplificationSettings {
  119884. /**
  119885. * Gets or sets the expected quality
  119886. */
  119887. quality: number;
  119888. /**
  119889. * Gets or sets the distance when this optimized version should be used
  119890. */
  119891. distance: number;
  119892. /**
  119893. * Gets an already optimized mesh
  119894. */
  119895. optimizeMesh?: boolean;
  119896. }
  119897. /**
  119898. * Class used to specify simplification options
  119899. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119900. */
  119901. export class SimplificationSettings implements ISimplificationSettings {
  119902. /** expected quality */
  119903. quality: number;
  119904. /** distance when this optimized version should be used */
  119905. distance: number;
  119906. /** already optimized mesh */
  119907. optimizeMesh?: boolean | undefined;
  119908. /**
  119909. * Creates a SimplificationSettings
  119910. * @param quality expected quality
  119911. * @param distance distance when this optimized version should be used
  119912. * @param optimizeMesh already optimized mesh
  119913. */
  119914. constructor(
  119915. /** expected quality */
  119916. quality: number,
  119917. /** distance when this optimized version should be used */
  119918. distance: number,
  119919. /** already optimized mesh */
  119920. optimizeMesh?: boolean | undefined);
  119921. }
  119922. /**
  119923. * Interface used to define a simplification task
  119924. */
  119925. export interface ISimplificationTask {
  119926. /**
  119927. * Array of settings
  119928. */
  119929. settings: Array<ISimplificationSettings>;
  119930. /**
  119931. * Simplification type
  119932. */
  119933. simplificationType: SimplificationType;
  119934. /**
  119935. * Mesh to simplify
  119936. */
  119937. mesh: Mesh;
  119938. /**
  119939. * Callback called on success
  119940. */
  119941. successCallback?: () => void;
  119942. /**
  119943. * Defines if parallel processing can be used
  119944. */
  119945. parallelProcessing: boolean;
  119946. }
  119947. /**
  119948. * Queue used to order the simplification tasks
  119949. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119950. */
  119951. export class SimplificationQueue {
  119952. private _simplificationArray;
  119953. /**
  119954. * Gets a boolean indicating that the process is still running
  119955. */
  119956. running: boolean;
  119957. /**
  119958. * Creates a new queue
  119959. */
  119960. constructor();
  119961. /**
  119962. * Adds a new simplification task
  119963. * @param task defines a task to add
  119964. */
  119965. addTask(task: ISimplificationTask): void;
  119966. /**
  119967. * Execute next task
  119968. */
  119969. executeNext(): void;
  119970. /**
  119971. * Execute a simplification task
  119972. * @param task defines the task to run
  119973. */
  119974. runSimplification(task: ISimplificationTask): void;
  119975. private getSimplifier;
  119976. }
  119977. /**
  119978. * The implemented types of simplification
  119979. * At the moment only Quadratic Error Decimation is implemented
  119980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119981. */
  119982. export enum SimplificationType {
  119983. /** Quadratic error decimation */
  119984. QUADRATIC = 0
  119985. }
  119986. }
  119987. declare module BABYLON {
  119988. interface Scene {
  119989. /** @hidden (Backing field) */
  119990. _simplificationQueue: SimplificationQueue;
  119991. /**
  119992. * Gets or sets the simplification queue attached to the scene
  119993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119994. */
  119995. simplificationQueue: SimplificationQueue;
  119996. }
  119997. interface Mesh {
  119998. /**
  119999. * Simplify the mesh according to the given array of settings.
  120000. * Function will return immediately and will simplify async
  120001. * @param settings a collection of simplification settings
  120002. * @param parallelProcessing should all levels calculate parallel or one after the other
  120003. * @param simplificationType the type of simplification to run
  120004. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  120005. * @returns the current mesh
  120006. */
  120007. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  120008. }
  120009. /**
  120010. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  120011. * created in a scene
  120012. */
  120013. export class SimplicationQueueSceneComponent implements ISceneComponent {
  120014. /**
  120015. * The component name helpfull to identify the component in the list of scene components.
  120016. */
  120017. readonly name: string;
  120018. /**
  120019. * The scene the component belongs to.
  120020. */
  120021. scene: Scene;
  120022. /**
  120023. * Creates a new instance of the component for the given scene
  120024. * @param scene Defines the scene to register the component in
  120025. */
  120026. constructor(scene: Scene);
  120027. /**
  120028. * Registers the component in a given scene
  120029. */
  120030. register(): void;
  120031. /**
  120032. * Rebuilds the elements related to this component in case of
  120033. * context lost for instance.
  120034. */
  120035. rebuild(): void;
  120036. /**
  120037. * Disposes the component and the associated ressources
  120038. */
  120039. dispose(): void;
  120040. private _beforeCameraUpdate;
  120041. }
  120042. }
  120043. declare module BABYLON {
  120044. /**
  120045. * Navigation plugin interface to add navigation constrained by a navigation mesh
  120046. */
  120047. export interface INavigationEnginePlugin {
  120048. /**
  120049. * plugin name
  120050. */
  120051. name: string;
  120052. /**
  120053. * Creates a navigation mesh
  120054. * @param meshes array of all the geometry used to compute the navigatio mesh
  120055. * @param parameters bunch of parameters used to filter geometry
  120056. */
  120057. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120058. /**
  120059. * Create a navigation mesh debug mesh
  120060. * @param scene is where the mesh will be added
  120061. * @returns debug display mesh
  120062. */
  120063. createDebugNavMesh(scene: Scene): Mesh;
  120064. /**
  120065. * Get a navigation mesh constrained position, closest to the parameter position
  120066. * @param position world position
  120067. * @returns the closest point to position constrained by the navigation mesh
  120068. */
  120069. getClosestPoint(position: Vector3): Vector3;
  120070. /**
  120071. * Get a navigation mesh constrained position, within a particular radius
  120072. * @param position world position
  120073. * @param maxRadius the maximum distance to the constrained world position
  120074. * @returns the closest point to position constrained by the navigation mesh
  120075. */
  120076. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120077. /**
  120078. * Compute the final position from a segment made of destination-position
  120079. * @param position world position
  120080. * @param destination world position
  120081. * @returns the resulting point along the navmesh
  120082. */
  120083. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120084. /**
  120085. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120086. * @param start world position
  120087. * @param end world position
  120088. * @returns array containing world position composing the path
  120089. */
  120090. computePath(start: Vector3, end: Vector3): Vector3[];
  120091. /**
  120092. * If this plugin is supported
  120093. * @returns true if plugin is supported
  120094. */
  120095. isSupported(): boolean;
  120096. /**
  120097. * Create a new Crowd so you can add agents
  120098. * @param maxAgents the maximum agent count in the crowd
  120099. * @param maxAgentRadius the maximum radius an agent can have
  120100. * @param scene to attach the crowd to
  120101. * @returns the crowd you can add agents to
  120102. */
  120103. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120104. /**
  120105. * Release all resources
  120106. */
  120107. dispose(): void;
  120108. }
  120109. /**
  120110. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  120111. */
  120112. export interface ICrowd {
  120113. /**
  120114. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120115. * You can attach anything to that node. The node position is updated in the scene update tick.
  120116. * @param pos world position that will be constrained by the navigation mesh
  120117. * @param parameters agent parameters
  120118. * @param transform hooked to the agent that will be update by the scene
  120119. * @returns agent index
  120120. */
  120121. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120122. /**
  120123. * Returns the agent position in world space
  120124. * @param index agent index returned by addAgent
  120125. * @returns world space position
  120126. */
  120127. getAgentPosition(index: number): Vector3;
  120128. /**
  120129. * Gets the agent velocity in world space
  120130. * @param index agent index returned by addAgent
  120131. * @returns world space velocity
  120132. */
  120133. getAgentVelocity(index: number): Vector3;
  120134. /**
  120135. * remove a particular agent previously created
  120136. * @param index agent index returned by addAgent
  120137. */
  120138. removeAgent(index: number): void;
  120139. /**
  120140. * get the list of all agents attached to this crowd
  120141. * @returns list of agent indices
  120142. */
  120143. getAgents(): number[];
  120144. /**
  120145. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120146. * @param deltaTime in seconds
  120147. */
  120148. update(deltaTime: number): void;
  120149. /**
  120150. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120151. * @param index agent index returned by addAgent
  120152. * @param destination targeted world position
  120153. */
  120154. agentGoto(index: number, destination: Vector3): void;
  120155. /**
  120156. * Release all resources
  120157. */
  120158. dispose(): void;
  120159. }
  120160. /**
  120161. * Configures an agent
  120162. */
  120163. export interface IAgentParameters {
  120164. /**
  120165. * Agent radius. [Limit: >= 0]
  120166. */
  120167. radius: number;
  120168. /**
  120169. * Agent height. [Limit: > 0]
  120170. */
  120171. height: number;
  120172. /**
  120173. * Maximum allowed acceleration. [Limit: >= 0]
  120174. */
  120175. maxAcceleration: number;
  120176. /**
  120177. * Maximum allowed speed. [Limit: >= 0]
  120178. */
  120179. maxSpeed: number;
  120180. /**
  120181. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  120182. */
  120183. collisionQueryRange: number;
  120184. /**
  120185. * The path visibility optimization range. [Limit: > 0]
  120186. */
  120187. pathOptimizationRange: number;
  120188. /**
  120189. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  120190. */
  120191. separationWeight: number;
  120192. }
  120193. /**
  120194. * Configures the navigation mesh creation
  120195. */
  120196. export interface INavMeshParameters {
  120197. /**
  120198. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  120199. */
  120200. cs: number;
  120201. /**
  120202. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  120203. */
  120204. ch: number;
  120205. /**
  120206. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  120207. */
  120208. walkableSlopeAngle: number;
  120209. /**
  120210. * Minimum floor to 'ceiling' height that will still allow the floor area to
  120211. * be considered walkable. [Limit: >= 3] [Units: vx]
  120212. */
  120213. walkableHeight: number;
  120214. /**
  120215. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  120216. */
  120217. walkableClimb: number;
  120218. /**
  120219. * The distance to erode/shrink the walkable area of the heightfield away from
  120220. * obstructions. [Limit: >=0] [Units: vx]
  120221. */
  120222. walkableRadius: number;
  120223. /**
  120224. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  120225. */
  120226. maxEdgeLen: number;
  120227. /**
  120228. * The maximum distance a simplfied contour's border edges should deviate
  120229. * the original raw contour. [Limit: >=0] [Units: vx]
  120230. */
  120231. maxSimplificationError: number;
  120232. /**
  120233. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  120234. */
  120235. minRegionArea: number;
  120236. /**
  120237. * Any regions with a span count smaller than this value will, if possible,
  120238. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120239. */
  120240. mergeRegionArea: number;
  120241. /**
  120242. * The maximum number of vertices allowed for polygons generated during the
  120243. * contour to polygon conversion process. [Limit: >= 3]
  120244. */
  120245. maxVertsPerPoly: number;
  120246. /**
  120247. * Sets the sampling distance to use when generating the detail mesh.
  120248. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120249. */
  120250. detailSampleDist: number;
  120251. /**
  120252. * The maximum distance the detail mesh surface should deviate from heightfield
  120253. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120254. */
  120255. detailSampleMaxError: number;
  120256. }
  120257. }
  120258. declare module BABYLON {
  120259. /**
  120260. * RecastJS navigation plugin
  120261. */
  120262. export class RecastJSPlugin implements INavigationEnginePlugin {
  120263. /**
  120264. * Reference to the Recast library
  120265. */
  120266. bjsRECAST: any;
  120267. /**
  120268. * plugin name
  120269. */
  120270. name: string;
  120271. /**
  120272. * the first navmesh created. We might extend this to support multiple navmeshes
  120273. */
  120274. navMesh: any;
  120275. /**
  120276. * Initializes the recastJS plugin
  120277. * @param recastInjection can be used to inject your own recast reference
  120278. */
  120279. constructor(recastInjection?: any);
  120280. /**
  120281. * Creates a navigation mesh
  120282. * @param meshes array of all the geometry used to compute the navigatio mesh
  120283. * @param parameters bunch of parameters used to filter geometry
  120284. */
  120285. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120286. /**
  120287. * Create a navigation mesh debug mesh
  120288. * @param scene is where the mesh will be added
  120289. * @returns debug display mesh
  120290. */
  120291. createDebugNavMesh(scene: Scene): Mesh;
  120292. /**
  120293. * Get a navigation mesh constrained position, closest to the parameter position
  120294. * @param position world position
  120295. * @returns the closest point to position constrained by the navigation mesh
  120296. */
  120297. getClosestPoint(position: Vector3): Vector3;
  120298. /**
  120299. * Get a navigation mesh constrained position, within a particular radius
  120300. * @param position world position
  120301. * @param maxRadius the maximum distance to the constrained world position
  120302. * @returns the closest point to position constrained by the navigation mesh
  120303. */
  120304. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120305. /**
  120306. * Compute the final position from a segment made of destination-position
  120307. * @param position world position
  120308. * @param destination world position
  120309. * @returns the resulting point along the navmesh
  120310. */
  120311. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120312. /**
  120313. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120314. * @param start world position
  120315. * @param end world position
  120316. * @returns array containing world position composing the path
  120317. */
  120318. computePath(start: Vector3, end: Vector3): Vector3[];
  120319. /**
  120320. * Create a new Crowd so you can add agents
  120321. * @param maxAgents the maximum agent count in the crowd
  120322. * @param maxAgentRadius the maximum radius an agent can have
  120323. * @param scene to attach the crowd to
  120324. * @returns the crowd you can add agents to
  120325. */
  120326. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120327. /**
  120328. * Disposes
  120329. */
  120330. dispose(): void;
  120331. /**
  120332. * If this plugin is supported
  120333. * @returns true if plugin is supported
  120334. */
  120335. isSupported(): boolean;
  120336. }
  120337. /**
  120338. * Recast detour crowd implementation
  120339. */
  120340. export class RecastJSCrowd implements ICrowd {
  120341. /**
  120342. * Recast/detour plugin
  120343. */
  120344. bjsRECASTPlugin: RecastJSPlugin;
  120345. /**
  120346. * Link to the detour crowd
  120347. */
  120348. recastCrowd: any;
  120349. /**
  120350. * One transform per agent
  120351. */
  120352. transforms: TransformNode[];
  120353. /**
  120354. * All agents created
  120355. */
  120356. agents: number[];
  120357. /**
  120358. * Link to the scene is kept to unregister the crowd from the scene
  120359. */
  120360. private _scene;
  120361. /**
  120362. * Observer for crowd updates
  120363. */
  120364. private _onBeforeAnimationsObserver;
  120365. /**
  120366. * Constructor
  120367. * @param plugin recastJS plugin
  120368. * @param maxAgents the maximum agent count in the crowd
  120369. * @param maxAgentRadius the maximum radius an agent can have
  120370. * @param scene to attach the crowd to
  120371. * @returns the crowd you can add agents to
  120372. */
  120373. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  120374. /**
  120375. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120376. * You can attach anything to that node. The node position is updated in the scene update tick.
  120377. * @param pos world position that will be constrained by the navigation mesh
  120378. * @param parameters agent parameters
  120379. * @param transform hooked to the agent that will be update by the scene
  120380. * @returns agent index
  120381. */
  120382. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120383. /**
  120384. * Returns the agent position in world space
  120385. * @param index agent index returned by addAgent
  120386. * @returns world space position
  120387. */
  120388. getAgentPosition(index: number): Vector3;
  120389. /**
  120390. * Returns the agent velocity in world space
  120391. * @param index agent index returned by addAgent
  120392. * @returns world space velocity
  120393. */
  120394. getAgentVelocity(index: number): Vector3;
  120395. /**
  120396. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120397. * @param index agent index returned by addAgent
  120398. * @param destination targeted world position
  120399. */
  120400. agentGoto(index: number, destination: Vector3): void;
  120401. /**
  120402. * remove a particular agent previously created
  120403. * @param index agent index returned by addAgent
  120404. */
  120405. removeAgent(index: number): void;
  120406. /**
  120407. * get the list of all agents attached to this crowd
  120408. * @returns list of agent indices
  120409. */
  120410. getAgents(): number[];
  120411. /**
  120412. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120413. * @param deltaTime in seconds
  120414. */
  120415. update(deltaTime: number): void;
  120416. /**
  120417. * Release all resources
  120418. */
  120419. dispose(): void;
  120420. }
  120421. }
  120422. declare module BABYLON {
  120423. /**
  120424. * Class used to enable access to IndexedDB
  120425. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120426. */
  120427. export class Database implements IOfflineProvider {
  120428. private _callbackManifestChecked;
  120429. private _currentSceneUrl;
  120430. private _db;
  120431. private _enableSceneOffline;
  120432. private _enableTexturesOffline;
  120433. private _manifestVersionFound;
  120434. private _mustUpdateRessources;
  120435. private _hasReachedQuota;
  120436. private _isSupported;
  120437. private _idbFactory;
  120438. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  120439. private static IsUASupportingBlobStorage;
  120440. /**
  120441. * Gets a boolean indicating if Database storate is enabled (off by default)
  120442. */
  120443. static IDBStorageEnabled: boolean;
  120444. /**
  120445. * Gets a boolean indicating if scene must be saved in the database
  120446. */
  120447. readonly enableSceneOffline: boolean;
  120448. /**
  120449. * Gets a boolean indicating if textures must be saved in the database
  120450. */
  120451. readonly enableTexturesOffline: boolean;
  120452. /**
  120453. * Creates a new Database
  120454. * @param urlToScene defines the url to load the scene
  120455. * @param callbackManifestChecked defines the callback to use when manifest is checked
  120456. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  120457. */
  120458. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  120459. private static _ParseURL;
  120460. private static _ReturnFullUrlLocation;
  120461. private _checkManifestFile;
  120462. /**
  120463. * Open the database and make it available
  120464. * @param successCallback defines the callback to call on success
  120465. * @param errorCallback defines the callback to call on error
  120466. */
  120467. open(successCallback: () => void, errorCallback: () => void): void;
  120468. /**
  120469. * Loads an image from the database
  120470. * @param url defines the url to load from
  120471. * @param image defines the target DOM image
  120472. */
  120473. loadImage(url: string, image: HTMLImageElement): void;
  120474. private _loadImageFromDBAsync;
  120475. private _saveImageIntoDBAsync;
  120476. private _checkVersionFromDB;
  120477. private _loadVersionFromDBAsync;
  120478. private _saveVersionIntoDBAsync;
  120479. /**
  120480. * Loads a file from database
  120481. * @param url defines the URL to load from
  120482. * @param sceneLoaded defines a callback to call on success
  120483. * @param progressCallBack defines a callback to call when progress changed
  120484. * @param errorCallback defines a callback to call on error
  120485. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  120486. */
  120487. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  120488. private _loadFileAsync;
  120489. private _saveFileAsync;
  120490. /**
  120491. * Validates if xhr data is correct
  120492. * @param xhr defines the request to validate
  120493. * @param dataType defines the expected data type
  120494. * @returns true if data is correct
  120495. */
  120496. private static _ValidateXHRData;
  120497. }
  120498. }
  120499. declare module BABYLON {
  120500. /** @hidden */
  120501. export var gpuUpdateParticlesPixelShader: {
  120502. name: string;
  120503. shader: string;
  120504. };
  120505. }
  120506. declare module BABYLON {
  120507. /** @hidden */
  120508. export var gpuUpdateParticlesVertexShader: {
  120509. name: string;
  120510. shader: string;
  120511. };
  120512. }
  120513. declare module BABYLON {
  120514. /** @hidden */
  120515. export var clipPlaneFragmentDeclaration2: {
  120516. name: string;
  120517. shader: string;
  120518. };
  120519. }
  120520. declare module BABYLON {
  120521. /** @hidden */
  120522. export var gpuRenderParticlesPixelShader: {
  120523. name: string;
  120524. shader: string;
  120525. };
  120526. }
  120527. declare module BABYLON {
  120528. /** @hidden */
  120529. export var clipPlaneVertexDeclaration2: {
  120530. name: string;
  120531. shader: string;
  120532. };
  120533. }
  120534. declare module BABYLON {
  120535. /** @hidden */
  120536. export var gpuRenderParticlesVertexShader: {
  120537. name: string;
  120538. shader: string;
  120539. };
  120540. }
  120541. declare module BABYLON {
  120542. /**
  120543. * This represents a GPU particle system in Babylon
  120544. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  120545. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  120546. */
  120547. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  120548. /**
  120549. * The layer mask we are rendering the particles through.
  120550. */
  120551. layerMask: number;
  120552. private _capacity;
  120553. private _activeCount;
  120554. private _currentActiveCount;
  120555. private _accumulatedCount;
  120556. private _renderEffect;
  120557. private _updateEffect;
  120558. private _buffer0;
  120559. private _buffer1;
  120560. private _spriteBuffer;
  120561. private _updateVAO;
  120562. private _renderVAO;
  120563. private _targetIndex;
  120564. private _sourceBuffer;
  120565. private _targetBuffer;
  120566. private _engine;
  120567. private _currentRenderId;
  120568. private _started;
  120569. private _stopped;
  120570. private _timeDelta;
  120571. private _randomTexture;
  120572. private _randomTexture2;
  120573. private _attributesStrideSize;
  120574. private _updateEffectOptions;
  120575. private _randomTextureSize;
  120576. private _actualFrame;
  120577. private readonly _rawTextureWidth;
  120578. /**
  120579. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  120580. */
  120581. static readonly IsSupported: boolean;
  120582. /**
  120583. * An event triggered when the system is disposed.
  120584. */
  120585. onDisposeObservable: Observable<GPUParticleSystem>;
  120586. /**
  120587. * Gets the maximum number of particles active at the same time.
  120588. * @returns The max number of active particles.
  120589. */
  120590. getCapacity(): number;
  120591. /**
  120592. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120593. * to override the particles.
  120594. */
  120595. forceDepthWrite: boolean;
  120596. /**
  120597. * Gets or set the number of active particles
  120598. */
  120599. activeParticleCount: number;
  120600. private _preWarmDone;
  120601. /**
  120602. * Is this system ready to be used/rendered
  120603. * @return true if the system is ready
  120604. */
  120605. isReady(): boolean;
  120606. /**
  120607. * Gets if the system has been started. (Note: this will still be true after stop is called)
  120608. * @returns True if it has been started, otherwise false.
  120609. */
  120610. isStarted(): boolean;
  120611. /**
  120612. * Starts the particle system and begins to emit
  120613. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  120614. */
  120615. start(delay?: number): void;
  120616. /**
  120617. * Stops the particle system.
  120618. */
  120619. stop(): void;
  120620. /**
  120621. * Remove all active particles
  120622. */
  120623. reset(): void;
  120624. /**
  120625. * Returns the string "GPUParticleSystem"
  120626. * @returns a string containing the class name
  120627. */
  120628. getClassName(): string;
  120629. private _colorGradientsTexture;
  120630. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  120631. /**
  120632. * Adds a new color gradient
  120633. * @param gradient defines the gradient to use (between 0 and 1)
  120634. * @param color1 defines the color to affect to the specified gradient
  120635. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  120636. * @returns the current particle system
  120637. */
  120638. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  120639. /**
  120640. * Remove a specific color gradient
  120641. * @param gradient defines the gradient to remove
  120642. * @returns the current particle system
  120643. */
  120644. removeColorGradient(gradient: number): GPUParticleSystem;
  120645. private _angularSpeedGradientsTexture;
  120646. private _sizeGradientsTexture;
  120647. private _velocityGradientsTexture;
  120648. private _limitVelocityGradientsTexture;
  120649. private _dragGradientsTexture;
  120650. private _addFactorGradient;
  120651. /**
  120652. * Adds a new size gradient
  120653. * @param gradient defines the gradient to use (between 0 and 1)
  120654. * @param factor defines the size factor to affect to the specified gradient
  120655. * @returns the current particle system
  120656. */
  120657. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  120658. /**
  120659. * Remove a specific size gradient
  120660. * @param gradient defines the gradient to remove
  120661. * @returns the current particle system
  120662. */
  120663. removeSizeGradient(gradient: number): GPUParticleSystem;
  120664. /**
  120665. * Adds a new angular speed gradient
  120666. * @param gradient defines the gradient to use (between 0 and 1)
  120667. * @param factor defines the angular speed to affect to the specified gradient
  120668. * @returns the current particle system
  120669. */
  120670. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  120671. /**
  120672. * Remove a specific angular speed gradient
  120673. * @param gradient defines the gradient to remove
  120674. * @returns the current particle system
  120675. */
  120676. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  120677. /**
  120678. * Adds a new velocity gradient
  120679. * @param gradient defines the gradient to use (between 0 and 1)
  120680. * @param factor defines the velocity to affect to the specified gradient
  120681. * @returns the current particle system
  120682. */
  120683. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120684. /**
  120685. * Remove a specific velocity gradient
  120686. * @param gradient defines the gradient to remove
  120687. * @returns the current particle system
  120688. */
  120689. removeVelocityGradient(gradient: number): GPUParticleSystem;
  120690. /**
  120691. * Adds a new limit velocity gradient
  120692. * @param gradient defines the gradient to use (between 0 and 1)
  120693. * @param factor defines the limit velocity value to affect to the specified gradient
  120694. * @returns the current particle system
  120695. */
  120696. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120697. /**
  120698. * Remove a specific limit velocity gradient
  120699. * @param gradient defines the gradient to remove
  120700. * @returns the current particle system
  120701. */
  120702. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  120703. /**
  120704. * Adds a new drag gradient
  120705. * @param gradient defines the gradient to use (between 0 and 1)
  120706. * @param factor defines the drag value to affect to the specified gradient
  120707. * @returns the current particle system
  120708. */
  120709. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  120710. /**
  120711. * Remove a specific drag gradient
  120712. * @param gradient defines the gradient to remove
  120713. * @returns the current particle system
  120714. */
  120715. removeDragGradient(gradient: number): GPUParticleSystem;
  120716. /**
  120717. * Not supported by GPUParticleSystem
  120718. * @param gradient defines the gradient to use (between 0 and 1)
  120719. * @param factor defines the emit rate value to affect to the specified gradient
  120720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120721. * @returns the current particle system
  120722. */
  120723. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120724. /**
  120725. * Not supported by GPUParticleSystem
  120726. * @param gradient defines the gradient to remove
  120727. * @returns the current particle system
  120728. */
  120729. removeEmitRateGradient(gradient: number): IParticleSystem;
  120730. /**
  120731. * Not supported by GPUParticleSystem
  120732. * @param gradient defines the gradient to use (between 0 and 1)
  120733. * @param factor defines the start size value to affect to the specified gradient
  120734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120735. * @returns the current particle system
  120736. */
  120737. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120738. /**
  120739. * Not supported by GPUParticleSystem
  120740. * @param gradient defines the gradient to remove
  120741. * @returns the current particle system
  120742. */
  120743. removeStartSizeGradient(gradient: number): IParticleSystem;
  120744. /**
  120745. * Not supported by GPUParticleSystem
  120746. * @param gradient defines the gradient to use (between 0 and 1)
  120747. * @param min defines the color remap minimal range
  120748. * @param max defines the color remap maximal range
  120749. * @returns the current particle system
  120750. */
  120751. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120752. /**
  120753. * Not supported by GPUParticleSystem
  120754. * @param gradient defines the gradient to remove
  120755. * @returns the current particle system
  120756. */
  120757. removeColorRemapGradient(): IParticleSystem;
  120758. /**
  120759. * Not supported by GPUParticleSystem
  120760. * @param gradient defines the gradient to use (between 0 and 1)
  120761. * @param min defines the alpha remap minimal range
  120762. * @param max defines the alpha remap maximal range
  120763. * @returns the current particle system
  120764. */
  120765. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120766. /**
  120767. * Not supported by GPUParticleSystem
  120768. * @param gradient defines the gradient to remove
  120769. * @returns the current particle system
  120770. */
  120771. removeAlphaRemapGradient(): IParticleSystem;
  120772. /**
  120773. * Not supported by GPUParticleSystem
  120774. * @param gradient defines the gradient to use (between 0 and 1)
  120775. * @param color defines the color to affect to the specified gradient
  120776. * @returns the current particle system
  120777. */
  120778. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  120779. /**
  120780. * Not supported by GPUParticleSystem
  120781. * @param gradient defines the gradient to remove
  120782. * @returns the current particle system
  120783. */
  120784. removeRampGradient(): IParticleSystem;
  120785. /**
  120786. * Not supported by GPUParticleSystem
  120787. * @returns the list of ramp gradients
  120788. */
  120789. getRampGradients(): Nullable<Array<Color3Gradient>>;
  120790. /**
  120791. * Not supported by GPUParticleSystem
  120792. * Gets or sets a boolean indicating that ramp gradients must be used
  120793. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  120794. */
  120795. useRampGradients: boolean;
  120796. /**
  120797. * Not supported by GPUParticleSystem
  120798. * @param gradient defines the gradient to use (between 0 and 1)
  120799. * @param factor defines the life time factor to affect to the specified gradient
  120800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120801. * @returns the current particle system
  120802. */
  120803. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120804. /**
  120805. * Not supported by GPUParticleSystem
  120806. * @param gradient defines the gradient to remove
  120807. * @returns the current particle system
  120808. */
  120809. removeLifeTimeGradient(gradient: number): IParticleSystem;
  120810. /**
  120811. * Instantiates a GPU particle system.
  120812. * 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.
  120813. * @param name The name of the particle system
  120814. * @param options The options used to create the system
  120815. * @param scene The scene the particle system belongs to
  120816. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  120817. */
  120818. constructor(name: string, options: Partial<{
  120819. capacity: number;
  120820. randomTextureSize: number;
  120821. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  120822. protected _reset(): void;
  120823. private _createUpdateVAO;
  120824. private _createRenderVAO;
  120825. private _initialize;
  120826. /** @hidden */
  120827. _recreateUpdateEffect(): void;
  120828. /** @hidden */
  120829. _recreateRenderEffect(): void;
  120830. /**
  120831. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  120832. * @param preWarm defines if we are in the pre-warmimg phase
  120833. */
  120834. animate(preWarm?: boolean): void;
  120835. private _createFactorGradientTexture;
  120836. private _createSizeGradientTexture;
  120837. private _createAngularSpeedGradientTexture;
  120838. private _createVelocityGradientTexture;
  120839. private _createLimitVelocityGradientTexture;
  120840. private _createDragGradientTexture;
  120841. private _createColorGradientTexture;
  120842. /**
  120843. * Renders the particle system in its current state
  120844. * @param preWarm defines if the system should only update the particles but not render them
  120845. * @returns the current number of particles
  120846. */
  120847. render(preWarm?: boolean): number;
  120848. /**
  120849. * Rebuilds the particle system
  120850. */
  120851. rebuild(): void;
  120852. private _releaseBuffers;
  120853. private _releaseVAOs;
  120854. /**
  120855. * Disposes the particle system and free the associated resources
  120856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120857. */
  120858. dispose(disposeTexture?: boolean): void;
  120859. /**
  120860. * Clones the particle system.
  120861. * @param name The name of the cloned object
  120862. * @param newEmitter The new emitter to use
  120863. * @returns the cloned particle system
  120864. */
  120865. clone(name: string, newEmitter: any): GPUParticleSystem;
  120866. /**
  120867. * Serializes the particle system to a JSON object.
  120868. * @returns the JSON object
  120869. */
  120870. serialize(): any;
  120871. /**
  120872. * Parses a JSON object to create a GPU particle system.
  120873. * @param parsedParticleSystem The JSON object to parse
  120874. * @param scene The scene to create the particle system in
  120875. * @param rootUrl The root url to use to load external dependencies like texture
  120876. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120877. * @returns the parsed GPU particle system
  120878. */
  120879. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120880. }
  120881. }
  120882. declare module BABYLON {
  120883. /**
  120884. * Represents a set of particle systems working together to create a specific effect
  120885. */
  120886. export class ParticleSystemSet implements IDisposable {
  120887. private _emitterCreationOptions;
  120888. private _emitterNode;
  120889. /**
  120890. * Gets the particle system list
  120891. */
  120892. systems: IParticleSystem[];
  120893. /**
  120894. * Gets the emitter node used with this set
  120895. */
  120896. readonly emitterNode: Nullable<TransformNode>;
  120897. /**
  120898. * Creates a new emitter mesh as a sphere
  120899. * @param options defines the options used to create the sphere
  120900. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120901. * @param scene defines the hosting scene
  120902. */
  120903. setEmitterAsSphere(options: {
  120904. diameter: number;
  120905. segments: number;
  120906. color: Color3;
  120907. }, renderingGroupId: number, scene: Scene): void;
  120908. /**
  120909. * Starts all particle systems of the set
  120910. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120911. */
  120912. start(emitter?: AbstractMesh): void;
  120913. /**
  120914. * Release all associated resources
  120915. */
  120916. dispose(): void;
  120917. /**
  120918. * Serialize the set into a JSON compatible object
  120919. * @returns a JSON compatible representation of the set
  120920. */
  120921. serialize(): any;
  120922. /**
  120923. * Parse a new ParticleSystemSet from a serialized source
  120924. * @param data defines a JSON compatible representation of the set
  120925. * @param scene defines the hosting scene
  120926. * @param gpu defines if we want GPU particles or CPU particles
  120927. * @returns a new ParticleSystemSet
  120928. */
  120929. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120930. }
  120931. }
  120932. declare module BABYLON {
  120933. /**
  120934. * This class is made for on one-liner static method to help creating particle system set.
  120935. */
  120936. export class ParticleHelper {
  120937. /**
  120938. * Gets or sets base Assets URL
  120939. */
  120940. static BaseAssetsUrl: string;
  120941. /**
  120942. * Create a default particle system that you can tweak
  120943. * @param emitter defines the emitter to use
  120944. * @param capacity defines the system capacity (default is 500 particles)
  120945. * @param scene defines the hosting scene
  120946. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120947. * @returns the new Particle system
  120948. */
  120949. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120950. /**
  120951. * This is the main static method (one-liner) of this helper to create different particle systems
  120952. * @param type This string represents the type to the particle system to create
  120953. * @param scene The scene where the particle system should live
  120954. * @param gpu If the system will use gpu
  120955. * @returns the ParticleSystemSet created
  120956. */
  120957. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120958. /**
  120959. * Static function used to export a particle system to a ParticleSystemSet variable.
  120960. * Please note that the emitter shape is not exported
  120961. * @param systems defines the particle systems to export
  120962. * @returns the created particle system set
  120963. */
  120964. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120965. }
  120966. }
  120967. declare module BABYLON {
  120968. interface Engine {
  120969. /**
  120970. * Create an effect to use with particle systems.
  120971. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120972. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120973. * @param uniformsNames defines a list of attribute names
  120974. * @param samplers defines an array of string used to represent textures
  120975. * @param defines defines the string containing the defines to use to compile the shaders
  120976. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120977. * @param onCompiled defines a function to call when the effect creation is successful
  120978. * @param onError defines a function to call when the effect creation has failed
  120979. * @returns the new Effect
  120980. */
  120981. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120982. }
  120983. interface Mesh {
  120984. /**
  120985. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120986. * @returns an array of IParticleSystem
  120987. */
  120988. getEmittedParticleSystems(): IParticleSystem[];
  120989. /**
  120990. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120991. * @returns an array of IParticleSystem
  120992. */
  120993. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120994. }
  120995. /**
  120996. * @hidden
  120997. */
  120998. export var _IDoNeedToBeInTheBuild: number;
  120999. }
  121000. declare module BABYLON {
  121001. interface Scene {
  121002. /** @hidden (Backing field) */
  121003. _physicsEngine: Nullable<IPhysicsEngine>;
  121004. /**
  121005. * Gets the current physics engine
  121006. * @returns a IPhysicsEngine or null if none attached
  121007. */
  121008. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  121009. /**
  121010. * Enables physics to the current scene
  121011. * @param gravity defines the scene's gravity for the physics engine
  121012. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  121013. * @return a boolean indicating if the physics engine was initialized
  121014. */
  121015. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  121016. /**
  121017. * Disables and disposes the physics engine associated with the scene
  121018. */
  121019. disablePhysicsEngine(): void;
  121020. /**
  121021. * Gets a boolean indicating if there is an active physics engine
  121022. * @returns a boolean indicating if there is an active physics engine
  121023. */
  121024. isPhysicsEnabled(): boolean;
  121025. /**
  121026. * Deletes a physics compound impostor
  121027. * @param compound defines the compound to delete
  121028. */
  121029. deleteCompoundImpostor(compound: any): void;
  121030. /**
  121031. * An event triggered when physic simulation is about to be run
  121032. */
  121033. onBeforePhysicsObservable: Observable<Scene>;
  121034. /**
  121035. * An event triggered when physic simulation has been done
  121036. */
  121037. onAfterPhysicsObservable: Observable<Scene>;
  121038. }
  121039. interface AbstractMesh {
  121040. /** @hidden */
  121041. _physicsImpostor: Nullable<PhysicsImpostor>;
  121042. /**
  121043. * Gets or sets impostor used for physic simulation
  121044. * @see http://doc.babylonjs.com/features/physics_engine
  121045. */
  121046. physicsImpostor: Nullable<PhysicsImpostor>;
  121047. /**
  121048. * Gets the current physics impostor
  121049. * @see http://doc.babylonjs.com/features/physics_engine
  121050. * @returns a physics impostor or null
  121051. */
  121052. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  121053. /** Apply a physic impulse to the mesh
  121054. * @param force defines the force to apply
  121055. * @param contactPoint defines where to apply the force
  121056. * @returns the current mesh
  121057. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121058. */
  121059. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  121060. /**
  121061. * Creates a physic joint between two meshes
  121062. * @param otherMesh defines the other mesh to use
  121063. * @param pivot1 defines the pivot to use on this mesh
  121064. * @param pivot2 defines the pivot to use on the other mesh
  121065. * @param options defines additional options (can be plugin dependent)
  121066. * @returns the current mesh
  121067. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  121068. */
  121069. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  121070. /** @hidden */
  121071. _disposePhysicsObserver: Nullable<Observer<Node>>;
  121072. }
  121073. /**
  121074. * Defines the physics engine scene component responsible to manage a physics engine
  121075. */
  121076. export class PhysicsEngineSceneComponent implements ISceneComponent {
  121077. /**
  121078. * The component name helpful to identify the component in the list of scene components.
  121079. */
  121080. readonly name: string;
  121081. /**
  121082. * The scene the component belongs to.
  121083. */
  121084. scene: Scene;
  121085. /**
  121086. * Creates a new instance of the component for the given scene
  121087. * @param scene Defines the scene to register the component in
  121088. */
  121089. constructor(scene: Scene);
  121090. /**
  121091. * Registers the component in a given scene
  121092. */
  121093. register(): void;
  121094. /**
  121095. * Rebuilds the elements related to this component in case of
  121096. * context lost for instance.
  121097. */
  121098. rebuild(): void;
  121099. /**
  121100. * Disposes the component and the associated ressources
  121101. */
  121102. dispose(): void;
  121103. }
  121104. }
  121105. declare module BABYLON {
  121106. /**
  121107. * A helper for physics simulations
  121108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121109. */
  121110. export class PhysicsHelper {
  121111. private _scene;
  121112. private _physicsEngine;
  121113. /**
  121114. * Initializes the Physics helper
  121115. * @param scene Babylon.js scene
  121116. */
  121117. constructor(scene: Scene);
  121118. /**
  121119. * Applies a radial explosion impulse
  121120. * @param origin the origin of the explosion
  121121. * @param radiusOrEventOptions the radius or the options of radial explosion
  121122. * @param strength the explosion strength
  121123. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121124. * @returns A physics radial explosion event, or null
  121125. */
  121126. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121127. /**
  121128. * Applies a radial explosion force
  121129. * @param origin the origin of the explosion
  121130. * @param radiusOrEventOptions the radius or the options of radial explosion
  121131. * @param strength the explosion strength
  121132. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121133. * @returns A physics radial explosion event, or null
  121134. */
  121135. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121136. /**
  121137. * Creates a gravitational field
  121138. * @param origin the origin of the explosion
  121139. * @param radiusOrEventOptions the radius or the options of radial explosion
  121140. * @param strength the explosion strength
  121141. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121142. * @returns A physics gravitational field event, or null
  121143. */
  121144. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  121145. /**
  121146. * Creates a physics updraft event
  121147. * @param origin the origin of the updraft
  121148. * @param radiusOrEventOptions the radius or the options of the updraft
  121149. * @param strength the strength of the updraft
  121150. * @param height the height of the updraft
  121151. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  121152. * @returns A physics updraft event, or null
  121153. */
  121154. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  121155. /**
  121156. * Creates a physics vortex event
  121157. * @param origin the of the vortex
  121158. * @param radiusOrEventOptions the radius or the options of the vortex
  121159. * @param strength the strength of the vortex
  121160. * @param height the height of the vortex
  121161. * @returns a Physics vortex event, or null
  121162. * A physics vortex event or null
  121163. */
  121164. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  121165. }
  121166. /**
  121167. * Represents a physics radial explosion event
  121168. */
  121169. class PhysicsRadialExplosionEvent {
  121170. private _scene;
  121171. private _options;
  121172. private _sphere;
  121173. private _dataFetched;
  121174. /**
  121175. * Initializes a radial explosioin event
  121176. * @param _scene BabylonJS scene
  121177. * @param _options The options for the vortex event
  121178. */
  121179. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  121180. /**
  121181. * Returns the data related to the radial explosion event (sphere).
  121182. * @returns The radial explosion event data
  121183. */
  121184. getData(): PhysicsRadialExplosionEventData;
  121185. /**
  121186. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  121187. * @param impostor A physics imposter
  121188. * @param origin the origin of the explosion
  121189. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  121190. */
  121191. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  121192. /**
  121193. * Triggers affecterd impostors callbacks
  121194. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  121195. */
  121196. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  121197. /**
  121198. * Disposes the sphere.
  121199. * @param force Specifies if the sphere should be disposed by force
  121200. */
  121201. dispose(force?: boolean): void;
  121202. /*** Helpers ***/
  121203. private _prepareSphere;
  121204. private _intersectsWithSphere;
  121205. }
  121206. /**
  121207. * Represents a gravitational field event
  121208. */
  121209. class PhysicsGravitationalFieldEvent {
  121210. private _physicsHelper;
  121211. private _scene;
  121212. private _origin;
  121213. private _options;
  121214. private _tickCallback;
  121215. private _sphere;
  121216. private _dataFetched;
  121217. /**
  121218. * Initializes the physics gravitational field event
  121219. * @param _physicsHelper A physics helper
  121220. * @param _scene BabylonJS scene
  121221. * @param _origin The origin position of the gravitational field event
  121222. * @param _options The options for the vortex event
  121223. */
  121224. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  121225. /**
  121226. * Returns the data related to the gravitational field event (sphere).
  121227. * @returns A gravitational field event
  121228. */
  121229. getData(): PhysicsGravitationalFieldEventData;
  121230. /**
  121231. * Enables the gravitational field.
  121232. */
  121233. enable(): void;
  121234. /**
  121235. * Disables the gravitational field.
  121236. */
  121237. disable(): void;
  121238. /**
  121239. * Disposes the sphere.
  121240. * @param force The force to dispose from the gravitational field event
  121241. */
  121242. dispose(force?: boolean): void;
  121243. private _tick;
  121244. }
  121245. /**
  121246. * Represents a physics updraft event
  121247. */
  121248. class PhysicsUpdraftEvent {
  121249. private _scene;
  121250. private _origin;
  121251. private _options;
  121252. private _physicsEngine;
  121253. private _originTop;
  121254. private _originDirection;
  121255. private _tickCallback;
  121256. private _cylinder;
  121257. private _cylinderPosition;
  121258. private _dataFetched;
  121259. /**
  121260. * Initializes the physics updraft event
  121261. * @param _scene BabylonJS scene
  121262. * @param _origin The origin position of the updraft
  121263. * @param _options The options for the updraft event
  121264. */
  121265. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121266. /**
  121267. * Returns the data related to the updraft event (cylinder).
  121268. * @returns A physics updraft event
  121269. */
  121270. getData(): PhysicsUpdraftEventData;
  121271. /**
  121272. * Enables the updraft.
  121273. */
  121274. enable(): void;
  121275. /**
  121276. * Disables the updraft.
  121277. */
  121278. disable(): void;
  121279. /**
  121280. * Disposes the cylinder.
  121281. * @param force Specifies if the updraft should be disposed by force
  121282. */
  121283. dispose(force?: boolean): void;
  121284. private getImpostorHitData;
  121285. private _tick;
  121286. /*** Helpers ***/
  121287. private _prepareCylinder;
  121288. private _intersectsWithCylinder;
  121289. }
  121290. /**
  121291. * Represents a physics vortex event
  121292. */
  121293. class PhysicsVortexEvent {
  121294. private _scene;
  121295. private _origin;
  121296. private _options;
  121297. private _physicsEngine;
  121298. private _originTop;
  121299. private _tickCallback;
  121300. private _cylinder;
  121301. private _cylinderPosition;
  121302. private _dataFetched;
  121303. /**
  121304. * Initializes the physics vortex event
  121305. * @param _scene The BabylonJS scene
  121306. * @param _origin The origin position of the vortex
  121307. * @param _options The options for the vortex event
  121308. */
  121309. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121310. /**
  121311. * Returns the data related to the vortex event (cylinder).
  121312. * @returns The physics vortex event data
  121313. */
  121314. getData(): PhysicsVortexEventData;
  121315. /**
  121316. * Enables the vortex.
  121317. */
  121318. enable(): void;
  121319. /**
  121320. * Disables the cortex.
  121321. */
  121322. disable(): void;
  121323. /**
  121324. * Disposes the sphere.
  121325. * @param force
  121326. */
  121327. dispose(force?: boolean): void;
  121328. private getImpostorHitData;
  121329. private _tick;
  121330. /*** Helpers ***/
  121331. private _prepareCylinder;
  121332. private _intersectsWithCylinder;
  121333. }
  121334. /**
  121335. * Options fot the radial explosion event
  121336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121337. */
  121338. export class PhysicsRadialExplosionEventOptions {
  121339. /**
  121340. * The radius of the sphere for the radial explosion.
  121341. */
  121342. radius: number;
  121343. /**
  121344. * The strenth of the explosion.
  121345. */
  121346. strength: number;
  121347. /**
  121348. * The strenght of the force in correspondence to the distance of the affected object
  121349. */
  121350. falloff: PhysicsRadialImpulseFalloff;
  121351. /**
  121352. * Sphere options for the radial explosion.
  121353. */
  121354. sphere: {
  121355. segments: number;
  121356. diameter: number;
  121357. };
  121358. /**
  121359. * Sphere options for the radial explosion.
  121360. */
  121361. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121362. }
  121363. /**
  121364. * Options fot the updraft event
  121365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121366. */
  121367. export class PhysicsUpdraftEventOptions {
  121368. /**
  121369. * The radius of the cylinder for the vortex
  121370. */
  121371. radius: number;
  121372. /**
  121373. * The strenth of the updraft.
  121374. */
  121375. strength: number;
  121376. /**
  121377. * The height of the cylinder for the updraft.
  121378. */
  121379. height: number;
  121380. /**
  121381. * The mode for the the updraft.
  121382. */
  121383. updraftMode: PhysicsUpdraftMode;
  121384. }
  121385. /**
  121386. * Options fot the vortex event
  121387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121388. */
  121389. export class PhysicsVortexEventOptions {
  121390. /**
  121391. * The radius of the cylinder for the vortex
  121392. */
  121393. radius: number;
  121394. /**
  121395. * The strenth of the vortex.
  121396. */
  121397. strength: number;
  121398. /**
  121399. * The height of the cylinder for the vortex.
  121400. */
  121401. height: number;
  121402. /**
  121403. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  121404. */
  121405. centripetalForceThreshold: number;
  121406. /**
  121407. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  121408. */
  121409. centripetalForceMultiplier: number;
  121410. /**
  121411. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  121412. */
  121413. centrifugalForceMultiplier: number;
  121414. /**
  121415. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  121416. */
  121417. updraftForceMultiplier: number;
  121418. }
  121419. /**
  121420. * The strenght of the force in correspondence to the distance of the affected object
  121421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121422. */
  121423. export enum PhysicsRadialImpulseFalloff {
  121424. /** Defines that impulse is constant in strength across it's whole radius */
  121425. Constant = 0,
  121426. /** Defines that impulse gets weaker if it's further from the origin */
  121427. Linear = 1
  121428. }
  121429. /**
  121430. * The strength of the force in correspondence to the distance of the affected object
  121431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121432. */
  121433. export enum PhysicsUpdraftMode {
  121434. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  121435. Center = 0,
  121436. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  121437. Perpendicular = 1
  121438. }
  121439. /**
  121440. * Interface for a physics hit data
  121441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121442. */
  121443. export interface PhysicsHitData {
  121444. /**
  121445. * The force applied at the contact point
  121446. */
  121447. force: Vector3;
  121448. /**
  121449. * The contact point
  121450. */
  121451. contactPoint: Vector3;
  121452. /**
  121453. * The distance from the origin to the contact point
  121454. */
  121455. distanceFromOrigin: number;
  121456. }
  121457. /**
  121458. * Interface for radial explosion event data
  121459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121460. */
  121461. export interface PhysicsRadialExplosionEventData {
  121462. /**
  121463. * A sphere used for the radial explosion event
  121464. */
  121465. sphere: Mesh;
  121466. }
  121467. /**
  121468. * Interface for gravitational field event data
  121469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121470. */
  121471. export interface PhysicsGravitationalFieldEventData {
  121472. /**
  121473. * A sphere mesh used for the gravitational field event
  121474. */
  121475. sphere: Mesh;
  121476. }
  121477. /**
  121478. * Interface for updraft event data
  121479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121480. */
  121481. export interface PhysicsUpdraftEventData {
  121482. /**
  121483. * A cylinder used for the updraft event
  121484. */
  121485. cylinder: Mesh;
  121486. }
  121487. /**
  121488. * Interface for vortex event data
  121489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121490. */
  121491. export interface PhysicsVortexEventData {
  121492. /**
  121493. * A cylinder used for the vortex event
  121494. */
  121495. cylinder: Mesh;
  121496. }
  121497. /**
  121498. * Interface for an affected physics impostor
  121499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121500. */
  121501. export interface PhysicsAffectedImpostorWithData {
  121502. /**
  121503. * The impostor affected by the effect
  121504. */
  121505. impostor: PhysicsImpostor;
  121506. /**
  121507. * The data about the hit/horce from the explosion
  121508. */
  121509. hitData: PhysicsHitData;
  121510. }
  121511. }
  121512. declare module BABYLON {
  121513. /** @hidden */
  121514. export var blackAndWhitePixelShader: {
  121515. name: string;
  121516. shader: string;
  121517. };
  121518. }
  121519. declare module BABYLON {
  121520. /**
  121521. * Post process used to render in black and white
  121522. */
  121523. export class BlackAndWhitePostProcess extends PostProcess {
  121524. /**
  121525. * Linear about to convert he result to black and white (default: 1)
  121526. */
  121527. degree: number;
  121528. /**
  121529. * Creates a black and white post process
  121530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  121531. * @param name The name of the effect.
  121532. * @param options The required width/height ratio to downsize to before computing the render pass.
  121533. * @param camera The camera to apply the render pass to.
  121534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121535. * @param engine The engine which the post process will be applied. (default: current engine)
  121536. * @param reusable If the post process can be reused on the same frame. (default: false)
  121537. */
  121538. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121539. }
  121540. }
  121541. declare module BABYLON {
  121542. /**
  121543. * This represents a set of one or more post processes in Babylon.
  121544. * A post process can be used to apply a shader to a texture after it is rendered.
  121545. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121546. */
  121547. export class PostProcessRenderEffect {
  121548. private _postProcesses;
  121549. private _getPostProcesses;
  121550. private _singleInstance;
  121551. private _cameras;
  121552. private _indicesForCamera;
  121553. /**
  121554. * Name of the effect
  121555. * @hidden
  121556. */
  121557. _name: string;
  121558. /**
  121559. * Instantiates a post process render effect.
  121560. * A post process can be used to apply a shader to a texture after it is rendered.
  121561. * @param engine The engine the effect is tied to
  121562. * @param name The name of the effect
  121563. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121564. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121565. */
  121566. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  121567. /**
  121568. * Checks if all the post processes in the effect are supported.
  121569. */
  121570. readonly isSupported: boolean;
  121571. /**
  121572. * Updates the current state of the effect
  121573. * @hidden
  121574. */
  121575. _update(): void;
  121576. /**
  121577. * Attaches the effect on cameras
  121578. * @param cameras The camera to attach to.
  121579. * @hidden
  121580. */
  121581. _attachCameras(cameras: Camera): void;
  121582. /**
  121583. * Attaches the effect on cameras
  121584. * @param cameras The camera to attach to.
  121585. * @hidden
  121586. */
  121587. _attachCameras(cameras: Camera[]): void;
  121588. /**
  121589. * Detaches the effect on cameras
  121590. * @param cameras The camera to detatch from.
  121591. * @hidden
  121592. */
  121593. _detachCameras(cameras: Camera): void;
  121594. /**
  121595. * Detatches the effect on cameras
  121596. * @param cameras The camera to detatch from.
  121597. * @hidden
  121598. */
  121599. _detachCameras(cameras: Camera[]): void;
  121600. /**
  121601. * Enables the effect on given cameras
  121602. * @param cameras The camera to enable.
  121603. * @hidden
  121604. */
  121605. _enable(cameras: Camera): void;
  121606. /**
  121607. * Enables the effect on given cameras
  121608. * @param cameras The camera to enable.
  121609. * @hidden
  121610. */
  121611. _enable(cameras: Nullable<Camera[]>): void;
  121612. /**
  121613. * Disables the effect on the given cameras
  121614. * @param cameras The camera to disable.
  121615. * @hidden
  121616. */
  121617. _disable(cameras: Camera): void;
  121618. /**
  121619. * Disables the effect on the given cameras
  121620. * @param cameras The camera to disable.
  121621. * @hidden
  121622. */
  121623. _disable(cameras: Nullable<Camera[]>): void;
  121624. /**
  121625. * Gets a list of the post processes contained in the effect.
  121626. * @param camera The camera to get the post processes on.
  121627. * @returns The list of the post processes in the effect.
  121628. */
  121629. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  121630. }
  121631. }
  121632. declare module BABYLON {
  121633. /** @hidden */
  121634. export var extractHighlightsPixelShader: {
  121635. name: string;
  121636. shader: string;
  121637. };
  121638. }
  121639. declare module BABYLON {
  121640. /**
  121641. * 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.
  121642. */
  121643. export class ExtractHighlightsPostProcess extends PostProcess {
  121644. /**
  121645. * The luminance threshold, pixels below this value will be set to black.
  121646. */
  121647. threshold: number;
  121648. /** @hidden */
  121649. _exposure: number;
  121650. /**
  121651. * Post process which has the input texture to be used when performing highlight extraction
  121652. * @hidden
  121653. */
  121654. _inputPostProcess: Nullable<PostProcess>;
  121655. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121656. }
  121657. }
  121658. declare module BABYLON {
  121659. /** @hidden */
  121660. export var bloomMergePixelShader: {
  121661. name: string;
  121662. shader: string;
  121663. };
  121664. }
  121665. declare module BABYLON {
  121666. /**
  121667. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121668. */
  121669. export class BloomMergePostProcess extends PostProcess {
  121670. /** Weight of the bloom to be added to the original input. */
  121671. weight: number;
  121672. /**
  121673. * Creates a new instance of @see BloomMergePostProcess
  121674. * @param name The name of the effect.
  121675. * @param originalFromInput Post process which's input will be used for the merge.
  121676. * @param blurred Blurred highlights post process which's output will be used.
  121677. * @param weight Weight of the bloom to be added to the original input.
  121678. * @param options The required width/height ratio to downsize to before computing the render pass.
  121679. * @param camera The camera to apply the render pass to.
  121680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121681. * @param engine The engine which the post process will be applied. (default: current engine)
  121682. * @param reusable If the post process can be reused on the same frame. (default: false)
  121683. * @param textureType Type of textures used when performing the post process. (default: 0)
  121684. * @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)
  121685. */
  121686. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  121687. /** Weight of the bloom to be added to the original input. */
  121688. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121689. }
  121690. }
  121691. declare module BABYLON {
  121692. /**
  121693. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  121694. */
  121695. export class BloomEffect extends PostProcessRenderEffect {
  121696. private bloomScale;
  121697. /**
  121698. * @hidden Internal
  121699. */
  121700. _effects: Array<PostProcess>;
  121701. /**
  121702. * @hidden Internal
  121703. */
  121704. _downscale: ExtractHighlightsPostProcess;
  121705. private _blurX;
  121706. private _blurY;
  121707. private _merge;
  121708. /**
  121709. * The luminance threshold to find bright areas of the image to bloom.
  121710. */
  121711. threshold: number;
  121712. /**
  121713. * The strength of the bloom.
  121714. */
  121715. weight: number;
  121716. /**
  121717. * Specifies the size of the bloom blur kernel, relative to the final output size
  121718. */
  121719. kernel: number;
  121720. /**
  121721. * Creates a new instance of @see BloomEffect
  121722. * @param scene The scene the effect belongs to.
  121723. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  121724. * @param bloomKernel The size of the kernel to be used when applying the blur.
  121725. * @param bloomWeight The the strength of bloom.
  121726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121727. * @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)
  121728. */
  121729. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  121730. /**
  121731. * Disposes each of the internal effects for a given camera.
  121732. * @param camera The camera to dispose the effect on.
  121733. */
  121734. disposeEffects(camera: Camera): void;
  121735. /**
  121736. * @hidden Internal
  121737. */
  121738. _updateEffects(): void;
  121739. /**
  121740. * Internal
  121741. * @returns if all the contained post processes are ready.
  121742. * @hidden
  121743. */
  121744. _isReady(): boolean;
  121745. }
  121746. }
  121747. declare module BABYLON {
  121748. /** @hidden */
  121749. export var chromaticAberrationPixelShader: {
  121750. name: string;
  121751. shader: string;
  121752. };
  121753. }
  121754. declare module BABYLON {
  121755. /**
  121756. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121757. */
  121758. export class ChromaticAberrationPostProcess extends PostProcess {
  121759. /**
  121760. * The amount of seperation of rgb channels (default: 30)
  121761. */
  121762. aberrationAmount: number;
  121763. /**
  121764. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121765. */
  121766. radialIntensity: number;
  121767. /**
  121768. * 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))
  121769. */
  121770. direction: Vector2;
  121771. /**
  121772. * 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))
  121773. */
  121774. centerPosition: Vector2;
  121775. /**
  121776. * Creates a new instance ChromaticAberrationPostProcess
  121777. * @param name The name of the effect.
  121778. * @param screenWidth The width of the screen to apply the effect on.
  121779. * @param screenHeight The height of the screen to apply the effect on.
  121780. * @param options The required width/height ratio to downsize to before computing the render pass.
  121781. * @param camera The camera to apply the render pass to.
  121782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121783. * @param engine The engine which the post process will be applied. (default: current engine)
  121784. * @param reusable If the post process can be reused on the same frame. (default: false)
  121785. * @param textureType Type of textures used when performing the post process. (default: 0)
  121786. * @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)
  121787. */
  121788. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121789. }
  121790. }
  121791. declare module BABYLON {
  121792. /** @hidden */
  121793. export var circleOfConfusionPixelShader: {
  121794. name: string;
  121795. shader: string;
  121796. };
  121797. }
  121798. declare module BABYLON {
  121799. /**
  121800. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121801. */
  121802. export class CircleOfConfusionPostProcess extends PostProcess {
  121803. /**
  121804. * 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.
  121805. */
  121806. lensSize: number;
  121807. /**
  121808. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121809. */
  121810. fStop: number;
  121811. /**
  121812. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121813. */
  121814. focusDistance: number;
  121815. /**
  121816. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121817. */
  121818. focalLength: number;
  121819. private _depthTexture;
  121820. /**
  121821. * Creates a new instance CircleOfConfusionPostProcess
  121822. * @param name The name of the effect.
  121823. * @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.
  121824. * @param options The required width/height ratio to downsize to before computing the render pass.
  121825. * @param camera The camera to apply the render pass to.
  121826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121827. * @param engine The engine which the post process will be applied. (default: current engine)
  121828. * @param reusable If the post process can be reused on the same frame. (default: false)
  121829. * @param textureType Type of textures used when performing the post process. (default: 0)
  121830. * @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)
  121831. */
  121832. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121833. /**
  121834. * 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.
  121835. */
  121836. depthTexture: RenderTargetTexture;
  121837. }
  121838. }
  121839. declare module BABYLON {
  121840. /** @hidden */
  121841. export var colorCorrectionPixelShader: {
  121842. name: string;
  121843. shader: string;
  121844. };
  121845. }
  121846. declare module BABYLON {
  121847. /**
  121848. *
  121849. * This post-process allows the modification of rendered colors by using
  121850. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121851. *
  121852. * The object needs to be provided an url to a texture containing the color
  121853. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121854. * Use an image editing software to tweak the LUT to match your needs.
  121855. *
  121856. * For an example of a color LUT, see here:
  121857. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121858. * For explanations on color grading, see here:
  121859. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121860. *
  121861. */
  121862. export class ColorCorrectionPostProcess extends PostProcess {
  121863. private _colorTableTexture;
  121864. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121865. }
  121866. }
  121867. declare module BABYLON {
  121868. /** @hidden */
  121869. export var convolutionPixelShader: {
  121870. name: string;
  121871. shader: string;
  121872. };
  121873. }
  121874. declare module BABYLON {
  121875. /**
  121876. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121877. * input texture to perform effects such as edge detection or sharpening
  121878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121879. */
  121880. export class ConvolutionPostProcess extends PostProcess {
  121881. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121882. kernel: number[];
  121883. /**
  121884. * Creates a new instance ConvolutionPostProcess
  121885. * @param name The name of the effect.
  121886. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121887. * @param options The required width/height ratio to downsize to before computing the render pass.
  121888. * @param camera The camera to apply the render pass to.
  121889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121890. * @param engine The engine which the post process will be applied. (default: current engine)
  121891. * @param reusable If the post process can be reused on the same frame. (default: false)
  121892. * @param textureType Type of textures used when performing the post process. (default: 0)
  121893. */
  121894. constructor(name: string,
  121895. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121896. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121897. /**
  121898. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121899. */
  121900. static EdgeDetect0Kernel: number[];
  121901. /**
  121902. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121903. */
  121904. static EdgeDetect1Kernel: number[];
  121905. /**
  121906. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121907. */
  121908. static EdgeDetect2Kernel: number[];
  121909. /**
  121910. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121911. */
  121912. static SharpenKernel: number[];
  121913. /**
  121914. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121915. */
  121916. static EmbossKernel: number[];
  121917. /**
  121918. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121919. */
  121920. static GaussianKernel: number[];
  121921. }
  121922. }
  121923. declare module BABYLON {
  121924. /**
  121925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121927. * based on samples that have a large difference in distance than the center pixel.
  121928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121929. */
  121930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121931. direction: Vector2;
  121932. /**
  121933. * Creates a new instance CircleOfConfusionPostProcess
  121934. * @param name The name of the effect.
  121935. * @param scene The scene the effect belongs to.
  121936. * @param direction The direction the blur should be applied.
  121937. * @param kernel The size of the kernel used to blur.
  121938. * @param options The required width/height ratio to downsize to before computing the render pass.
  121939. * @param camera The camera to apply the render pass to.
  121940. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121941. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121943. * @param engine The engine which the post process will be applied. (default: current engine)
  121944. * @param reusable If the post process can be reused on the same frame. (default: false)
  121945. * @param textureType Type of textures used when performing the post process. (default: 0)
  121946. * @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)
  121947. */
  121948. 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);
  121949. }
  121950. }
  121951. declare module BABYLON {
  121952. /** @hidden */
  121953. export var depthOfFieldMergePixelShader: {
  121954. name: string;
  121955. shader: string;
  121956. };
  121957. }
  121958. declare module BABYLON {
  121959. /**
  121960. * Options to be set when merging outputs from the default pipeline.
  121961. */
  121962. export class DepthOfFieldMergePostProcessOptions {
  121963. /**
  121964. * The original image to merge on top of
  121965. */
  121966. originalFromInput: PostProcess;
  121967. /**
  121968. * Parameters to perform the merge of the depth of field effect
  121969. */
  121970. depthOfField?: {
  121971. circleOfConfusion: PostProcess;
  121972. blurSteps: Array<PostProcess>;
  121973. };
  121974. /**
  121975. * Parameters to perform the merge of bloom effect
  121976. */
  121977. bloom?: {
  121978. blurred: PostProcess;
  121979. weight: number;
  121980. };
  121981. }
  121982. /**
  121983. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121984. */
  121985. export class DepthOfFieldMergePostProcess extends PostProcess {
  121986. private blurSteps;
  121987. /**
  121988. * Creates a new instance of DepthOfFieldMergePostProcess
  121989. * @param name The name of the effect.
  121990. * @param originalFromInput Post process which's input will be used for the merge.
  121991. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121992. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121993. * @param options The required width/height ratio to downsize to before computing the render pass.
  121994. * @param camera The camera to apply the render pass to.
  121995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121996. * @param engine The engine which the post process will be applied. (default: current engine)
  121997. * @param reusable If the post process can be reused on the same frame. (default: false)
  121998. * @param textureType Type of textures used when performing the post process. (default: 0)
  121999. * @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)
  122000. */
  122001. 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);
  122002. /**
  122003. * Updates the effect with the current post process compile time values and recompiles the shader.
  122004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122007. * @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
  122008. * @param onCompiled Called when the shader has been compiled.
  122009. * @param onError Called if there is an error when compiling a shader.
  122010. */
  122011. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  122012. }
  122013. }
  122014. declare module BABYLON {
  122015. /**
  122016. * Specifies the level of max blur that should be applied when using the depth of field effect
  122017. */
  122018. export enum DepthOfFieldEffectBlurLevel {
  122019. /**
  122020. * Subtle blur
  122021. */
  122022. Low = 0,
  122023. /**
  122024. * Medium blur
  122025. */
  122026. Medium = 1,
  122027. /**
  122028. * Large blur
  122029. */
  122030. High = 2
  122031. }
  122032. /**
  122033. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122034. */
  122035. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  122036. private _circleOfConfusion;
  122037. /**
  122038. * @hidden Internal, blurs from high to low
  122039. */
  122040. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  122041. private _depthOfFieldBlurY;
  122042. private _dofMerge;
  122043. /**
  122044. * @hidden Internal post processes in depth of field effect
  122045. */
  122046. _effects: Array<PostProcess>;
  122047. /**
  122048. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122049. */
  122050. focalLength: number;
  122051. /**
  122052. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122053. */
  122054. fStop: number;
  122055. /**
  122056. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122057. */
  122058. focusDistance: number;
  122059. /**
  122060. * 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.
  122061. */
  122062. lensSize: number;
  122063. /**
  122064. * Creates a new instance DepthOfFieldEffect
  122065. * @param scene The scene the effect belongs to.
  122066. * @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.
  122067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122068. * @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)
  122069. */
  122070. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  122071. /**
  122072. * Get the current class name of the current effet
  122073. * @returns "DepthOfFieldEffect"
  122074. */
  122075. getClassName(): string;
  122076. /**
  122077. * 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.
  122078. */
  122079. depthTexture: RenderTargetTexture;
  122080. /**
  122081. * Disposes each of the internal effects for a given camera.
  122082. * @param camera The camera to dispose the effect on.
  122083. */
  122084. disposeEffects(camera: Camera): void;
  122085. /**
  122086. * @hidden Internal
  122087. */
  122088. _updateEffects(): void;
  122089. /**
  122090. * Internal
  122091. * @returns if all the contained post processes are ready.
  122092. * @hidden
  122093. */
  122094. _isReady(): boolean;
  122095. }
  122096. }
  122097. declare module BABYLON {
  122098. /** @hidden */
  122099. export var displayPassPixelShader: {
  122100. name: string;
  122101. shader: string;
  122102. };
  122103. }
  122104. declare module BABYLON {
  122105. /**
  122106. * DisplayPassPostProcess which produces an output the same as it's input
  122107. */
  122108. export class DisplayPassPostProcess extends PostProcess {
  122109. /**
  122110. * Creates the DisplayPassPostProcess
  122111. * @param name The name of the effect.
  122112. * @param options The required width/height ratio to downsize to before computing the render pass.
  122113. * @param camera The camera to apply the render pass to.
  122114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122115. * @param engine The engine which the post process will be applied. (default: current engine)
  122116. * @param reusable If the post process can be reused on the same frame. (default: false)
  122117. */
  122118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122119. }
  122120. }
  122121. declare module BABYLON {
  122122. /** @hidden */
  122123. export var filterPixelShader: {
  122124. name: string;
  122125. shader: string;
  122126. };
  122127. }
  122128. declare module BABYLON {
  122129. /**
  122130. * Applies a kernel filter to the image
  122131. */
  122132. export class FilterPostProcess extends PostProcess {
  122133. /** The matrix to be applied to the image */
  122134. kernelMatrix: Matrix;
  122135. /**
  122136. *
  122137. * @param name The name of the effect.
  122138. * @param kernelMatrix The matrix to be applied to the image
  122139. * @param options The required width/height ratio to downsize to before computing the render pass.
  122140. * @param camera The camera to apply the render pass to.
  122141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122142. * @param engine The engine which the post process will be applied. (default: current engine)
  122143. * @param reusable If the post process can be reused on the same frame. (default: false)
  122144. */
  122145. constructor(name: string,
  122146. /** The matrix to be applied to the image */
  122147. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122148. }
  122149. }
  122150. declare module BABYLON {
  122151. /** @hidden */
  122152. export var fxaaPixelShader: {
  122153. name: string;
  122154. shader: string;
  122155. };
  122156. }
  122157. declare module BABYLON {
  122158. /** @hidden */
  122159. export var fxaaVertexShader: {
  122160. name: string;
  122161. shader: string;
  122162. };
  122163. }
  122164. declare module BABYLON {
  122165. /**
  122166. * Fxaa post process
  122167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122168. */
  122169. export class FxaaPostProcess extends PostProcess {
  122170. /** @hidden */
  122171. texelWidth: number;
  122172. /** @hidden */
  122173. texelHeight: number;
  122174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122175. private _getDefines;
  122176. }
  122177. }
  122178. declare module BABYLON {
  122179. /** @hidden */
  122180. export var grainPixelShader: {
  122181. name: string;
  122182. shader: string;
  122183. };
  122184. }
  122185. declare module BABYLON {
  122186. /**
  122187. * The GrainPostProcess adds noise to the image at mid luminance levels
  122188. */
  122189. export class GrainPostProcess extends PostProcess {
  122190. /**
  122191. * The intensity of the grain added (default: 30)
  122192. */
  122193. intensity: number;
  122194. /**
  122195. * If the grain should be randomized on every frame
  122196. */
  122197. animated: boolean;
  122198. /**
  122199. * Creates a new instance of @see GrainPostProcess
  122200. * @param name The name of the effect.
  122201. * @param options The required width/height ratio to downsize to before computing the render pass.
  122202. * @param camera The camera to apply the render pass to.
  122203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122204. * @param engine The engine which the post process will be applied. (default: current engine)
  122205. * @param reusable If the post process can be reused on the same frame. (default: false)
  122206. * @param textureType Type of textures used when performing the post process. (default: 0)
  122207. * @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)
  122208. */
  122209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122210. }
  122211. }
  122212. declare module BABYLON {
  122213. /** @hidden */
  122214. export var highlightsPixelShader: {
  122215. name: string;
  122216. shader: string;
  122217. };
  122218. }
  122219. declare module BABYLON {
  122220. /**
  122221. * Extracts highlights from the image
  122222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122223. */
  122224. export class HighlightsPostProcess extends PostProcess {
  122225. /**
  122226. * Extracts highlights from the image
  122227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122228. * @param name The name of the effect.
  122229. * @param options The required width/height ratio to downsize to before computing the render pass.
  122230. * @param camera The camera to apply the render pass to.
  122231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122232. * @param engine The engine which the post process will be applied. (default: current engine)
  122233. * @param reusable If the post process can be reused on the same frame. (default: false)
  122234. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122235. */
  122236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122237. }
  122238. }
  122239. declare module BABYLON {
  122240. /** @hidden */
  122241. export var mrtFragmentDeclaration: {
  122242. name: string;
  122243. shader: string;
  122244. };
  122245. }
  122246. declare module BABYLON {
  122247. /** @hidden */
  122248. export var geometryPixelShader: {
  122249. name: string;
  122250. shader: string;
  122251. };
  122252. }
  122253. declare module BABYLON {
  122254. /** @hidden */
  122255. export var geometryVertexShader: {
  122256. name: string;
  122257. shader: string;
  122258. };
  122259. }
  122260. declare module BABYLON {
  122261. /** @hidden */
  122262. interface ISavedTransformationMatrix {
  122263. world: Matrix;
  122264. viewProjection: Matrix;
  122265. }
  122266. /**
  122267. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122268. */
  122269. export class GeometryBufferRenderer {
  122270. /**
  122271. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122272. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122273. */
  122274. static readonly POSITION_TEXTURE_TYPE: number;
  122275. /**
  122276. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122277. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122278. */
  122279. static readonly VELOCITY_TEXTURE_TYPE: number;
  122280. /**
  122281. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122282. * in order to compute objects velocities when enableVelocity is set to "true"
  122283. * @hidden
  122284. */
  122285. _previousTransformationMatrices: {
  122286. [index: number]: ISavedTransformationMatrix;
  122287. };
  122288. /**
  122289. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122290. * in order to compute objects velocities when enableVelocity is set to "true"
  122291. * @hidden
  122292. */
  122293. _previousBonesTransformationMatrices: {
  122294. [index: number]: Float32Array;
  122295. };
  122296. /**
  122297. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122298. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122299. */
  122300. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122301. private _scene;
  122302. private _multiRenderTarget;
  122303. private _ratio;
  122304. private _enablePosition;
  122305. private _enableVelocity;
  122306. private _positionIndex;
  122307. private _velocityIndex;
  122308. protected _effect: Effect;
  122309. protected _cachedDefines: string;
  122310. /**
  122311. * Set the render list (meshes to be rendered) used in the G buffer.
  122312. */
  122313. renderList: Mesh[];
  122314. /**
  122315. * Gets wether or not G buffer are supported by the running hardware.
  122316. * This requires draw buffer supports
  122317. */
  122318. readonly isSupported: boolean;
  122319. /**
  122320. * Returns the index of the given texture type in the G-Buffer textures array
  122321. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122322. * @returns the index of the given texture type in the G-Buffer textures array
  122323. */
  122324. getTextureIndex(textureType: number): number;
  122325. /**
  122326. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122327. */
  122328. /**
  122329. * Sets whether or not objects positions are enabled for the G buffer.
  122330. */
  122331. enablePosition: boolean;
  122332. /**
  122333. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122334. */
  122335. /**
  122336. * Sets wether or not objects velocities are enabled for the G buffer.
  122337. */
  122338. enableVelocity: boolean;
  122339. /**
  122340. * Gets the scene associated with the buffer.
  122341. */
  122342. readonly scene: Scene;
  122343. /**
  122344. * Gets the ratio used by the buffer during its creation.
  122345. * How big is the buffer related to the main canvas.
  122346. */
  122347. readonly ratio: number;
  122348. /** @hidden */
  122349. static _SceneComponentInitialization: (scene: Scene) => void;
  122350. /**
  122351. * Creates a new G Buffer for the scene
  122352. * @param scene The scene the buffer belongs to
  122353. * @param ratio How big is the buffer related to the main canvas.
  122354. */
  122355. constructor(scene: Scene, ratio?: number);
  122356. /**
  122357. * Checks wether everything is ready to render a submesh to the G buffer.
  122358. * @param subMesh the submesh to check readiness for
  122359. * @param useInstances is the mesh drawn using instance or not
  122360. * @returns true if ready otherwise false
  122361. */
  122362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122363. /**
  122364. * Gets the current underlying G Buffer.
  122365. * @returns the buffer
  122366. */
  122367. getGBuffer(): MultiRenderTarget;
  122368. /**
  122369. * Gets the number of samples used to render the buffer (anti aliasing).
  122370. */
  122371. /**
  122372. * Sets the number of samples used to render the buffer (anti aliasing).
  122373. */
  122374. samples: number;
  122375. /**
  122376. * Disposes the renderer and frees up associated resources.
  122377. */
  122378. dispose(): void;
  122379. protected _createRenderTargets(): void;
  122380. private _copyBonesTransformationMatrices;
  122381. }
  122382. }
  122383. declare module BABYLON {
  122384. interface Scene {
  122385. /** @hidden (Backing field) */
  122386. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122387. /**
  122388. * Gets or Sets the current geometry buffer associated to the scene.
  122389. */
  122390. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122391. /**
  122392. * Enables a GeometryBufferRender and associates it with the scene
  122393. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  122394. * @returns the GeometryBufferRenderer
  122395. */
  122396. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  122397. /**
  122398. * Disables the GeometryBufferRender associated with the scene
  122399. */
  122400. disableGeometryBufferRenderer(): void;
  122401. }
  122402. /**
  122403. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122404. * in several rendering techniques.
  122405. */
  122406. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  122407. /**
  122408. * The component name helpful to identify the component in the list of scene components.
  122409. */
  122410. readonly name: string;
  122411. /**
  122412. * The scene the component belongs to.
  122413. */
  122414. scene: Scene;
  122415. /**
  122416. * Creates a new instance of the component for the given scene
  122417. * @param scene Defines the scene to register the component in
  122418. */
  122419. constructor(scene: Scene);
  122420. /**
  122421. * Registers the component in a given scene
  122422. */
  122423. register(): void;
  122424. /**
  122425. * Rebuilds the elements related to this component in case of
  122426. * context lost for instance.
  122427. */
  122428. rebuild(): void;
  122429. /**
  122430. * Disposes the component and the associated ressources
  122431. */
  122432. dispose(): void;
  122433. private _gatherRenderTargets;
  122434. }
  122435. }
  122436. declare module BABYLON {
  122437. /** @hidden */
  122438. export var motionBlurPixelShader: {
  122439. name: string;
  122440. shader: string;
  122441. };
  122442. }
  122443. declare module BABYLON {
  122444. /**
  122445. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122446. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122447. * As an example, all you have to do is to create the post-process:
  122448. * var mb = new BABYLON.MotionBlurPostProcess(
  122449. * 'mb', // The name of the effect.
  122450. * scene, // The scene containing the objects to blur according to their velocity.
  122451. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122452. * camera // The camera to apply the render pass to.
  122453. * );
  122454. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122455. */
  122456. export class MotionBlurPostProcess extends PostProcess {
  122457. /**
  122458. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122459. */
  122460. motionStrength: number;
  122461. /**
  122462. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122463. */
  122464. /**
  122465. * Sets the number of iterations to be used for motion blur quality
  122466. */
  122467. motionBlurSamples: number;
  122468. private _motionBlurSamples;
  122469. private _geometryBufferRenderer;
  122470. /**
  122471. * Creates a new instance MotionBlurPostProcess
  122472. * @param name The name of the effect.
  122473. * @param scene The scene containing the objects to blur according to their velocity.
  122474. * @param options The required width/height ratio to downsize to before computing the render pass.
  122475. * @param camera The camera to apply the render pass to.
  122476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122477. * @param engine The engine which the post process will be applied. (default: current engine)
  122478. * @param reusable If the post process can be reused on the same frame. (default: false)
  122479. * @param textureType Type of textures used when performing the post process. (default: 0)
  122480. * @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)
  122481. */
  122482. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122483. /**
  122484. * Excludes the given skinned mesh from computing bones velocities.
  122485. * 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.
  122486. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  122487. */
  122488. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122489. /**
  122490. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  122491. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  122492. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  122493. */
  122494. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122495. /**
  122496. * Disposes the post process.
  122497. * @param camera The camera to dispose the post process on.
  122498. */
  122499. dispose(camera?: Camera): void;
  122500. }
  122501. }
  122502. declare module BABYLON {
  122503. /** @hidden */
  122504. export var refractionPixelShader: {
  122505. name: string;
  122506. shader: string;
  122507. };
  122508. }
  122509. declare module BABYLON {
  122510. /**
  122511. * Post process which applies a refractin texture
  122512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122513. */
  122514. export class RefractionPostProcess extends PostProcess {
  122515. /** the base color of the refraction (used to taint the rendering) */
  122516. color: Color3;
  122517. /** simulated refraction depth */
  122518. depth: number;
  122519. /** the coefficient of the base color (0 to remove base color tainting) */
  122520. colorLevel: number;
  122521. private _refTexture;
  122522. private _ownRefractionTexture;
  122523. /**
  122524. * Gets or sets the refraction texture
  122525. * Please note that you are responsible for disposing the texture if you set it manually
  122526. */
  122527. refractionTexture: Texture;
  122528. /**
  122529. * Initializes the RefractionPostProcess
  122530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122531. * @param name The name of the effect.
  122532. * @param refractionTextureUrl Url of the refraction texture to use
  122533. * @param color the base color of the refraction (used to taint the rendering)
  122534. * @param depth simulated refraction depth
  122535. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  122536. * @param camera The camera to apply the render pass to.
  122537. * @param options The required width/height ratio to downsize to before computing the render pass.
  122538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122539. * @param engine The engine which the post process will be applied. (default: current engine)
  122540. * @param reusable If the post process can be reused on the same frame. (default: false)
  122541. */
  122542. constructor(name: string, refractionTextureUrl: string,
  122543. /** the base color of the refraction (used to taint the rendering) */
  122544. color: Color3,
  122545. /** simulated refraction depth */
  122546. depth: number,
  122547. /** the coefficient of the base color (0 to remove base color tainting) */
  122548. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122549. /**
  122550. * Disposes of the post process
  122551. * @param camera Camera to dispose post process on
  122552. */
  122553. dispose(camera: Camera): void;
  122554. }
  122555. }
  122556. declare module BABYLON {
  122557. /** @hidden */
  122558. export var sharpenPixelShader: {
  122559. name: string;
  122560. shader: string;
  122561. };
  122562. }
  122563. declare module BABYLON {
  122564. /**
  122565. * The SharpenPostProcess applies a sharpen kernel to every pixel
  122566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122567. */
  122568. export class SharpenPostProcess extends PostProcess {
  122569. /**
  122570. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  122571. */
  122572. colorAmount: number;
  122573. /**
  122574. * How much sharpness should be applied (default: 0.3)
  122575. */
  122576. edgeAmount: number;
  122577. /**
  122578. * Creates a new instance ConvolutionPostProcess
  122579. * @param name The name of the effect.
  122580. * @param options The required width/height ratio to downsize to before computing the render pass.
  122581. * @param camera The camera to apply the render pass to.
  122582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122583. * @param engine The engine which the post process will be applied. (default: current engine)
  122584. * @param reusable If the post process can be reused on the same frame. (default: false)
  122585. * @param textureType Type of textures used when performing the post process. (default: 0)
  122586. * @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)
  122587. */
  122588. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122589. }
  122590. }
  122591. declare module BABYLON {
  122592. /**
  122593. * PostProcessRenderPipeline
  122594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122595. */
  122596. export class PostProcessRenderPipeline {
  122597. private engine;
  122598. private _renderEffects;
  122599. private _renderEffectsForIsolatedPass;
  122600. /**
  122601. * List of inspectable custom properties (used by the Inspector)
  122602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122603. */
  122604. inspectableCustomProperties: IInspectable[];
  122605. /**
  122606. * @hidden
  122607. */
  122608. protected _cameras: Camera[];
  122609. /** @hidden */
  122610. _name: string;
  122611. /**
  122612. * Gets pipeline name
  122613. */
  122614. readonly name: string;
  122615. /**
  122616. * Initializes a PostProcessRenderPipeline
  122617. * @param engine engine to add the pipeline to
  122618. * @param name name of the pipeline
  122619. */
  122620. constructor(engine: Engine, name: string);
  122621. /**
  122622. * Gets the class name
  122623. * @returns "PostProcessRenderPipeline"
  122624. */
  122625. getClassName(): string;
  122626. /**
  122627. * If all the render effects in the pipeline are supported
  122628. */
  122629. readonly isSupported: boolean;
  122630. /**
  122631. * Adds an effect to the pipeline
  122632. * @param renderEffect the effect to add
  122633. */
  122634. addEffect(renderEffect: PostProcessRenderEffect): void;
  122635. /** @hidden */
  122636. _rebuild(): void;
  122637. /** @hidden */
  122638. _enableEffect(renderEffectName: string, cameras: Camera): void;
  122639. /** @hidden */
  122640. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  122641. /** @hidden */
  122642. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122643. /** @hidden */
  122644. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122645. /** @hidden */
  122646. _attachCameras(cameras: Camera, unique: boolean): void;
  122647. /** @hidden */
  122648. _attachCameras(cameras: Camera[], unique: boolean): void;
  122649. /** @hidden */
  122650. _detachCameras(cameras: Camera): void;
  122651. /** @hidden */
  122652. _detachCameras(cameras: Nullable<Camera[]>): void;
  122653. /** @hidden */
  122654. _update(): void;
  122655. /** @hidden */
  122656. _reset(): void;
  122657. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  122658. /**
  122659. * Disposes of the pipeline
  122660. */
  122661. dispose(): void;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /**
  122666. * PostProcessRenderPipelineManager class
  122667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122668. */
  122669. export class PostProcessRenderPipelineManager {
  122670. private _renderPipelines;
  122671. /**
  122672. * Initializes a PostProcessRenderPipelineManager
  122673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122674. */
  122675. constructor();
  122676. /**
  122677. * Gets the list of supported render pipelines
  122678. */
  122679. readonly supportedPipelines: PostProcessRenderPipeline[];
  122680. /**
  122681. * Adds a pipeline to the manager
  122682. * @param renderPipeline The pipeline to add
  122683. */
  122684. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  122685. /**
  122686. * Attaches a camera to the pipeline
  122687. * @param renderPipelineName The name of the pipeline to attach to
  122688. * @param cameras the camera to attach
  122689. * @param unique if the camera can be attached multiple times to the pipeline
  122690. */
  122691. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  122692. /**
  122693. * Detaches a camera from the pipeline
  122694. * @param renderPipelineName The name of the pipeline to detach from
  122695. * @param cameras the camera to detach
  122696. */
  122697. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  122698. /**
  122699. * Enables an effect by name on a pipeline
  122700. * @param renderPipelineName the name of the pipeline to enable the effect in
  122701. * @param renderEffectName the name of the effect to enable
  122702. * @param cameras the cameras that the effect should be enabled on
  122703. */
  122704. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122705. /**
  122706. * Disables an effect by name on a pipeline
  122707. * @param renderPipelineName the name of the pipeline to disable the effect in
  122708. * @param renderEffectName the name of the effect to disable
  122709. * @param cameras the cameras that the effect should be disabled on
  122710. */
  122711. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122712. /**
  122713. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122714. */
  122715. update(): void;
  122716. /** @hidden */
  122717. _rebuild(): void;
  122718. /**
  122719. * Disposes of the manager and pipelines
  122720. */
  122721. dispose(): void;
  122722. }
  122723. }
  122724. declare module BABYLON {
  122725. interface Scene {
  122726. /** @hidden (Backing field) */
  122727. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122728. /**
  122729. * Gets the postprocess render pipeline manager
  122730. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122731. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122732. */
  122733. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122734. }
  122735. /**
  122736. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122737. */
  122738. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  122739. /**
  122740. * The component name helpfull to identify the component in the list of scene components.
  122741. */
  122742. readonly name: string;
  122743. /**
  122744. * The scene the component belongs to.
  122745. */
  122746. scene: Scene;
  122747. /**
  122748. * Creates a new instance of the component for the given scene
  122749. * @param scene Defines the scene to register the component in
  122750. */
  122751. constructor(scene: Scene);
  122752. /**
  122753. * Registers the component in a given scene
  122754. */
  122755. register(): void;
  122756. /**
  122757. * Rebuilds the elements related to this component in case of
  122758. * context lost for instance.
  122759. */
  122760. rebuild(): void;
  122761. /**
  122762. * Disposes the component and the associated ressources
  122763. */
  122764. dispose(): void;
  122765. private _gatherRenderTargets;
  122766. }
  122767. }
  122768. declare module BABYLON {
  122769. /**
  122770. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  122771. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122772. */
  122773. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122774. private _scene;
  122775. private _camerasToBeAttached;
  122776. /**
  122777. * ID of the sharpen post process,
  122778. */
  122779. private readonly SharpenPostProcessId;
  122780. /**
  122781. * @ignore
  122782. * ID of the image processing post process;
  122783. */
  122784. readonly ImageProcessingPostProcessId: string;
  122785. /**
  122786. * @ignore
  122787. * ID of the Fast Approximate Anti-Aliasing post process;
  122788. */
  122789. readonly FxaaPostProcessId: string;
  122790. /**
  122791. * ID of the chromatic aberration post process,
  122792. */
  122793. private readonly ChromaticAberrationPostProcessId;
  122794. /**
  122795. * ID of the grain post process
  122796. */
  122797. private readonly GrainPostProcessId;
  122798. /**
  122799. * Sharpen post process which will apply a sharpen convolution to enhance edges
  122800. */
  122801. sharpen: SharpenPostProcess;
  122802. private _sharpenEffect;
  122803. private bloom;
  122804. /**
  122805. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  122806. */
  122807. depthOfField: DepthOfFieldEffect;
  122808. /**
  122809. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122810. */
  122811. fxaa: FxaaPostProcess;
  122812. /**
  122813. * Image post processing pass used to perform operations such as tone mapping or color grading.
  122814. */
  122815. imageProcessing: ImageProcessingPostProcess;
  122816. /**
  122817. * Chromatic aberration post process which will shift rgb colors in the image
  122818. */
  122819. chromaticAberration: ChromaticAberrationPostProcess;
  122820. private _chromaticAberrationEffect;
  122821. /**
  122822. * Grain post process which add noise to the image
  122823. */
  122824. grain: GrainPostProcess;
  122825. private _grainEffect;
  122826. /**
  122827. * Glow post process which adds a glow to emissive areas of the image
  122828. */
  122829. private _glowLayer;
  122830. /**
  122831. * Animations which can be used to tweak settings over a period of time
  122832. */
  122833. animations: Animation[];
  122834. private _imageProcessingConfigurationObserver;
  122835. private _sharpenEnabled;
  122836. private _bloomEnabled;
  122837. private _depthOfFieldEnabled;
  122838. private _depthOfFieldBlurLevel;
  122839. private _fxaaEnabled;
  122840. private _imageProcessingEnabled;
  122841. private _defaultPipelineTextureType;
  122842. private _bloomScale;
  122843. private _chromaticAberrationEnabled;
  122844. private _grainEnabled;
  122845. private _buildAllowed;
  122846. /**
  122847. * Gets active scene
  122848. */
  122849. readonly scene: Scene;
  122850. /**
  122851. * Enable or disable the sharpen process from the pipeline
  122852. */
  122853. sharpenEnabled: boolean;
  122854. private _resizeObserver;
  122855. private _hardwareScaleLevel;
  122856. private _bloomKernel;
  122857. /**
  122858. * Specifies the size of the bloom blur kernel, relative to the final output size
  122859. */
  122860. bloomKernel: number;
  122861. /**
  122862. * Specifies the weight of the bloom in the final rendering
  122863. */
  122864. private _bloomWeight;
  122865. /**
  122866. * Specifies the luma threshold for the area that will be blurred by the bloom
  122867. */
  122868. private _bloomThreshold;
  122869. private _hdr;
  122870. /**
  122871. * The strength of the bloom.
  122872. */
  122873. bloomWeight: number;
  122874. /**
  122875. * The strength of the bloom.
  122876. */
  122877. bloomThreshold: number;
  122878. /**
  122879. * The scale of the bloom, lower value will provide better performance.
  122880. */
  122881. bloomScale: number;
  122882. /**
  122883. * Enable or disable the bloom from the pipeline
  122884. */
  122885. bloomEnabled: boolean;
  122886. private _rebuildBloom;
  122887. /**
  122888. * If the depth of field is enabled.
  122889. */
  122890. depthOfFieldEnabled: boolean;
  122891. /**
  122892. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122893. */
  122894. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122895. /**
  122896. * If the anti aliasing is enabled.
  122897. */
  122898. fxaaEnabled: boolean;
  122899. private _samples;
  122900. /**
  122901. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122902. */
  122903. samples: number;
  122904. /**
  122905. * If image processing is enabled.
  122906. */
  122907. imageProcessingEnabled: boolean;
  122908. /**
  122909. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122910. */
  122911. glowLayerEnabled: boolean;
  122912. /**
  122913. * Gets the glow layer (or null if not defined)
  122914. */
  122915. readonly glowLayer: Nullable<GlowLayer>;
  122916. /**
  122917. * Enable or disable the chromaticAberration process from the pipeline
  122918. */
  122919. chromaticAberrationEnabled: boolean;
  122920. /**
  122921. * Enable or disable the grain process from the pipeline
  122922. */
  122923. grainEnabled: boolean;
  122924. /**
  122925. * @constructor
  122926. * @param name - The rendering pipeline name (default: "")
  122927. * @param hdr - If high dynamic range textures should be used (default: true)
  122928. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122929. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122930. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122931. */
  122932. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122933. /**
  122934. * Get the class name
  122935. * @returns "DefaultRenderingPipeline"
  122936. */
  122937. getClassName(): string;
  122938. /**
  122939. * Force the compilation of the entire pipeline.
  122940. */
  122941. prepare(): void;
  122942. private _hasCleared;
  122943. private _prevPostProcess;
  122944. private _prevPrevPostProcess;
  122945. private _setAutoClearAndTextureSharing;
  122946. private _depthOfFieldSceneObserver;
  122947. private _buildPipeline;
  122948. private _disposePostProcesses;
  122949. /**
  122950. * Adds a camera to the pipeline
  122951. * @param camera the camera to be added
  122952. */
  122953. addCamera(camera: Camera): void;
  122954. /**
  122955. * Removes a camera from the pipeline
  122956. * @param camera the camera to remove
  122957. */
  122958. removeCamera(camera: Camera): void;
  122959. /**
  122960. * Dispose of the pipeline and stop all post processes
  122961. */
  122962. dispose(): void;
  122963. /**
  122964. * Serialize the rendering pipeline (Used when exporting)
  122965. * @returns the serialized object
  122966. */
  122967. serialize(): any;
  122968. /**
  122969. * Parse the serialized pipeline
  122970. * @param source Source pipeline.
  122971. * @param scene The scene to load the pipeline to.
  122972. * @param rootUrl The URL of the serialized pipeline.
  122973. * @returns An instantiated pipeline from the serialized object.
  122974. */
  122975. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122976. }
  122977. }
  122978. declare module BABYLON {
  122979. /** @hidden */
  122980. export var lensHighlightsPixelShader: {
  122981. name: string;
  122982. shader: string;
  122983. };
  122984. }
  122985. declare module BABYLON {
  122986. /** @hidden */
  122987. export var depthOfFieldPixelShader: {
  122988. name: string;
  122989. shader: string;
  122990. };
  122991. }
  122992. declare module BABYLON {
  122993. /**
  122994. * BABYLON.JS Chromatic Aberration GLSL Shader
  122995. * Author: Olivier Guyot
  122996. * Separates very slightly R, G and B colors on the edges of the screen
  122997. * Inspired by Francois Tarlier & Martins Upitis
  122998. */
  122999. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  123000. /**
  123001. * @ignore
  123002. * The chromatic aberration PostProcess id in the pipeline
  123003. */
  123004. LensChromaticAberrationEffect: string;
  123005. /**
  123006. * @ignore
  123007. * The highlights enhancing PostProcess id in the pipeline
  123008. */
  123009. HighlightsEnhancingEffect: string;
  123010. /**
  123011. * @ignore
  123012. * The depth-of-field PostProcess id in the pipeline
  123013. */
  123014. LensDepthOfFieldEffect: string;
  123015. private _scene;
  123016. private _depthTexture;
  123017. private _grainTexture;
  123018. private _chromaticAberrationPostProcess;
  123019. private _highlightsPostProcess;
  123020. private _depthOfFieldPostProcess;
  123021. private _edgeBlur;
  123022. private _grainAmount;
  123023. private _chromaticAberration;
  123024. private _distortion;
  123025. private _highlightsGain;
  123026. private _highlightsThreshold;
  123027. private _dofDistance;
  123028. private _dofAperture;
  123029. private _dofDarken;
  123030. private _dofPentagon;
  123031. private _blurNoise;
  123032. /**
  123033. * @constructor
  123034. *
  123035. * Effect parameters are as follow:
  123036. * {
  123037. * chromatic_aberration: number; // from 0 to x (1 for realism)
  123038. * edge_blur: number; // from 0 to x (1 for realism)
  123039. * distortion: number; // from 0 to x (1 for realism)
  123040. * grain_amount: number; // from 0 to 1
  123041. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  123042. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  123043. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  123044. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  123045. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  123046. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  123047. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  123048. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  123049. * }
  123050. * Note: if an effect parameter is unset, effect is disabled
  123051. *
  123052. * @param name The rendering pipeline name
  123053. * @param parameters - An object containing all parameters (see above)
  123054. * @param scene The scene linked to this pipeline
  123055. * @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)
  123056. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123057. */
  123058. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  123059. /**
  123060. * Get the class name
  123061. * @returns "LensRenderingPipeline"
  123062. */
  123063. getClassName(): string;
  123064. /**
  123065. * Gets associated scene
  123066. */
  123067. readonly scene: Scene;
  123068. /**
  123069. * Gets or sets the edge blur
  123070. */
  123071. edgeBlur: number;
  123072. /**
  123073. * Gets or sets the grain amount
  123074. */
  123075. grainAmount: number;
  123076. /**
  123077. * Gets or sets the chromatic aberration amount
  123078. */
  123079. chromaticAberration: number;
  123080. /**
  123081. * Gets or sets the depth of field aperture
  123082. */
  123083. dofAperture: number;
  123084. /**
  123085. * Gets or sets the edge distortion
  123086. */
  123087. edgeDistortion: number;
  123088. /**
  123089. * Gets or sets the depth of field distortion
  123090. */
  123091. dofDistortion: number;
  123092. /**
  123093. * Gets or sets the darken out of focus amount
  123094. */
  123095. darkenOutOfFocus: number;
  123096. /**
  123097. * Gets or sets a boolean indicating if blur noise is enabled
  123098. */
  123099. blurNoise: boolean;
  123100. /**
  123101. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  123102. */
  123103. pentagonBokeh: boolean;
  123104. /**
  123105. * Gets or sets the highlight grain amount
  123106. */
  123107. highlightsGain: number;
  123108. /**
  123109. * Gets or sets the highlight threshold
  123110. */
  123111. highlightsThreshold: number;
  123112. /**
  123113. * Sets the amount of blur at the edges
  123114. * @param amount blur amount
  123115. */
  123116. setEdgeBlur(amount: number): void;
  123117. /**
  123118. * Sets edge blur to 0
  123119. */
  123120. disableEdgeBlur(): void;
  123121. /**
  123122. * Sets the amout of grain
  123123. * @param amount Amount of grain
  123124. */
  123125. setGrainAmount(amount: number): void;
  123126. /**
  123127. * Set grain amount to 0
  123128. */
  123129. disableGrain(): void;
  123130. /**
  123131. * Sets the chromatic aberration amount
  123132. * @param amount amount of chromatic aberration
  123133. */
  123134. setChromaticAberration(amount: number): void;
  123135. /**
  123136. * Sets chromatic aberration amount to 0
  123137. */
  123138. disableChromaticAberration(): void;
  123139. /**
  123140. * Sets the EdgeDistortion amount
  123141. * @param amount amount of EdgeDistortion
  123142. */
  123143. setEdgeDistortion(amount: number): void;
  123144. /**
  123145. * Sets edge distortion to 0
  123146. */
  123147. disableEdgeDistortion(): void;
  123148. /**
  123149. * Sets the FocusDistance amount
  123150. * @param amount amount of FocusDistance
  123151. */
  123152. setFocusDistance(amount: number): void;
  123153. /**
  123154. * Disables depth of field
  123155. */
  123156. disableDepthOfField(): void;
  123157. /**
  123158. * Sets the Aperture amount
  123159. * @param amount amount of Aperture
  123160. */
  123161. setAperture(amount: number): void;
  123162. /**
  123163. * Sets the DarkenOutOfFocus amount
  123164. * @param amount amount of DarkenOutOfFocus
  123165. */
  123166. setDarkenOutOfFocus(amount: number): void;
  123167. private _pentagonBokehIsEnabled;
  123168. /**
  123169. * Creates a pentagon bokeh effect
  123170. */
  123171. enablePentagonBokeh(): void;
  123172. /**
  123173. * Disables the pentagon bokeh effect
  123174. */
  123175. disablePentagonBokeh(): void;
  123176. /**
  123177. * Enables noise blur
  123178. */
  123179. enableNoiseBlur(): void;
  123180. /**
  123181. * Disables noise blur
  123182. */
  123183. disableNoiseBlur(): void;
  123184. /**
  123185. * Sets the HighlightsGain amount
  123186. * @param amount amount of HighlightsGain
  123187. */
  123188. setHighlightsGain(amount: number): void;
  123189. /**
  123190. * Sets the HighlightsThreshold amount
  123191. * @param amount amount of HighlightsThreshold
  123192. */
  123193. setHighlightsThreshold(amount: number): void;
  123194. /**
  123195. * Disables highlights
  123196. */
  123197. disableHighlights(): void;
  123198. /**
  123199. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  123200. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  123201. */
  123202. dispose(disableDepthRender?: boolean): void;
  123203. private _createChromaticAberrationPostProcess;
  123204. private _createHighlightsPostProcess;
  123205. private _createDepthOfFieldPostProcess;
  123206. private _createGrainTexture;
  123207. }
  123208. }
  123209. declare module BABYLON {
  123210. /** @hidden */
  123211. export var ssao2PixelShader: {
  123212. name: string;
  123213. shader: string;
  123214. };
  123215. }
  123216. declare module BABYLON {
  123217. /** @hidden */
  123218. export var ssaoCombinePixelShader: {
  123219. name: string;
  123220. shader: string;
  123221. };
  123222. }
  123223. declare module BABYLON {
  123224. /**
  123225. * Render pipeline to produce ssao effect
  123226. */
  123227. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  123228. /**
  123229. * @ignore
  123230. * The PassPostProcess id in the pipeline that contains the original scene color
  123231. */
  123232. SSAOOriginalSceneColorEffect: string;
  123233. /**
  123234. * @ignore
  123235. * The SSAO PostProcess id in the pipeline
  123236. */
  123237. SSAORenderEffect: string;
  123238. /**
  123239. * @ignore
  123240. * The horizontal blur PostProcess id in the pipeline
  123241. */
  123242. SSAOBlurHRenderEffect: string;
  123243. /**
  123244. * @ignore
  123245. * The vertical blur PostProcess id in the pipeline
  123246. */
  123247. SSAOBlurVRenderEffect: string;
  123248. /**
  123249. * @ignore
  123250. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123251. */
  123252. SSAOCombineRenderEffect: string;
  123253. /**
  123254. * The output strength of the SSAO post-process. Default value is 1.0.
  123255. */
  123256. totalStrength: number;
  123257. /**
  123258. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123259. */
  123260. maxZ: number;
  123261. /**
  123262. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123263. */
  123264. minZAspect: number;
  123265. private _samples;
  123266. /**
  123267. * Number of samples used for the SSAO calculations. Default value is 8
  123268. */
  123269. samples: number;
  123270. private _textureSamples;
  123271. /**
  123272. * Number of samples to use for antialiasing
  123273. */
  123274. textureSamples: number;
  123275. /**
  123276. * Ratio object used for SSAO ratio and blur ratio
  123277. */
  123278. private _ratio;
  123279. /**
  123280. * Dynamically generated sphere sampler.
  123281. */
  123282. private _sampleSphere;
  123283. /**
  123284. * Blur filter offsets
  123285. */
  123286. private _samplerOffsets;
  123287. private _expensiveBlur;
  123288. /**
  123289. * If bilateral blur should be used
  123290. */
  123291. expensiveBlur: boolean;
  123292. /**
  123293. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123294. */
  123295. radius: number;
  123296. /**
  123297. * The base color of the SSAO post-process
  123298. * The final result is "base + ssao" between [0, 1]
  123299. */
  123300. base: number;
  123301. /**
  123302. * Support test.
  123303. */
  123304. static readonly IsSupported: boolean;
  123305. private _scene;
  123306. private _depthTexture;
  123307. private _normalTexture;
  123308. private _randomTexture;
  123309. private _originalColorPostProcess;
  123310. private _ssaoPostProcess;
  123311. private _blurHPostProcess;
  123312. private _blurVPostProcess;
  123313. private _ssaoCombinePostProcess;
  123314. private _firstUpdate;
  123315. /**
  123316. * Gets active scene
  123317. */
  123318. readonly scene: Scene;
  123319. /**
  123320. * @constructor
  123321. * @param name The rendering pipeline name
  123322. * @param scene The scene linked to this pipeline
  123323. * @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 }
  123324. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123325. */
  123326. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123327. /**
  123328. * Get the class name
  123329. * @returns "SSAO2RenderingPipeline"
  123330. */
  123331. getClassName(): string;
  123332. /**
  123333. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123334. */
  123335. dispose(disableGeometryBufferRenderer?: boolean): void;
  123336. private _createBlurPostProcess;
  123337. /** @hidden */
  123338. _rebuild(): void;
  123339. private _bits;
  123340. private _radicalInverse_VdC;
  123341. private _hammersley;
  123342. private _hemisphereSample_uniform;
  123343. private _generateHemisphere;
  123344. private _createSSAOPostProcess;
  123345. private _createSSAOCombinePostProcess;
  123346. private _createRandomTexture;
  123347. /**
  123348. * Serialize the rendering pipeline (Used when exporting)
  123349. * @returns the serialized object
  123350. */
  123351. serialize(): any;
  123352. /**
  123353. * Parse the serialized pipeline
  123354. * @param source Source pipeline.
  123355. * @param scene The scene to load the pipeline to.
  123356. * @param rootUrl The URL of the serialized pipeline.
  123357. * @returns An instantiated pipeline from the serialized object.
  123358. */
  123359. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123360. }
  123361. }
  123362. declare module BABYLON {
  123363. /** @hidden */
  123364. export var ssaoPixelShader: {
  123365. name: string;
  123366. shader: string;
  123367. };
  123368. }
  123369. declare module BABYLON {
  123370. /**
  123371. * Render pipeline to produce ssao effect
  123372. */
  123373. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  123374. /**
  123375. * @ignore
  123376. * The PassPostProcess id in the pipeline that contains the original scene color
  123377. */
  123378. SSAOOriginalSceneColorEffect: string;
  123379. /**
  123380. * @ignore
  123381. * The SSAO PostProcess id in the pipeline
  123382. */
  123383. SSAORenderEffect: string;
  123384. /**
  123385. * @ignore
  123386. * The horizontal blur PostProcess id in the pipeline
  123387. */
  123388. SSAOBlurHRenderEffect: string;
  123389. /**
  123390. * @ignore
  123391. * The vertical blur PostProcess id in the pipeline
  123392. */
  123393. SSAOBlurVRenderEffect: string;
  123394. /**
  123395. * @ignore
  123396. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123397. */
  123398. SSAOCombineRenderEffect: string;
  123399. /**
  123400. * The output strength of the SSAO post-process. Default value is 1.0.
  123401. */
  123402. totalStrength: number;
  123403. /**
  123404. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  123405. */
  123406. radius: number;
  123407. /**
  123408. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  123409. * Must not be equal to fallOff and superior to fallOff.
  123410. * Default value is 0.0075
  123411. */
  123412. area: number;
  123413. /**
  123414. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  123415. * Must not be equal to area and inferior to area.
  123416. * Default value is 0.000001
  123417. */
  123418. fallOff: number;
  123419. /**
  123420. * The base color of the SSAO post-process
  123421. * The final result is "base + ssao" between [0, 1]
  123422. */
  123423. base: number;
  123424. private _scene;
  123425. private _depthTexture;
  123426. private _randomTexture;
  123427. private _originalColorPostProcess;
  123428. private _ssaoPostProcess;
  123429. private _blurHPostProcess;
  123430. private _blurVPostProcess;
  123431. private _ssaoCombinePostProcess;
  123432. private _firstUpdate;
  123433. /**
  123434. * Gets active scene
  123435. */
  123436. readonly scene: Scene;
  123437. /**
  123438. * @constructor
  123439. * @param name - The rendering pipeline name
  123440. * @param scene - The scene linked to this pipeline
  123441. * @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 }
  123442. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  123443. */
  123444. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123445. /**
  123446. * Get the class name
  123447. * @returns "SSAORenderingPipeline"
  123448. */
  123449. getClassName(): string;
  123450. /**
  123451. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123452. */
  123453. dispose(disableDepthRender?: boolean): void;
  123454. private _createBlurPostProcess;
  123455. /** @hidden */
  123456. _rebuild(): void;
  123457. private _createSSAOPostProcess;
  123458. private _createSSAOCombinePostProcess;
  123459. private _createRandomTexture;
  123460. }
  123461. }
  123462. declare module BABYLON {
  123463. /** @hidden */
  123464. export var standardPixelShader: {
  123465. name: string;
  123466. shader: string;
  123467. };
  123468. }
  123469. declare module BABYLON {
  123470. /**
  123471. * Standard rendering pipeline
  123472. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123473. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  123474. */
  123475. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123476. /**
  123477. * Public members
  123478. */
  123479. /**
  123480. * Post-process which contains the original scene color before the pipeline applies all the effects
  123481. */
  123482. originalPostProcess: Nullable<PostProcess>;
  123483. /**
  123484. * Post-process used to down scale an image x4
  123485. */
  123486. downSampleX4PostProcess: Nullable<PostProcess>;
  123487. /**
  123488. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  123489. */
  123490. brightPassPostProcess: Nullable<PostProcess>;
  123491. /**
  123492. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  123493. */
  123494. blurHPostProcesses: PostProcess[];
  123495. /**
  123496. * Post-process array storing all the vertical blur post-processes used by the pipeline
  123497. */
  123498. blurVPostProcesses: PostProcess[];
  123499. /**
  123500. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  123501. */
  123502. textureAdderPostProcess: Nullable<PostProcess>;
  123503. /**
  123504. * Post-process used to create volumetric lighting effect
  123505. */
  123506. volumetricLightPostProcess: Nullable<PostProcess>;
  123507. /**
  123508. * Post-process used to smooth the previous volumetric light post-process on the X axis
  123509. */
  123510. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  123511. /**
  123512. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  123513. */
  123514. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123515. /**
  123516. * Post-process used to merge the volumetric light effect and the real scene color
  123517. */
  123518. volumetricLightMergePostProces: Nullable<PostProcess>;
  123519. /**
  123520. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  123521. */
  123522. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  123523. /**
  123524. * Base post-process used to calculate the average luminance of the final image for HDR
  123525. */
  123526. luminancePostProcess: Nullable<PostProcess>;
  123527. /**
  123528. * Post-processes used to create down sample post-processes in order to get
  123529. * the average luminance of the final image for HDR
  123530. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  123531. */
  123532. luminanceDownSamplePostProcesses: PostProcess[];
  123533. /**
  123534. * Post-process used to create a HDR effect (light adaptation)
  123535. */
  123536. hdrPostProcess: Nullable<PostProcess>;
  123537. /**
  123538. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  123539. */
  123540. textureAdderFinalPostProcess: Nullable<PostProcess>;
  123541. /**
  123542. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  123543. */
  123544. lensFlareFinalPostProcess: Nullable<PostProcess>;
  123545. /**
  123546. * Post-process used to merge the final HDR post-process and the real scene color
  123547. */
  123548. hdrFinalPostProcess: Nullable<PostProcess>;
  123549. /**
  123550. * Post-process used to create a lens flare effect
  123551. */
  123552. lensFlarePostProcess: Nullable<PostProcess>;
  123553. /**
  123554. * Post-process that merges the result of the lens flare post-process and the real scene color
  123555. */
  123556. lensFlareComposePostProcess: Nullable<PostProcess>;
  123557. /**
  123558. * Post-process used to create a motion blur effect
  123559. */
  123560. motionBlurPostProcess: Nullable<PostProcess>;
  123561. /**
  123562. * Post-process used to create a depth of field effect
  123563. */
  123564. depthOfFieldPostProcess: Nullable<PostProcess>;
  123565. /**
  123566. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123567. */
  123568. fxaaPostProcess: Nullable<FxaaPostProcess>;
  123569. /**
  123570. * Represents the brightness threshold in order to configure the illuminated surfaces
  123571. */
  123572. brightThreshold: number;
  123573. /**
  123574. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  123575. */
  123576. blurWidth: number;
  123577. /**
  123578. * Sets if the blur for highlighted surfaces must be only horizontal
  123579. */
  123580. horizontalBlur: boolean;
  123581. /**
  123582. * Gets the overall exposure used by the pipeline
  123583. */
  123584. /**
  123585. * Sets the overall exposure used by the pipeline
  123586. */
  123587. exposure: number;
  123588. /**
  123589. * Texture used typically to simulate "dirty" on camera lens
  123590. */
  123591. lensTexture: Nullable<Texture>;
  123592. /**
  123593. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  123594. */
  123595. volumetricLightCoefficient: number;
  123596. /**
  123597. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  123598. */
  123599. volumetricLightPower: number;
  123600. /**
  123601. * Used the set the blur intensity to smooth the volumetric lights
  123602. */
  123603. volumetricLightBlurScale: number;
  123604. /**
  123605. * Light (spot or directional) used to generate the volumetric lights rays
  123606. * The source light must have a shadow generate so the pipeline can get its
  123607. * depth map
  123608. */
  123609. sourceLight: Nullable<SpotLight | DirectionalLight>;
  123610. /**
  123611. * For eye adaptation, represents the minimum luminance the eye can see
  123612. */
  123613. hdrMinimumLuminance: number;
  123614. /**
  123615. * For eye adaptation, represents the decrease luminance speed
  123616. */
  123617. hdrDecreaseRate: number;
  123618. /**
  123619. * For eye adaptation, represents the increase luminance speed
  123620. */
  123621. hdrIncreaseRate: number;
  123622. /**
  123623. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123624. */
  123625. /**
  123626. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123627. */
  123628. hdrAutoExposure: boolean;
  123629. /**
  123630. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  123631. */
  123632. lensColorTexture: Nullable<Texture>;
  123633. /**
  123634. * The overall strengh for the lens flare effect
  123635. */
  123636. lensFlareStrength: number;
  123637. /**
  123638. * Dispersion coefficient for lens flare ghosts
  123639. */
  123640. lensFlareGhostDispersal: number;
  123641. /**
  123642. * Main lens flare halo width
  123643. */
  123644. lensFlareHaloWidth: number;
  123645. /**
  123646. * Based on the lens distortion effect, defines how much the lens flare result
  123647. * is distorted
  123648. */
  123649. lensFlareDistortionStrength: number;
  123650. /**
  123651. * Lens star texture must be used to simulate rays on the flares and is available
  123652. * in the documentation
  123653. */
  123654. lensStarTexture: Nullable<Texture>;
  123655. /**
  123656. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  123657. * flare effect by taking account of the dirt texture
  123658. */
  123659. lensFlareDirtTexture: Nullable<Texture>;
  123660. /**
  123661. * Represents the focal length for the depth of field effect
  123662. */
  123663. depthOfFieldDistance: number;
  123664. /**
  123665. * Represents the blur intensity for the blurred part of the depth of field effect
  123666. */
  123667. depthOfFieldBlurWidth: number;
  123668. /**
  123669. * Gets how much the image is blurred by the movement while using the motion blur post-process
  123670. */
  123671. /**
  123672. * Sets how much the image is blurred by the movement while using the motion blur post-process
  123673. */
  123674. motionStrength: number;
  123675. /**
  123676. * Gets wether or not the motion blur post-process is object based or screen based.
  123677. */
  123678. /**
  123679. * Sets wether or not the motion blur post-process should be object based or screen based
  123680. */
  123681. objectBasedMotionBlur: boolean;
  123682. /**
  123683. * List of animations for the pipeline (IAnimatable implementation)
  123684. */
  123685. animations: Animation[];
  123686. /**
  123687. * Private members
  123688. */
  123689. private _scene;
  123690. private _currentDepthOfFieldSource;
  123691. private _basePostProcess;
  123692. private _fixedExposure;
  123693. private _currentExposure;
  123694. private _hdrAutoExposure;
  123695. private _hdrCurrentLuminance;
  123696. private _motionStrength;
  123697. private _isObjectBasedMotionBlur;
  123698. private _floatTextureType;
  123699. private _camerasToBeAttached;
  123700. private _ratio;
  123701. private _bloomEnabled;
  123702. private _depthOfFieldEnabled;
  123703. private _vlsEnabled;
  123704. private _lensFlareEnabled;
  123705. private _hdrEnabled;
  123706. private _motionBlurEnabled;
  123707. private _fxaaEnabled;
  123708. private _motionBlurSamples;
  123709. private _volumetricLightStepsCount;
  123710. private _samples;
  123711. /**
  123712. * @ignore
  123713. * Specifies if the bloom pipeline is enabled
  123714. */
  123715. BloomEnabled: boolean;
  123716. /**
  123717. * @ignore
  123718. * Specifies if the depth of field pipeline is enabed
  123719. */
  123720. DepthOfFieldEnabled: boolean;
  123721. /**
  123722. * @ignore
  123723. * Specifies if the lens flare pipeline is enabed
  123724. */
  123725. LensFlareEnabled: boolean;
  123726. /**
  123727. * @ignore
  123728. * Specifies if the HDR pipeline is enabled
  123729. */
  123730. HDREnabled: boolean;
  123731. /**
  123732. * @ignore
  123733. * Specifies if the volumetric lights scattering effect is enabled
  123734. */
  123735. VLSEnabled: boolean;
  123736. /**
  123737. * @ignore
  123738. * Specifies if the motion blur effect is enabled
  123739. */
  123740. MotionBlurEnabled: boolean;
  123741. /**
  123742. * Specifies if anti-aliasing is enabled
  123743. */
  123744. fxaaEnabled: boolean;
  123745. /**
  123746. * Specifies the number of steps used to calculate the volumetric lights
  123747. * Typically in interval [50, 200]
  123748. */
  123749. volumetricLightStepsCount: number;
  123750. /**
  123751. * Specifies the number of samples used for the motion blur effect
  123752. * Typically in interval [16, 64]
  123753. */
  123754. motionBlurSamples: number;
  123755. /**
  123756. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123757. */
  123758. samples: number;
  123759. /**
  123760. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123761. * @constructor
  123762. * @param name The rendering pipeline name
  123763. * @param scene The scene linked to this pipeline
  123764. * @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)
  123765. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  123766. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123767. */
  123768. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  123769. private _buildPipeline;
  123770. private _createDownSampleX4PostProcess;
  123771. private _createBrightPassPostProcess;
  123772. private _createBlurPostProcesses;
  123773. private _createTextureAdderPostProcess;
  123774. private _createVolumetricLightPostProcess;
  123775. private _createLuminancePostProcesses;
  123776. private _createHdrPostProcess;
  123777. private _createLensFlarePostProcess;
  123778. private _createDepthOfFieldPostProcess;
  123779. private _createMotionBlurPostProcess;
  123780. private _getDepthTexture;
  123781. private _disposePostProcesses;
  123782. /**
  123783. * Dispose of the pipeline and stop all post processes
  123784. */
  123785. dispose(): void;
  123786. /**
  123787. * Serialize the rendering pipeline (Used when exporting)
  123788. * @returns the serialized object
  123789. */
  123790. serialize(): any;
  123791. /**
  123792. * Parse the serialized pipeline
  123793. * @param source Source pipeline.
  123794. * @param scene The scene to load the pipeline to.
  123795. * @param rootUrl The URL of the serialized pipeline.
  123796. * @returns An instantiated pipeline from the serialized object.
  123797. */
  123798. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  123799. /**
  123800. * Luminance steps
  123801. */
  123802. static LuminanceSteps: number;
  123803. }
  123804. }
  123805. declare module BABYLON {
  123806. /** @hidden */
  123807. export var tonemapPixelShader: {
  123808. name: string;
  123809. shader: string;
  123810. };
  123811. }
  123812. declare module BABYLON {
  123813. /** Defines operator used for tonemapping */
  123814. export enum TonemappingOperator {
  123815. /** Hable */
  123816. Hable = 0,
  123817. /** Reinhard */
  123818. Reinhard = 1,
  123819. /** HejiDawson */
  123820. HejiDawson = 2,
  123821. /** Photographic */
  123822. Photographic = 3
  123823. }
  123824. /**
  123825. * Defines a post process to apply tone mapping
  123826. */
  123827. export class TonemapPostProcess extends PostProcess {
  123828. private _operator;
  123829. /** Defines the required exposure adjustement */
  123830. exposureAdjustment: number;
  123831. /**
  123832. * Creates a new TonemapPostProcess
  123833. * @param name defines the name of the postprocess
  123834. * @param _operator defines the operator to use
  123835. * @param exposureAdjustment defines the required exposure adjustement
  123836. * @param camera defines the camera to use (can be null)
  123837. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123838. * @param engine defines the hosting engine (can be ignore if camera is set)
  123839. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123840. */
  123841. constructor(name: string, _operator: TonemappingOperator,
  123842. /** Defines the required exposure adjustement */
  123843. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  123844. }
  123845. }
  123846. declare module BABYLON {
  123847. /** @hidden */
  123848. export var depthVertexShader: {
  123849. name: string;
  123850. shader: string;
  123851. };
  123852. }
  123853. declare module BABYLON {
  123854. /** @hidden */
  123855. export var volumetricLightScatteringPixelShader: {
  123856. name: string;
  123857. shader: string;
  123858. };
  123859. }
  123860. declare module BABYLON {
  123861. /** @hidden */
  123862. export var volumetricLightScatteringPassVertexShader: {
  123863. name: string;
  123864. shader: string;
  123865. };
  123866. }
  123867. declare module BABYLON {
  123868. /** @hidden */
  123869. export var volumetricLightScatteringPassPixelShader: {
  123870. name: string;
  123871. shader: string;
  123872. };
  123873. }
  123874. declare module BABYLON {
  123875. /**
  123876. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123877. */
  123878. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123879. private _volumetricLightScatteringPass;
  123880. private _volumetricLightScatteringRTT;
  123881. private _viewPort;
  123882. private _screenCoordinates;
  123883. private _cachedDefines;
  123884. /**
  123885. * If not undefined, the mesh position is computed from the attached node position
  123886. */
  123887. attachedNode: {
  123888. position: Vector3;
  123889. };
  123890. /**
  123891. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123892. */
  123893. customMeshPosition: Vector3;
  123894. /**
  123895. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123896. */
  123897. useCustomMeshPosition: boolean;
  123898. /**
  123899. * If the post-process should inverse the light scattering direction
  123900. */
  123901. invert: boolean;
  123902. /**
  123903. * The internal mesh used by the post-process
  123904. */
  123905. mesh: Mesh;
  123906. /**
  123907. * @hidden
  123908. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123909. */
  123910. useDiffuseColor: boolean;
  123911. /**
  123912. * Array containing the excluded meshes not rendered in the internal pass
  123913. */
  123914. excludedMeshes: AbstractMesh[];
  123915. /**
  123916. * Controls the overall intensity of the post-process
  123917. */
  123918. exposure: number;
  123919. /**
  123920. * Dissipates each sample's contribution in range [0, 1]
  123921. */
  123922. decay: number;
  123923. /**
  123924. * Controls the overall intensity of each sample
  123925. */
  123926. weight: number;
  123927. /**
  123928. * Controls the density of each sample
  123929. */
  123930. density: number;
  123931. /**
  123932. * @constructor
  123933. * @param name The post-process name
  123934. * @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)
  123935. * @param camera The camera that the post-process will be attached to
  123936. * @param mesh The mesh used to create the light scattering
  123937. * @param samples The post-process quality, default 100
  123938. * @param samplingModeThe post-process filtering mode
  123939. * @param engine The babylon engine
  123940. * @param reusable If the post-process is reusable
  123941. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123942. */
  123943. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123944. /**
  123945. * Returns the string "VolumetricLightScatteringPostProcess"
  123946. * @returns "VolumetricLightScatteringPostProcess"
  123947. */
  123948. getClassName(): string;
  123949. private _isReady;
  123950. /**
  123951. * Sets the new light position for light scattering effect
  123952. * @param position The new custom light position
  123953. */
  123954. setCustomMeshPosition(position: Vector3): void;
  123955. /**
  123956. * Returns the light position for light scattering effect
  123957. * @return Vector3 The custom light position
  123958. */
  123959. getCustomMeshPosition(): Vector3;
  123960. /**
  123961. * Disposes the internal assets and detaches the post-process from the camera
  123962. */
  123963. dispose(camera: Camera): void;
  123964. /**
  123965. * Returns the render target texture used by the post-process
  123966. * @return the render target texture used by the post-process
  123967. */
  123968. getPass(): RenderTargetTexture;
  123969. private _meshExcluded;
  123970. private _createPass;
  123971. private _updateMeshScreenCoordinates;
  123972. /**
  123973. * Creates a default mesh for the Volumeric Light Scattering post-process
  123974. * @param name The mesh name
  123975. * @param scene The scene where to create the mesh
  123976. * @return the default mesh
  123977. */
  123978. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123979. }
  123980. }
  123981. declare module BABYLON {
  123982. interface Scene {
  123983. /** @hidden (Backing field) */
  123984. _boundingBoxRenderer: BoundingBoxRenderer;
  123985. /** @hidden (Backing field) */
  123986. _forceShowBoundingBoxes: boolean;
  123987. /**
  123988. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123989. */
  123990. forceShowBoundingBoxes: boolean;
  123991. /**
  123992. * Gets the bounding box renderer associated with the scene
  123993. * @returns a BoundingBoxRenderer
  123994. */
  123995. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123996. }
  123997. interface AbstractMesh {
  123998. /** @hidden (Backing field) */
  123999. _showBoundingBox: boolean;
  124000. /**
  124001. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  124002. */
  124003. showBoundingBox: boolean;
  124004. }
  124005. /**
  124006. * Component responsible of rendering the bounding box of the meshes in a scene.
  124007. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124008. */
  124009. export class BoundingBoxRenderer implements ISceneComponent {
  124010. /**
  124011. * The component name helpfull to identify the component in the list of scene components.
  124012. */
  124013. readonly name: string;
  124014. /**
  124015. * The scene the component belongs to.
  124016. */
  124017. scene: Scene;
  124018. /**
  124019. * Color of the bounding box lines placed in front of an object
  124020. */
  124021. frontColor: Color3;
  124022. /**
  124023. * Color of the bounding box lines placed behind an object
  124024. */
  124025. backColor: Color3;
  124026. /**
  124027. * Defines if the renderer should show the back lines or not
  124028. */
  124029. showBackLines: boolean;
  124030. /**
  124031. * @hidden
  124032. */
  124033. renderList: SmartArray<BoundingBox>;
  124034. private _colorShader;
  124035. private _vertexBuffers;
  124036. private _indexBuffer;
  124037. private _fillIndexBuffer;
  124038. private _fillIndexData;
  124039. /**
  124040. * Instantiates a new bounding box renderer in a scene.
  124041. * @param scene the scene the renderer renders in
  124042. */
  124043. constructor(scene: Scene);
  124044. /**
  124045. * Registers the component in a given scene
  124046. */
  124047. register(): void;
  124048. private _evaluateSubMesh;
  124049. private _activeMesh;
  124050. private _prepareRessources;
  124051. private _createIndexBuffer;
  124052. /**
  124053. * Rebuilds the elements related to this component in case of
  124054. * context lost for instance.
  124055. */
  124056. rebuild(): void;
  124057. /**
  124058. * @hidden
  124059. */
  124060. reset(): void;
  124061. /**
  124062. * Render the bounding boxes of a specific rendering group
  124063. * @param renderingGroupId defines the rendering group to render
  124064. */
  124065. render(renderingGroupId: number): void;
  124066. /**
  124067. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124068. * @param mesh Define the mesh to render the occlusion bounding box for
  124069. */
  124070. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  124071. /**
  124072. * Dispose and release the resources attached to this renderer.
  124073. */
  124074. dispose(): void;
  124075. }
  124076. }
  124077. declare module BABYLON {
  124078. /** @hidden */
  124079. export var depthPixelShader: {
  124080. name: string;
  124081. shader: string;
  124082. };
  124083. }
  124084. declare module BABYLON {
  124085. /**
  124086. * This represents a depth renderer in Babylon.
  124087. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124088. */
  124089. export class DepthRenderer {
  124090. private _scene;
  124091. private _depthMap;
  124092. private _effect;
  124093. private readonly _storeNonLinearDepth;
  124094. private readonly _clearColor;
  124095. /** Get if the depth renderer is using packed depth or not */
  124096. readonly isPacked: boolean;
  124097. private _cachedDefines;
  124098. private _camera;
  124099. /**
  124100. * Specifiess that the depth renderer will only be used within
  124101. * the camera it is created for.
  124102. * This can help forcing its rendering during the camera processing.
  124103. */
  124104. useOnlyInActiveCamera: boolean;
  124105. /** @hidden */
  124106. static _SceneComponentInitialization: (scene: Scene) => void;
  124107. /**
  124108. * Instantiates a depth renderer
  124109. * @param scene The scene the renderer belongs to
  124110. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124111. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124112. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124113. */
  124114. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  124115. /**
  124116. * Creates the depth rendering effect and checks if the effect is ready.
  124117. * @param subMesh The submesh to be used to render the depth map of
  124118. * @param useInstances If multiple world instances should be used
  124119. * @returns if the depth renderer is ready to render the depth map
  124120. */
  124121. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124122. /**
  124123. * Gets the texture which the depth map will be written to.
  124124. * @returns The depth map texture
  124125. */
  124126. getDepthMap(): RenderTargetTexture;
  124127. /**
  124128. * Disposes of the depth renderer.
  124129. */
  124130. dispose(): void;
  124131. }
  124132. }
  124133. declare module BABYLON {
  124134. interface Scene {
  124135. /** @hidden (Backing field) */
  124136. _depthRenderer: {
  124137. [id: string]: DepthRenderer;
  124138. };
  124139. /**
  124140. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  124141. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  124142. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124143. * @returns the created depth renderer
  124144. */
  124145. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  124146. /**
  124147. * Disables a depth renderer for a given camera
  124148. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  124149. */
  124150. disableDepthRenderer(camera?: Nullable<Camera>): void;
  124151. }
  124152. /**
  124153. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124154. * in several rendering techniques.
  124155. */
  124156. export class DepthRendererSceneComponent implements ISceneComponent {
  124157. /**
  124158. * The component name helpfull to identify the component in the list of scene components.
  124159. */
  124160. readonly name: string;
  124161. /**
  124162. * The scene the component belongs to.
  124163. */
  124164. scene: Scene;
  124165. /**
  124166. * Creates a new instance of the component for the given scene
  124167. * @param scene Defines the scene to register the component in
  124168. */
  124169. constructor(scene: Scene);
  124170. /**
  124171. * Registers the component in a given scene
  124172. */
  124173. register(): void;
  124174. /**
  124175. * Rebuilds the elements related to this component in case of
  124176. * context lost for instance.
  124177. */
  124178. rebuild(): void;
  124179. /**
  124180. * Disposes the component and the associated ressources
  124181. */
  124182. dispose(): void;
  124183. private _gatherRenderTargets;
  124184. private _gatherActiveCameraRenderTargets;
  124185. }
  124186. }
  124187. declare module BABYLON {
  124188. /** @hidden */
  124189. export var outlinePixelShader: {
  124190. name: string;
  124191. shader: string;
  124192. };
  124193. }
  124194. declare module BABYLON {
  124195. /** @hidden */
  124196. export var outlineVertexShader: {
  124197. name: string;
  124198. shader: string;
  124199. };
  124200. }
  124201. declare module BABYLON {
  124202. interface Scene {
  124203. /** @hidden */
  124204. _outlineRenderer: OutlineRenderer;
  124205. /**
  124206. * Gets the outline renderer associated with the scene
  124207. * @returns a OutlineRenderer
  124208. */
  124209. getOutlineRenderer(): OutlineRenderer;
  124210. }
  124211. interface AbstractMesh {
  124212. /** @hidden (Backing field) */
  124213. _renderOutline: boolean;
  124214. /**
  124215. * Gets or sets a boolean indicating if the outline must be rendered as well
  124216. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  124217. */
  124218. renderOutline: boolean;
  124219. /** @hidden (Backing field) */
  124220. _renderOverlay: boolean;
  124221. /**
  124222. * Gets or sets a boolean indicating if the overlay must be rendered as well
  124223. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  124224. */
  124225. renderOverlay: boolean;
  124226. }
  124227. /**
  124228. * This class is responsible to draw bothe outline/overlay of meshes.
  124229. * It should not be used directly but through the available method on mesh.
  124230. */
  124231. export class OutlineRenderer implements ISceneComponent {
  124232. /**
  124233. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  124234. */
  124235. private static _StencilReference;
  124236. /**
  124237. * The name of the component. Each component must have a unique name.
  124238. */
  124239. name: string;
  124240. /**
  124241. * The scene the component belongs to.
  124242. */
  124243. scene: Scene;
  124244. /**
  124245. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124246. */
  124247. zOffset: number;
  124248. private _engine;
  124249. private _effect;
  124250. private _cachedDefines;
  124251. private _savedDepthWrite;
  124252. /**
  124253. * Instantiates a new outline renderer. (There could be only one per scene).
  124254. * @param scene Defines the scene it belongs to
  124255. */
  124256. constructor(scene: Scene);
  124257. /**
  124258. * Register the component to one instance of a scene.
  124259. */
  124260. register(): void;
  124261. /**
  124262. * Rebuilds the elements related to this component in case of
  124263. * context lost for instance.
  124264. */
  124265. rebuild(): void;
  124266. /**
  124267. * Disposes the component and the associated ressources.
  124268. */
  124269. dispose(): void;
  124270. /**
  124271. * Renders the outline in the canvas.
  124272. * @param subMesh Defines the sumesh to render
  124273. * @param batch Defines the batch of meshes in case of instances
  124274. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124275. */
  124276. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124277. /**
  124278. * Returns whether or not the outline renderer is ready for a given submesh.
  124279. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124280. * @param subMesh Defines the submesh to check readyness for
  124281. * @param useInstances Defines wheter wee are trying to render instances or not
  124282. * @returns true if ready otherwise false
  124283. */
  124284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124285. private _beforeRenderingMesh;
  124286. private _afterRenderingMesh;
  124287. }
  124288. }
  124289. declare module BABYLON {
  124290. /**
  124291. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124292. * @see http://doc.babylonjs.com/babylon101/sprites
  124293. */
  124294. export class SpritePackedManager extends SpriteManager {
  124295. /** defines the packed manager's name */
  124296. name: string;
  124297. /**
  124298. * Creates a new sprite manager from a packed sprite sheet
  124299. * @param name defines the manager's name
  124300. * @param imgUrl defines the sprite sheet url
  124301. * @param capacity defines the maximum allowed number of sprites
  124302. * @param scene defines the hosting scene
  124303. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124304. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124305. * @param samplingMode defines the smapling mode to use with spritesheet
  124306. * @param fromPacked set to true; do not alter
  124307. */
  124308. constructor(
  124309. /** defines the packed manager's name */
  124310. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124311. }
  124312. }
  124313. declare module BABYLON {
  124314. /**
  124315. * Defines the list of states available for a task inside a AssetsManager
  124316. */
  124317. export enum AssetTaskState {
  124318. /**
  124319. * Initialization
  124320. */
  124321. INIT = 0,
  124322. /**
  124323. * Running
  124324. */
  124325. RUNNING = 1,
  124326. /**
  124327. * Done
  124328. */
  124329. DONE = 2,
  124330. /**
  124331. * Error
  124332. */
  124333. ERROR = 3
  124334. }
  124335. /**
  124336. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124337. */
  124338. export abstract class AbstractAssetTask {
  124339. /**
  124340. * Task name
  124341. */ name: string;
  124342. /**
  124343. * Callback called when the task is successful
  124344. */
  124345. onSuccess: (task: any) => void;
  124346. /**
  124347. * Callback called when the task is not successful
  124348. */
  124349. onError: (task: any, message?: string, exception?: any) => void;
  124350. /**
  124351. * Creates a new AssetsManager
  124352. * @param name defines the name of the task
  124353. */
  124354. constructor(
  124355. /**
  124356. * Task name
  124357. */ name: string);
  124358. private _isCompleted;
  124359. private _taskState;
  124360. private _errorObject;
  124361. /**
  124362. * Get if the task is completed
  124363. */
  124364. readonly isCompleted: boolean;
  124365. /**
  124366. * Gets the current state of the task
  124367. */
  124368. readonly taskState: AssetTaskState;
  124369. /**
  124370. * Gets the current error object (if task is in error)
  124371. */
  124372. readonly errorObject: {
  124373. message?: string;
  124374. exception?: any;
  124375. };
  124376. /**
  124377. * Internal only
  124378. * @hidden
  124379. */
  124380. _setErrorObject(message?: string, exception?: any): void;
  124381. /**
  124382. * Execute the current task
  124383. * @param scene defines the scene where you want your assets to be loaded
  124384. * @param onSuccess is a callback called when the task is successfully executed
  124385. * @param onError is a callback called if an error occurs
  124386. */
  124387. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124388. /**
  124389. * Execute the current task
  124390. * @param scene defines the scene where you want your assets to be loaded
  124391. * @param onSuccess is a callback called when the task is successfully executed
  124392. * @param onError is a callback called if an error occurs
  124393. */
  124394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124395. /**
  124396. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  124397. * This can be used with failed tasks that have the reason for failure fixed.
  124398. */
  124399. reset(): void;
  124400. private onErrorCallback;
  124401. private onDoneCallback;
  124402. }
  124403. /**
  124404. * Define the interface used by progress events raised during assets loading
  124405. */
  124406. export interface IAssetsProgressEvent {
  124407. /**
  124408. * Defines the number of remaining tasks to process
  124409. */
  124410. remainingCount: number;
  124411. /**
  124412. * Defines the total number of tasks
  124413. */
  124414. totalCount: number;
  124415. /**
  124416. * Defines the task that was just processed
  124417. */
  124418. task: AbstractAssetTask;
  124419. }
  124420. /**
  124421. * Class used to share progress information about assets loading
  124422. */
  124423. export class AssetsProgressEvent implements IAssetsProgressEvent {
  124424. /**
  124425. * Defines the number of remaining tasks to process
  124426. */
  124427. remainingCount: number;
  124428. /**
  124429. * Defines the total number of tasks
  124430. */
  124431. totalCount: number;
  124432. /**
  124433. * Defines the task that was just processed
  124434. */
  124435. task: AbstractAssetTask;
  124436. /**
  124437. * Creates a AssetsProgressEvent
  124438. * @param remainingCount defines the number of remaining tasks to process
  124439. * @param totalCount defines the total number of tasks
  124440. * @param task defines the task that was just processed
  124441. */
  124442. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  124443. }
  124444. /**
  124445. * Define a task used by AssetsManager to load meshes
  124446. */
  124447. export class MeshAssetTask extends AbstractAssetTask {
  124448. /**
  124449. * Defines the name of the task
  124450. */
  124451. name: string;
  124452. /**
  124453. * Defines the list of mesh's names you want to load
  124454. */
  124455. meshesNames: any;
  124456. /**
  124457. * Defines the root url to use as a base to load your meshes and associated resources
  124458. */
  124459. rootUrl: string;
  124460. /**
  124461. * Defines the filename of the scene to load from
  124462. */
  124463. sceneFilename: string;
  124464. /**
  124465. * Gets the list of loaded meshes
  124466. */
  124467. loadedMeshes: Array<AbstractMesh>;
  124468. /**
  124469. * Gets the list of loaded particle systems
  124470. */
  124471. loadedParticleSystems: Array<IParticleSystem>;
  124472. /**
  124473. * Gets the list of loaded skeletons
  124474. */
  124475. loadedSkeletons: Array<Skeleton>;
  124476. /**
  124477. * Gets the list of loaded animation groups
  124478. */
  124479. loadedAnimationGroups: Array<AnimationGroup>;
  124480. /**
  124481. * Callback called when the task is successful
  124482. */
  124483. onSuccess: (task: MeshAssetTask) => void;
  124484. /**
  124485. * Callback called when the task is successful
  124486. */
  124487. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  124488. /**
  124489. * Creates a new MeshAssetTask
  124490. * @param name defines the name of the task
  124491. * @param meshesNames defines the list of mesh's names you want to load
  124492. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  124493. * @param sceneFilename defines the filename of the scene to load from
  124494. */
  124495. constructor(
  124496. /**
  124497. * Defines the name of the task
  124498. */
  124499. name: string,
  124500. /**
  124501. * Defines the list of mesh's names you want to load
  124502. */
  124503. meshesNames: any,
  124504. /**
  124505. * Defines the root url to use as a base to load your meshes and associated resources
  124506. */
  124507. rootUrl: string,
  124508. /**
  124509. * Defines the filename of the scene to load from
  124510. */
  124511. sceneFilename: string);
  124512. /**
  124513. * Execute the current task
  124514. * @param scene defines the scene where you want your assets to be loaded
  124515. * @param onSuccess is a callback called when the task is successfully executed
  124516. * @param onError is a callback called if an error occurs
  124517. */
  124518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124519. }
  124520. /**
  124521. * Define a task used by AssetsManager to load text content
  124522. */
  124523. export class TextFileAssetTask extends AbstractAssetTask {
  124524. /**
  124525. * Defines the name of the task
  124526. */
  124527. name: string;
  124528. /**
  124529. * Defines the location of the file to load
  124530. */
  124531. url: string;
  124532. /**
  124533. * Gets the loaded text string
  124534. */
  124535. text: string;
  124536. /**
  124537. * Callback called when the task is successful
  124538. */
  124539. onSuccess: (task: TextFileAssetTask) => void;
  124540. /**
  124541. * Callback called when the task is successful
  124542. */
  124543. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  124544. /**
  124545. * Creates a new TextFileAssetTask object
  124546. * @param name defines the name of the task
  124547. * @param url defines the location of the file to load
  124548. */
  124549. constructor(
  124550. /**
  124551. * Defines the name of the task
  124552. */
  124553. name: string,
  124554. /**
  124555. * Defines the location of the file to load
  124556. */
  124557. url: string);
  124558. /**
  124559. * Execute the current task
  124560. * @param scene defines the scene where you want your assets to be loaded
  124561. * @param onSuccess is a callback called when the task is successfully executed
  124562. * @param onError is a callback called if an error occurs
  124563. */
  124564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124565. }
  124566. /**
  124567. * Define a task used by AssetsManager to load binary data
  124568. */
  124569. export class BinaryFileAssetTask extends AbstractAssetTask {
  124570. /**
  124571. * Defines the name of the task
  124572. */
  124573. name: string;
  124574. /**
  124575. * Defines the location of the file to load
  124576. */
  124577. url: string;
  124578. /**
  124579. * Gets the lodaded data (as an array buffer)
  124580. */
  124581. data: ArrayBuffer;
  124582. /**
  124583. * Callback called when the task is successful
  124584. */
  124585. onSuccess: (task: BinaryFileAssetTask) => void;
  124586. /**
  124587. * Callback called when the task is successful
  124588. */
  124589. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  124590. /**
  124591. * Creates a new BinaryFileAssetTask object
  124592. * @param name defines the name of the new task
  124593. * @param url defines the location of the file to load
  124594. */
  124595. constructor(
  124596. /**
  124597. * Defines the name of the task
  124598. */
  124599. name: string,
  124600. /**
  124601. * Defines the location of the file to load
  124602. */
  124603. url: string);
  124604. /**
  124605. * Execute the current task
  124606. * @param scene defines the scene where you want your assets to be loaded
  124607. * @param onSuccess is a callback called when the task is successfully executed
  124608. * @param onError is a callback called if an error occurs
  124609. */
  124610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124611. }
  124612. /**
  124613. * Define a task used by AssetsManager to load images
  124614. */
  124615. export class ImageAssetTask extends AbstractAssetTask {
  124616. /**
  124617. * Defines the name of the task
  124618. */
  124619. name: string;
  124620. /**
  124621. * Defines the location of the image to load
  124622. */
  124623. url: string;
  124624. /**
  124625. * Gets the loaded images
  124626. */
  124627. image: HTMLImageElement;
  124628. /**
  124629. * Callback called when the task is successful
  124630. */
  124631. onSuccess: (task: ImageAssetTask) => void;
  124632. /**
  124633. * Callback called when the task is successful
  124634. */
  124635. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  124636. /**
  124637. * Creates a new ImageAssetTask
  124638. * @param name defines the name of the task
  124639. * @param url defines the location of the image to load
  124640. */
  124641. constructor(
  124642. /**
  124643. * Defines the name of the task
  124644. */
  124645. name: string,
  124646. /**
  124647. * Defines the location of the image to load
  124648. */
  124649. url: string);
  124650. /**
  124651. * Execute the current task
  124652. * @param scene defines the scene where you want your assets to be loaded
  124653. * @param onSuccess is a callback called when the task is successfully executed
  124654. * @param onError is a callback called if an error occurs
  124655. */
  124656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124657. }
  124658. /**
  124659. * Defines the interface used by texture loading tasks
  124660. */
  124661. export interface ITextureAssetTask<TEX extends BaseTexture> {
  124662. /**
  124663. * Gets the loaded texture
  124664. */
  124665. texture: TEX;
  124666. }
  124667. /**
  124668. * Define a task used by AssetsManager to load 2D textures
  124669. */
  124670. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  124671. /**
  124672. * Defines the name of the task
  124673. */
  124674. name: string;
  124675. /**
  124676. * Defines the location of the file to load
  124677. */
  124678. url: string;
  124679. /**
  124680. * Defines if mipmap should not be generated (default is false)
  124681. */
  124682. noMipmap?: boolean | undefined;
  124683. /**
  124684. * Defines if texture must be inverted on Y axis (default is false)
  124685. */
  124686. invertY?: boolean | undefined;
  124687. /**
  124688. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124689. */
  124690. samplingMode: number;
  124691. /**
  124692. * Gets the loaded texture
  124693. */
  124694. texture: Texture;
  124695. /**
  124696. * Callback called when the task is successful
  124697. */
  124698. onSuccess: (task: TextureAssetTask) => void;
  124699. /**
  124700. * Callback called when the task is successful
  124701. */
  124702. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  124703. /**
  124704. * Creates a new TextureAssetTask object
  124705. * @param name defines the name of the task
  124706. * @param url defines the location of the file to load
  124707. * @param noMipmap defines if mipmap should not be generated (default is false)
  124708. * @param invertY defines if texture must be inverted on Y axis (default is false)
  124709. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124710. */
  124711. constructor(
  124712. /**
  124713. * Defines the name of the task
  124714. */
  124715. name: string,
  124716. /**
  124717. * Defines the location of the file to load
  124718. */
  124719. url: string,
  124720. /**
  124721. * Defines if mipmap should not be generated (default is false)
  124722. */
  124723. noMipmap?: boolean | undefined,
  124724. /**
  124725. * Defines if texture must be inverted on Y axis (default is false)
  124726. */
  124727. invertY?: boolean | undefined,
  124728. /**
  124729. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124730. */
  124731. samplingMode?: number);
  124732. /**
  124733. * Execute the current task
  124734. * @param scene defines the scene where you want your assets to be loaded
  124735. * @param onSuccess is a callback called when the task is successfully executed
  124736. * @param onError is a callback called if an error occurs
  124737. */
  124738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124739. }
  124740. /**
  124741. * Define a task used by AssetsManager to load cube textures
  124742. */
  124743. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  124744. /**
  124745. * Defines the name of the task
  124746. */
  124747. name: string;
  124748. /**
  124749. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124750. */
  124751. url: string;
  124752. /**
  124753. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124754. */
  124755. extensions?: string[] | undefined;
  124756. /**
  124757. * Defines if mipmaps should not be generated (default is false)
  124758. */
  124759. noMipmap?: boolean | undefined;
  124760. /**
  124761. * Defines the explicit list of files (undefined by default)
  124762. */
  124763. files?: string[] | undefined;
  124764. /**
  124765. * Gets the loaded texture
  124766. */
  124767. texture: CubeTexture;
  124768. /**
  124769. * Callback called when the task is successful
  124770. */
  124771. onSuccess: (task: CubeTextureAssetTask) => void;
  124772. /**
  124773. * Callback called when the task is successful
  124774. */
  124775. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  124776. /**
  124777. * Creates a new CubeTextureAssetTask
  124778. * @param name defines the name of the task
  124779. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124780. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124782. * @param files defines the explicit list of files (undefined by default)
  124783. */
  124784. constructor(
  124785. /**
  124786. * Defines the name of the task
  124787. */
  124788. name: string,
  124789. /**
  124790. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124791. */
  124792. url: string,
  124793. /**
  124794. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124795. */
  124796. extensions?: string[] | undefined,
  124797. /**
  124798. * Defines if mipmaps should not be generated (default is false)
  124799. */
  124800. noMipmap?: boolean | undefined,
  124801. /**
  124802. * Defines the explicit list of files (undefined by default)
  124803. */
  124804. files?: string[] | undefined);
  124805. /**
  124806. * Execute the current task
  124807. * @param scene defines the scene where you want your assets to be loaded
  124808. * @param onSuccess is a callback called when the task is successfully executed
  124809. * @param onError is a callback called if an error occurs
  124810. */
  124811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124812. }
  124813. /**
  124814. * Define a task used by AssetsManager to load HDR cube textures
  124815. */
  124816. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  124817. /**
  124818. * Defines the name of the task
  124819. */
  124820. name: string;
  124821. /**
  124822. * Defines the location of the file to load
  124823. */
  124824. url: string;
  124825. /**
  124826. * Defines the desired size (the more it increases the longer the generation will be)
  124827. */
  124828. size: number;
  124829. /**
  124830. * Defines if mipmaps should not be generated (default is false)
  124831. */
  124832. noMipmap: boolean;
  124833. /**
  124834. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124835. */
  124836. generateHarmonics: boolean;
  124837. /**
  124838. * 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)
  124839. */
  124840. gammaSpace: boolean;
  124841. /**
  124842. * Internal Use Only
  124843. */
  124844. reserved: boolean;
  124845. /**
  124846. * Gets the loaded texture
  124847. */
  124848. texture: HDRCubeTexture;
  124849. /**
  124850. * Callback called when the task is successful
  124851. */
  124852. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  124853. /**
  124854. * Callback called when the task is successful
  124855. */
  124856. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  124857. /**
  124858. * Creates a new HDRCubeTextureAssetTask object
  124859. * @param name defines the name of the task
  124860. * @param url defines the location of the file to load
  124861. * @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.
  124862. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124863. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124864. * @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)
  124865. * @param reserved Internal use only
  124866. */
  124867. constructor(
  124868. /**
  124869. * Defines the name of the task
  124870. */
  124871. name: string,
  124872. /**
  124873. * Defines the location of the file to load
  124874. */
  124875. url: string,
  124876. /**
  124877. * Defines the desired size (the more it increases the longer the generation will be)
  124878. */
  124879. size: number,
  124880. /**
  124881. * Defines if mipmaps should not be generated (default is false)
  124882. */
  124883. noMipmap?: boolean,
  124884. /**
  124885. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124886. */
  124887. generateHarmonics?: boolean,
  124888. /**
  124889. * 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)
  124890. */
  124891. gammaSpace?: boolean,
  124892. /**
  124893. * Internal Use Only
  124894. */
  124895. reserved?: boolean);
  124896. /**
  124897. * Execute the current task
  124898. * @param scene defines the scene where you want your assets to be loaded
  124899. * @param onSuccess is a callback called when the task is successfully executed
  124900. * @param onError is a callback called if an error occurs
  124901. */
  124902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124903. }
  124904. /**
  124905. * Define a task used by AssetsManager to load Equirectangular cube textures
  124906. */
  124907. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124908. /**
  124909. * Defines the name of the task
  124910. */
  124911. name: string;
  124912. /**
  124913. * Defines the location of the file to load
  124914. */
  124915. url: string;
  124916. /**
  124917. * Defines the desired size (the more it increases the longer the generation will be)
  124918. */
  124919. size: number;
  124920. /**
  124921. * Defines if mipmaps should not be generated (default is false)
  124922. */
  124923. noMipmap: boolean;
  124924. /**
  124925. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124926. * but the standard material would require them in Gamma space) (default is true)
  124927. */
  124928. gammaSpace: boolean;
  124929. /**
  124930. * Gets the loaded texture
  124931. */
  124932. texture: EquiRectangularCubeTexture;
  124933. /**
  124934. * Callback called when the task is successful
  124935. */
  124936. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124937. /**
  124938. * Callback called when the task is successful
  124939. */
  124940. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124941. /**
  124942. * Creates a new EquiRectangularCubeTextureAssetTask object
  124943. * @param name defines the name of the task
  124944. * @param url defines the location of the file to load
  124945. * @param size defines the desired size (the more it increases the longer the generation will be)
  124946. * If the size is omitted this implies you are using a preprocessed cubemap.
  124947. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124948. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124949. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124950. * (default is true)
  124951. */
  124952. constructor(
  124953. /**
  124954. * Defines the name of the task
  124955. */
  124956. name: string,
  124957. /**
  124958. * Defines the location of the file to load
  124959. */
  124960. url: string,
  124961. /**
  124962. * Defines the desired size (the more it increases the longer the generation will be)
  124963. */
  124964. size: number,
  124965. /**
  124966. * Defines if mipmaps should not be generated (default is false)
  124967. */
  124968. noMipmap?: boolean,
  124969. /**
  124970. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124971. * but the standard material would require them in Gamma space) (default is true)
  124972. */
  124973. gammaSpace?: boolean);
  124974. /**
  124975. * Execute the current task
  124976. * @param scene defines the scene where you want your assets to be loaded
  124977. * @param onSuccess is a callback called when the task is successfully executed
  124978. * @param onError is a callback called if an error occurs
  124979. */
  124980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124981. }
  124982. /**
  124983. * This class can be used to easily import assets into a scene
  124984. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124985. */
  124986. export class AssetsManager {
  124987. private _scene;
  124988. private _isLoading;
  124989. protected _tasks: AbstractAssetTask[];
  124990. protected _waitingTasksCount: number;
  124991. protected _totalTasksCount: number;
  124992. /**
  124993. * Callback called when all tasks are processed
  124994. */
  124995. onFinish: (tasks: AbstractAssetTask[]) => void;
  124996. /**
  124997. * Callback called when a task is successful
  124998. */
  124999. onTaskSuccess: (task: AbstractAssetTask) => void;
  125000. /**
  125001. * Callback called when a task had an error
  125002. */
  125003. onTaskError: (task: AbstractAssetTask) => void;
  125004. /**
  125005. * Callback called when a task is done (whatever the result is)
  125006. */
  125007. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  125008. /**
  125009. * Observable called when all tasks are processed
  125010. */
  125011. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  125012. /**
  125013. * Observable called when a task had an error
  125014. */
  125015. onTaskErrorObservable: Observable<AbstractAssetTask>;
  125016. /**
  125017. * Observable called when all tasks were executed
  125018. */
  125019. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  125020. /**
  125021. * Observable called when a task is done (whatever the result is)
  125022. */
  125023. onProgressObservable: Observable<IAssetsProgressEvent>;
  125024. /**
  125025. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  125026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125027. */
  125028. useDefaultLoadingScreen: boolean;
  125029. /**
  125030. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  125031. * when all assets have been downloaded.
  125032. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  125033. */
  125034. autoHideLoadingUI: boolean;
  125035. /**
  125036. * Creates a new AssetsManager
  125037. * @param scene defines the scene to work on
  125038. */
  125039. constructor(scene: Scene);
  125040. /**
  125041. * Add a MeshAssetTask to the list of active tasks
  125042. * @param taskName defines the name of the new task
  125043. * @param meshesNames defines the name of meshes to load
  125044. * @param rootUrl defines the root url to use to locate files
  125045. * @param sceneFilename defines the filename of the scene file
  125046. * @returns a new MeshAssetTask object
  125047. */
  125048. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  125049. /**
  125050. * Add a TextFileAssetTask to the list of active tasks
  125051. * @param taskName defines the name of the new task
  125052. * @param url defines the url of the file to load
  125053. * @returns a new TextFileAssetTask object
  125054. */
  125055. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  125056. /**
  125057. * Add a BinaryFileAssetTask to the list of active tasks
  125058. * @param taskName defines the name of the new task
  125059. * @param url defines the url of the file to load
  125060. * @returns a new BinaryFileAssetTask object
  125061. */
  125062. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  125063. /**
  125064. * Add a ImageAssetTask to the list of active tasks
  125065. * @param taskName defines the name of the new task
  125066. * @param url defines the url of the file to load
  125067. * @returns a new ImageAssetTask object
  125068. */
  125069. addImageTask(taskName: string, url: string): ImageAssetTask;
  125070. /**
  125071. * Add a TextureAssetTask to the list of active tasks
  125072. * @param taskName defines the name of the new task
  125073. * @param url defines the url of the file to load
  125074. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125075. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  125076. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125077. * @returns a new TextureAssetTask object
  125078. */
  125079. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  125080. /**
  125081. * Add a CubeTextureAssetTask to the list of active tasks
  125082. * @param taskName defines the name of the new task
  125083. * @param url defines the url of the file to load
  125084. * @param extensions defines the extension to use to load the cube map (can be null)
  125085. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125086. * @param files defines the list of files to load (can be null)
  125087. * @returns a new CubeTextureAssetTask object
  125088. */
  125089. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  125090. /**
  125091. *
  125092. * Add a HDRCubeTextureAssetTask to the list of active tasks
  125093. * @param taskName defines the name of the new task
  125094. * @param url defines the url of the file to load
  125095. * @param size defines the size you want for the cubemap (can be null)
  125096. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125097. * @param generateHarmonics defines if you want to automatically generate (true by default)
  125098. * @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)
  125099. * @param reserved Internal use only
  125100. * @returns a new HDRCubeTextureAssetTask object
  125101. */
  125102. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  125103. /**
  125104. *
  125105. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  125106. * @param taskName defines the name of the new task
  125107. * @param url defines the url of the file to load
  125108. * @param size defines the size you want for the cubemap (can be null)
  125109. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125110. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125111. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125112. * @returns a new EquiRectangularCubeTextureAssetTask object
  125113. */
  125114. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  125115. /**
  125116. * Remove a task from the assets manager.
  125117. * @param task the task to remove
  125118. */
  125119. removeTask(task: AbstractAssetTask): void;
  125120. private _decreaseWaitingTasksCount;
  125121. private _runTask;
  125122. /**
  125123. * Reset the AssetsManager and remove all tasks
  125124. * @return the current instance of the AssetsManager
  125125. */
  125126. reset(): AssetsManager;
  125127. /**
  125128. * Start the loading process
  125129. * @return the current instance of the AssetsManager
  125130. */
  125131. load(): AssetsManager;
  125132. /**
  125133. * Start the loading process as an async operation
  125134. * @return a promise returning the list of failed tasks
  125135. */
  125136. loadAsync(): Promise<void>;
  125137. }
  125138. }
  125139. declare module BABYLON {
  125140. /**
  125141. * Wrapper class for promise with external resolve and reject.
  125142. */
  125143. export class Deferred<T> {
  125144. /**
  125145. * The promise associated with this deferred object.
  125146. */
  125147. readonly promise: Promise<T>;
  125148. private _resolve;
  125149. private _reject;
  125150. /**
  125151. * The resolve method of the promise associated with this deferred object.
  125152. */
  125153. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  125154. /**
  125155. * The reject method of the promise associated with this deferred object.
  125156. */
  125157. readonly reject: (reason?: any) => void;
  125158. /**
  125159. * Constructor for this deferred object.
  125160. */
  125161. constructor();
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /**
  125166. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  125167. */
  125168. export class MeshExploder {
  125169. private _centerMesh;
  125170. private _meshes;
  125171. private _meshesOrigins;
  125172. private _toCenterVectors;
  125173. private _scaledDirection;
  125174. private _newPosition;
  125175. private _centerPosition;
  125176. /**
  125177. * Explodes meshes from a center mesh.
  125178. * @param meshes The meshes to explode.
  125179. * @param centerMesh The mesh to be center of explosion.
  125180. */
  125181. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  125182. private _setCenterMesh;
  125183. /**
  125184. * Get class name
  125185. * @returns "MeshExploder"
  125186. */
  125187. getClassName(): string;
  125188. /**
  125189. * "Exploded meshes"
  125190. * @returns Array of meshes with the centerMesh at index 0.
  125191. */
  125192. getMeshes(): Array<Mesh>;
  125193. /**
  125194. * Explodes meshes giving a specific direction
  125195. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  125196. */
  125197. explode(direction?: number): void;
  125198. }
  125199. }
  125200. declare module BABYLON {
  125201. /**
  125202. * Class used to help managing file picking and drag'n'drop
  125203. */
  125204. export class FilesInput {
  125205. /**
  125206. * List of files ready to be loaded
  125207. */
  125208. static readonly FilesToLoad: {
  125209. [key: string]: File;
  125210. };
  125211. /**
  125212. * Callback called when a file is processed
  125213. */
  125214. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  125215. private _engine;
  125216. private _currentScene;
  125217. private _sceneLoadedCallback;
  125218. private _progressCallback;
  125219. private _additionalRenderLoopLogicCallback;
  125220. private _textureLoadingCallback;
  125221. private _startingProcessingFilesCallback;
  125222. private _onReloadCallback;
  125223. private _errorCallback;
  125224. private _elementToMonitor;
  125225. private _sceneFileToLoad;
  125226. private _filesToLoad;
  125227. /**
  125228. * Creates a new FilesInput
  125229. * @param engine defines the rendering engine
  125230. * @param scene defines the hosting scene
  125231. * @param sceneLoadedCallback callback called when scene is loaded
  125232. * @param progressCallback callback called to track progress
  125233. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  125234. * @param textureLoadingCallback callback called when a texture is loading
  125235. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  125236. * @param onReloadCallback callback called when a reload is requested
  125237. * @param errorCallback callback call if an error occurs
  125238. */
  125239. 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);
  125240. private _dragEnterHandler;
  125241. private _dragOverHandler;
  125242. private _dropHandler;
  125243. /**
  125244. * Calls this function to listen to drag'n'drop events on a specific DOM element
  125245. * @param elementToMonitor defines the DOM element to track
  125246. */
  125247. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125248. /**
  125249. * Release all associated resources
  125250. */
  125251. dispose(): void;
  125252. private renderFunction;
  125253. private drag;
  125254. private drop;
  125255. private _traverseFolder;
  125256. private _processFiles;
  125257. /**
  125258. * Load files from a drop event
  125259. * @param event defines the drop event to use as source
  125260. */
  125261. loadFiles(event: any): void;
  125262. private _processReload;
  125263. /**
  125264. * Reload the current scene from the loaded files
  125265. */
  125266. reload(): void;
  125267. }
  125268. }
  125269. declare module BABYLON {
  125270. /**
  125271. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125273. */
  125274. export class SceneOptimization {
  125275. /**
  125276. * Defines the priority of this optimization (0 by default which means first in the list)
  125277. */
  125278. priority: number;
  125279. /**
  125280. * Gets a string describing the action executed by the current optimization
  125281. * @returns description string
  125282. */
  125283. getDescription(): string;
  125284. /**
  125285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125286. * @param scene defines the current scene where to apply this optimization
  125287. * @param optimizer defines the current optimizer
  125288. * @returns true if everything that can be done was applied
  125289. */
  125290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125291. /**
  125292. * Creates the SceneOptimization object
  125293. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125294. * @param desc defines the description associated with the optimization
  125295. */
  125296. constructor(
  125297. /**
  125298. * Defines the priority of this optimization (0 by default which means first in the list)
  125299. */
  125300. priority?: number);
  125301. }
  125302. /**
  125303. * Defines an optimization used to reduce the size of render target textures
  125304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125305. */
  125306. export class TextureOptimization extends SceneOptimization {
  125307. /**
  125308. * Defines the priority of this optimization (0 by default which means first in the list)
  125309. */
  125310. priority: number;
  125311. /**
  125312. * 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
  125313. */
  125314. maximumSize: number;
  125315. /**
  125316. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125317. */
  125318. step: number;
  125319. /**
  125320. * Gets a string describing the action executed by the current optimization
  125321. * @returns description string
  125322. */
  125323. getDescription(): string;
  125324. /**
  125325. * Creates the TextureOptimization object
  125326. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125327. * @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
  125328. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125329. */
  125330. constructor(
  125331. /**
  125332. * Defines the priority of this optimization (0 by default which means first in the list)
  125333. */
  125334. priority?: number,
  125335. /**
  125336. * 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
  125337. */
  125338. maximumSize?: number,
  125339. /**
  125340. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125341. */
  125342. step?: number);
  125343. /**
  125344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125345. * @param scene defines the current scene where to apply this optimization
  125346. * @param optimizer defines the current optimizer
  125347. * @returns true if everything that can be done was applied
  125348. */
  125349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125350. }
  125351. /**
  125352. * Defines an optimization used to increase or decrease the rendering resolution
  125353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125354. */
  125355. export class HardwareScalingOptimization extends SceneOptimization {
  125356. /**
  125357. * Defines the priority of this optimization (0 by default which means first in the list)
  125358. */
  125359. priority: number;
  125360. /**
  125361. * Defines the maximum scale to use (2 by default)
  125362. */
  125363. maximumScale: number;
  125364. /**
  125365. * Defines the step to use between two passes (0.5 by default)
  125366. */
  125367. step: number;
  125368. private _currentScale;
  125369. private _directionOffset;
  125370. /**
  125371. * Gets a string describing the action executed by the current optimization
  125372. * @return description string
  125373. */
  125374. getDescription(): string;
  125375. /**
  125376. * Creates the HardwareScalingOptimization object
  125377. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125378. * @param maximumScale defines the maximum scale to use (2 by default)
  125379. * @param step defines the step to use between two passes (0.5 by default)
  125380. */
  125381. constructor(
  125382. /**
  125383. * Defines the priority of this optimization (0 by default which means first in the list)
  125384. */
  125385. priority?: number,
  125386. /**
  125387. * Defines the maximum scale to use (2 by default)
  125388. */
  125389. maximumScale?: number,
  125390. /**
  125391. * Defines the step to use between two passes (0.5 by default)
  125392. */
  125393. step?: number);
  125394. /**
  125395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125396. * @param scene defines the current scene where to apply this optimization
  125397. * @param optimizer defines the current optimizer
  125398. * @returns true if everything that can be done was applied
  125399. */
  125400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125401. }
  125402. /**
  125403. * Defines an optimization used to remove shadows
  125404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125405. */
  125406. export class ShadowsOptimization extends SceneOptimization {
  125407. /**
  125408. * Gets a string describing the action executed by the current optimization
  125409. * @return description string
  125410. */
  125411. getDescription(): string;
  125412. /**
  125413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125414. * @param scene defines the current scene where to apply this optimization
  125415. * @param optimizer defines the current optimizer
  125416. * @returns true if everything that can be done was applied
  125417. */
  125418. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125419. }
  125420. /**
  125421. * Defines an optimization used to turn post-processes off
  125422. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125423. */
  125424. export class PostProcessesOptimization extends SceneOptimization {
  125425. /**
  125426. * Gets a string describing the action executed by the current optimization
  125427. * @return description string
  125428. */
  125429. getDescription(): string;
  125430. /**
  125431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125432. * @param scene defines the current scene where to apply this optimization
  125433. * @param optimizer defines the current optimizer
  125434. * @returns true if everything that can be done was applied
  125435. */
  125436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125437. }
  125438. /**
  125439. * Defines an optimization used to turn lens flares off
  125440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125441. */
  125442. export class LensFlaresOptimization extends SceneOptimization {
  125443. /**
  125444. * Gets a string describing the action executed by the current optimization
  125445. * @return description string
  125446. */
  125447. getDescription(): string;
  125448. /**
  125449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125450. * @param scene defines the current scene where to apply this optimization
  125451. * @param optimizer defines the current optimizer
  125452. * @returns true if everything that can be done was applied
  125453. */
  125454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125455. }
  125456. /**
  125457. * Defines an optimization based on user defined callback.
  125458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125459. */
  125460. export class CustomOptimization extends SceneOptimization {
  125461. /**
  125462. * Callback called to apply the custom optimization.
  125463. */
  125464. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  125465. /**
  125466. * Callback called to get custom description
  125467. */
  125468. onGetDescription: () => string;
  125469. /**
  125470. * Gets a string describing the action executed by the current optimization
  125471. * @returns description string
  125472. */
  125473. getDescription(): string;
  125474. /**
  125475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125476. * @param scene defines the current scene where to apply this optimization
  125477. * @param optimizer defines the current optimizer
  125478. * @returns true if everything that can be done was applied
  125479. */
  125480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125481. }
  125482. /**
  125483. * Defines an optimization used to turn particles off
  125484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125485. */
  125486. export class ParticlesOptimization extends SceneOptimization {
  125487. /**
  125488. * Gets a string describing the action executed by the current optimization
  125489. * @return description string
  125490. */
  125491. getDescription(): string;
  125492. /**
  125493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125494. * @param scene defines the current scene where to apply this optimization
  125495. * @param optimizer defines the current optimizer
  125496. * @returns true if everything that can be done was applied
  125497. */
  125498. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125499. }
  125500. /**
  125501. * Defines an optimization used to turn render targets off
  125502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125503. */
  125504. export class RenderTargetsOptimization extends SceneOptimization {
  125505. /**
  125506. * Gets a string describing the action executed by the current optimization
  125507. * @return description string
  125508. */
  125509. getDescription(): string;
  125510. /**
  125511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125512. * @param scene defines the current scene where to apply this optimization
  125513. * @param optimizer defines the current optimizer
  125514. * @returns true if everything that can be done was applied
  125515. */
  125516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125517. }
  125518. /**
  125519. * Defines an optimization used to merge meshes with compatible materials
  125520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125521. */
  125522. export class MergeMeshesOptimization extends SceneOptimization {
  125523. private static _UpdateSelectionTree;
  125524. /**
  125525. * Gets or sets a boolean which defines if optimization octree has to be updated
  125526. */
  125527. /**
  125528. * Gets or sets a boolean which defines if optimization octree has to be updated
  125529. */
  125530. static UpdateSelectionTree: boolean;
  125531. /**
  125532. * Gets a string describing the action executed by the current optimization
  125533. * @return description string
  125534. */
  125535. getDescription(): string;
  125536. private _canBeMerged;
  125537. /**
  125538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125539. * @param scene defines the current scene where to apply this optimization
  125540. * @param optimizer defines the current optimizer
  125541. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  125542. * @returns true if everything that can be done was applied
  125543. */
  125544. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  125545. }
  125546. /**
  125547. * Defines a list of options used by SceneOptimizer
  125548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125549. */
  125550. export class SceneOptimizerOptions {
  125551. /**
  125552. * Defines the target frame rate to reach (60 by default)
  125553. */
  125554. targetFrameRate: number;
  125555. /**
  125556. * Defines the interval between two checkes (2000ms by default)
  125557. */
  125558. trackerDuration: number;
  125559. /**
  125560. * Gets the list of optimizations to apply
  125561. */
  125562. optimizations: SceneOptimization[];
  125563. /**
  125564. * Creates a new list of options used by SceneOptimizer
  125565. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  125566. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  125567. */
  125568. constructor(
  125569. /**
  125570. * Defines the target frame rate to reach (60 by default)
  125571. */
  125572. targetFrameRate?: number,
  125573. /**
  125574. * Defines the interval between two checkes (2000ms by default)
  125575. */
  125576. trackerDuration?: number);
  125577. /**
  125578. * Add a new optimization
  125579. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  125580. * @returns the current SceneOptimizerOptions
  125581. */
  125582. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  125583. /**
  125584. * Add a new custom optimization
  125585. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  125586. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  125587. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125588. * @returns the current SceneOptimizerOptions
  125589. */
  125590. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  125591. /**
  125592. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  125593. * @param targetFrameRate defines the target frame rate (60 by default)
  125594. * @returns a SceneOptimizerOptions object
  125595. */
  125596. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125597. /**
  125598. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  125599. * @param targetFrameRate defines the target frame rate (60 by default)
  125600. * @returns a SceneOptimizerOptions object
  125601. */
  125602. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125603. /**
  125604. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  125605. * @param targetFrameRate defines the target frame rate (60 by default)
  125606. * @returns a SceneOptimizerOptions object
  125607. */
  125608. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125609. }
  125610. /**
  125611. * Class used to run optimizations in order to reach a target frame rate
  125612. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125613. */
  125614. export class SceneOptimizer implements IDisposable {
  125615. private _isRunning;
  125616. private _options;
  125617. private _scene;
  125618. private _currentPriorityLevel;
  125619. private _targetFrameRate;
  125620. private _trackerDuration;
  125621. private _currentFrameRate;
  125622. private _sceneDisposeObserver;
  125623. private _improvementMode;
  125624. /**
  125625. * Defines an observable called when the optimizer reaches the target frame rate
  125626. */
  125627. onSuccessObservable: Observable<SceneOptimizer>;
  125628. /**
  125629. * Defines an observable called when the optimizer enables an optimization
  125630. */
  125631. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  125632. /**
  125633. * Defines an observable called when the optimizer is not able to reach the target frame rate
  125634. */
  125635. onFailureObservable: Observable<SceneOptimizer>;
  125636. /**
  125637. * Gets a boolean indicating if the optimizer is in improvement mode
  125638. */
  125639. readonly isInImprovementMode: boolean;
  125640. /**
  125641. * Gets the current priority level (0 at start)
  125642. */
  125643. readonly currentPriorityLevel: number;
  125644. /**
  125645. * Gets the current frame rate checked by the SceneOptimizer
  125646. */
  125647. readonly currentFrameRate: number;
  125648. /**
  125649. * Gets or sets the current target frame rate (60 by default)
  125650. */
  125651. /**
  125652. * Gets or sets the current target frame rate (60 by default)
  125653. */
  125654. targetFrameRate: number;
  125655. /**
  125656. * Gets or sets the current interval between two checks (every 2000ms by default)
  125657. */
  125658. /**
  125659. * Gets or sets the current interval between two checks (every 2000ms by default)
  125660. */
  125661. trackerDuration: number;
  125662. /**
  125663. * Gets the list of active optimizations
  125664. */
  125665. readonly optimizations: SceneOptimization[];
  125666. /**
  125667. * Creates a new SceneOptimizer
  125668. * @param scene defines the scene to work on
  125669. * @param options defines the options to use with the SceneOptimizer
  125670. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  125671. * @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)
  125672. */
  125673. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  125674. /**
  125675. * Stops the current optimizer
  125676. */
  125677. stop(): void;
  125678. /**
  125679. * Reset the optimizer to initial step (current priority level = 0)
  125680. */
  125681. reset(): void;
  125682. /**
  125683. * Start the optimizer. By default it will try to reach a specific framerate
  125684. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  125685. */
  125686. start(): void;
  125687. private _checkCurrentState;
  125688. /**
  125689. * Release all resources
  125690. */
  125691. dispose(): void;
  125692. /**
  125693. * Helper function to create a SceneOptimizer with one single line of code
  125694. * @param scene defines the scene to work on
  125695. * @param options defines the options to use with the SceneOptimizer
  125696. * @param onSuccess defines a callback to call on success
  125697. * @param onFailure defines a callback to call on failure
  125698. * @returns the new SceneOptimizer object
  125699. */
  125700. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  125701. }
  125702. }
  125703. declare module BABYLON {
  125704. /**
  125705. * Class used to serialize a scene into a string
  125706. */
  125707. export class SceneSerializer {
  125708. /**
  125709. * Clear cache used by a previous serialization
  125710. */
  125711. static ClearCache(): void;
  125712. /**
  125713. * Serialize a scene into a JSON compatible object
  125714. * @param scene defines the scene to serialize
  125715. * @returns a JSON compatible object
  125716. */
  125717. static Serialize(scene: Scene): any;
  125718. /**
  125719. * Serialize a mesh into a JSON compatible object
  125720. * @param toSerialize defines the mesh to serialize
  125721. * @param withParents defines if parents must be serialized as well
  125722. * @param withChildren defines if children must be serialized as well
  125723. * @returns a JSON compatible object
  125724. */
  125725. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  125726. }
  125727. }
  125728. declare module BABYLON {
  125729. /**
  125730. * Class used to host texture specific utilities
  125731. */
  125732. export class TextureTools {
  125733. /**
  125734. * Uses the GPU to create a copy texture rescaled at a given size
  125735. * @param texture Texture to copy from
  125736. * @param width defines the desired width
  125737. * @param height defines the desired height
  125738. * @param useBilinearMode defines if bilinear mode has to be used
  125739. * @return the generated texture
  125740. */
  125741. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  125742. }
  125743. }
  125744. declare module BABYLON {
  125745. /**
  125746. * This represents the different options available for the video capture.
  125747. */
  125748. export interface VideoRecorderOptions {
  125749. /** Defines the mime type of the video. */
  125750. mimeType: string;
  125751. /** Defines the FPS the video should be recorded at. */
  125752. fps: number;
  125753. /** Defines the chunk size for the recording data. */
  125754. recordChunckSize: number;
  125755. /** The audio tracks to attach to the recording. */
  125756. audioTracks?: MediaStreamTrack[];
  125757. }
  125758. /**
  125759. * This can help with recording videos from BabylonJS.
  125760. * This is based on the available WebRTC functionalities of the browser.
  125761. *
  125762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  125763. */
  125764. export class VideoRecorder {
  125765. private static readonly _defaultOptions;
  125766. /**
  125767. * Returns whether or not the VideoRecorder is available in your browser.
  125768. * @param engine Defines the Babylon Engine.
  125769. * @returns true if supported otherwise false.
  125770. */
  125771. static IsSupported(engine: Engine): boolean;
  125772. private readonly _options;
  125773. private _canvas;
  125774. private _mediaRecorder;
  125775. private _recordedChunks;
  125776. private _fileName;
  125777. private _resolve;
  125778. private _reject;
  125779. /**
  125780. * True when a recording is already in progress.
  125781. */
  125782. readonly isRecording: boolean;
  125783. /**
  125784. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  125785. * @param engine Defines the BabylonJS Engine you wish to record.
  125786. * @param options Defines options that can be used to customize the capture.
  125787. */
  125788. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  125789. /**
  125790. * Stops the current recording before the default capture timeout passed in the startRecording function.
  125791. */
  125792. stopRecording(): void;
  125793. /**
  125794. * Starts recording the canvas for a max duration specified in parameters.
  125795. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  125796. * If null no automatic download will start and you can rely on the promise to get the data back.
  125797. * @param maxDuration Defines the maximum recording time in seconds.
  125798. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  125799. * @return A promise callback at the end of the recording with the video data in Blob.
  125800. */
  125801. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  125802. /**
  125803. * Releases internal resources used during the recording.
  125804. */
  125805. dispose(): void;
  125806. private _handleDataAvailable;
  125807. private _handleError;
  125808. private _handleStop;
  125809. }
  125810. }
  125811. declare module BABYLON {
  125812. /**
  125813. * Class containing a set of static utilities functions for screenshots
  125814. */
  125815. export class ScreenshotTools {
  125816. /**
  125817. * Captures a screenshot of the current rendering
  125818. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125819. * @param engine defines the rendering engine
  125820. * @param camera defines the source camera
  125821. * @param size This parameter can be set to a single number or to an object with the
  125822. * following (optional) properties: precision, width, height. If a single number is passed,
  125823. * it will be used for both width and height. If an object is passed, the screenshot size
  125824. * will be derived from the parameters. The precision property is a multiplier allowing
  125825. * rendering at a higher or lower resolution
  125826. * @param successCallback defines the callback receives a single parameter which contains the
  125827. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125828. * src parameter of an <img> to display it
  125829. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125830. * Check your browser for supported MIME types
  125831. */
  125832. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  125833. /**
  125834. * Captures a screenshot of the current rendering
  125835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125836. * @param engine defines the rendering engine
  125837. * @param camera defines the source camera
  125838. * @param size This parameter can be set to a single number or to an object with the
  125839. * following (optional) properties: precision, width, height. If a single number is passed,
  125840. * it will be used for both width and height. If an object is passed, the screenshot size
  125841. * will be derived from the parameters. The precision property is a multiplier allowing
  125842. * rendering at a higher or lower resolution
  125843. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125844. * Check your browser for supported MIME types
  125845. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125846. * to the src parameter of an <img> to display it
  125847. */
  125848. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  125849. /**
  125850. * Generates an image screenshot from the specified camera.
  125851. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125852. * @param engine The engine to use for rendering
  125853. * @param camera The camera to use for rendering
  125854. * @param size This parameter can be set to a single number or to an object with the
  125855. * following (optional) properties: precision, width, height. If a single number is passed,
  125856. * it will be used for both width and height. If an object is passed, the screenshot size
  125857. * will be derived from the parameters. The precision property is a multiplier allowing
  125858. * rendering at a higher or lower resolution
  125859. * @param successCallback The callback receives a single parameter which contains the
  125860. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125861. * src parameter of an <img> to display it
  125862. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125863. * Check your browser for supported MIME types
  125864. * @param samples Texture samples (default: 1)
  125865. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125866. * @param fileName A name for for the downloaded file.
  125867. */
  125868. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  125869. /**
  125870. * Generates an image screenshot from the specified camera.
  125871. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125872. * @param engine The engine to use for rendering
  125873. * @param camera The camera to use for rendering
  125874. * @param size This parameter can be set to a single number or to an object with the
  125875. * following (optional) properties: precision, width, height. If a single number is passed,
  125876. * it will be used for both width and height. If an object is passed, the screenshot size
  125877. * will be derived from the parameters. The precision property is a multiplier allowing
  125878. * rendering at a higher or lower resolution
  125879. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125880. * Check your browser for supported MIME types
  125881. * @param samples Texture samples (default: 1)
  125882. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125883. * @param fileName A name for for the downloaded file.
  125884. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125885. * to the src parameter of an <img> to display it
  125886. */
  125887. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125888. /**
  125889. * Gets height and width for screenshot size
  125890. * @private
  125891. */
  125892. private static _getScreenshotSize;
  125893. }
  125894. }
  125895. declare module BABYLON {
  125896. /**
  125897. * A cursor which tracks a point on a path
  125898. */
  125899. export class PathCursor {
  125900. private path;
  125901. /**
  125902. * Stores path cursor callbacks for when an onchange event is triggered
  125903. */
  125904. private _onchange;
  125905. /**
  125906. * The value of the path cursor
  125907. */
  125908. value: number;
  125909. /**
  125910. * The animation array of the path cursor
  125911. */
  125912. animations: Animation[];
  125913. /**
  125914. * Initializes the path cursor
  125915. * @param path The path to track
  125916. */
  125917. constructor(path: Path2);
  125918. /**
  125919. * Gets the cursor point on the path
  125920. * @returns A point on the path cursor at the cursor location
  125921. */
  125922. getPoint(): Vector3;
  125923. /**
  125924. * Moves the cursor ahead by the step amount
  125925. * @param step The amount to move the cursor forward
  125926. * @returns This path cursor
  125927. */
  125928. moveAhead(step?: number): PathCursor;
  125929. /**
  125930. * Moves the cursor behind by the step amount
  125931. * @param step The amount to move the cursor back
  125932. * @returns This path cursor
  125933. */
  125934. moveBack(step?: number): PathCursor;
  125935. /**
  125936. * Moves the cursor by the step amount
  125937. * If the step amount is greater than one, an exception is thrown
  125938. * @param step The amount to move the cursor
  125939. * @returns This path cursor
  125940. */
  125941. move(step: number): PathCursor;
  125942. /**
  125943. * Ensures that the value is limited between zero and one
  125944. * @returns This path cursor
  125945. */
  125946. private ensureLimits;
  125947. /**
  125948. * Runs onchange callbacks on change (used by the animation engine)
  125949. * @returns This path cursor
  125950. */
  125951. private raiseOnChange;
  125952. /**
  125953. * Executes a function on change
  125954. * @param f A path cursor onchange callback
  125955. * @returns This path cursor
  125956. */
  125957. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125958. }
  125959. }
  125960. declare module BABYLON {
  125961. /** @hidden */
  125962. export var blurPixelShader: {
  125963. name: string;
  125964. shader: string;
  125965. };
  125966. }
  125967. declare module BABYLON {
  125968. /** @hidden */
  125969. export var pointCloudVertexDeclaration: {
  125970. name: string;
  125971. shader: string;
  125972. };
  125973. }
  125974. // Mixins
  125975. interface Window {
  125976. mozIndexedDB: IDBFactory;
  125977. webkitIndexedDB: IDBFactory;
  125978. msIndexedDB: IDBFactory;
  125979. webkitURL: typeof URL;
  125980. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125981. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125982. WebGLRenderingContext: WebGLRenderingContext;
  125983. MSGesture: MSGesture;
  125984. CANNON: any;
  125985. AudioContext: AudioContext;
  125986. webkitAudioContext: AudioContext;
  125987. PointerEvent: any;
  125988. Math: Math;
  125989. Uint8Array: Uint8ArrayConstructor;
  125990. Float32Array: Float32ArrayConstructor;
  125991. mozURL: typeof URL;
  125992. msURL: typeof URL;
  125993. VRFrameData: any; // WebVR, from specs 1.1
  125994. DracoDecoderModule: any;
  125995. setImmediate(handler: (...args: any[]) => void): number;
  125996. }
  125997. interface HTMLCanvasElement {
  125998. requestPointerLock(): void;
  125999. msRequestPointerLock?(): void;
  126000. mozRequestPointerLock?(): void;
  126001. webkitRequestPointerLock?(): void;
  126002. /** Track wether a record is in progress */
  126003. isRecording: boolean;
  126004. /** Capture Stream method defined by some browsers */
  126005. captureStream(fps?: number): MediaStream;
  126006. }
  126007. interface CanvasRenderingContext2D {
  126008. msImageSmoothingEnabled: boolean;
  126009. }
  126010. interface MouseEvent {
  126011. mozMovementX: number;
  126012. mozMovementY: number;
  126013. webkitMovementX: number;
  126014. webkitMovementY: number;
  126015. msMovementX: number;
  126016. msMovementY: number;
  126017. }
  126018. interface Navigator {
  126019. mozGetVRDevices: (any: any) => any;
  126020. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126021. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126022. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126023. webkitGetGamepads(): Gamepad[];
  126024. msGetGamepads(): Gamepad[];
  126025. webkitGamepads(): Gamepad[];
  126026. }
  126027. interface HTMLVideoElement {
  126028. mozSrcObject: any;
  126029. }
  126030. interface Math {
  126031. fround(x: number): number;
  126032. imul(a: number, b: number): number;
  126033. }
  126034. interface WebGLRenderingContext {
  126035. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  126036. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  126037. vertexAttribDivisor(index: number, divisor: number): void;
  126038. createVertexArray(): any;
  126039. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  126040. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  126041. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  126042. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  126043. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  126044. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  126045. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  126046. // Queries
  126047. createQuery(): WebGLQuery;
  126048. deleteQuery(query: WebGLQuery): void;
  126049. beginQuery(target: number, query: WebGLQuery): void;
  126050. endQuery(target: number): void;
  126051. getQueryParameter(query: WebGLQuery, pname: number): any;
  126052. getQuery(target: number, pname: number): any;
  126053. MAX_SAMPLES: number;
  126054. RGBA8: number;
  126055. READ_FRAMEBUFFER: number;
  126056. DRAW_FRAMEBUFFER: number;
  126057. UNIFORM_BUFFER: number;
  126058. HALF_FLOAT_OES: number;
  126059. RGBA16F: number;
  126060. RGBA32F: number;
  126061. R32F: number;
  126062. RG32F: number;
  126063. RGB32F: number;
  126064. R16F: number;
  126065. RG16F: number;
  126066. RGB16F: number;
  126067. RED: number;
  126068. RG: number;
  126069. R8: number;
  126070. RG8: number;
  126071. UNSIGNED_INT_24_8: number;
  126072. DEPTH24_STENCIL8: number;
  126073. /* Multiple Render Targets */
  126074. drawBuffers(buffers: number[]): void;
  126075. readBuffer(src: number): void;
  126076. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  126077. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  126078. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  126079. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  126080. // Occlusion Query
  126081. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  126082. ANY_SAMPLES_PASSED: number;
  126083. QUERY_RESULT_AVAILABLE: number;
  126084. QUERY_RESULT: number;
  126085. }
  126086. interface WebGLProgram {
  126087. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  126088. }
  126089. interface EXT_disjoint_timer_query {
  126090. QUERY_COUNTER_BITS_EXT: number;
  126091. TIME_ELAPSED_EXT: number;
  126092. TIMESTAMP_EXT: number;
  126093. GPU_DISJOINT_EXT: number;
  126094. QUERY_RESULT_EXT: number;
  126095. QUERY_RESULT_AVAILABLE_EXT: number;
  126096. queryCounterEXT(query: WebGLQuery, target: number): void;
  126097. createQueryEXT(): WebGLQuery;
  126098. beginQueryEXT(target: number, query: WebGLQuery): void;
  126099. endQueryEXT(target: number): void;
  126100. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  126101. deleteQueryEXT(query: WebGLQuery): void;
  126102. }
  126103. interface WebGLUniformLocation {
  126104. _currentState: any;
  126105. }
  126106. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  126107. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  126108. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  126109. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126110. interface WebGLRenderingContext {
  126111. readonly RASTERIZER_DISCARD: number;
  126112. readonly DEPTH_COMPONENT24: number;
  126113. readonly TEXTURE_3D: number;
  126114. readonly TEXTURE_2D_ARRAY: number;
  126115. readonly TEXTURE_COMPARE_FUNC: number;
  126116. readonly TEXTURE_COMPARE_MODE: number;
  126117. readonly COMPARE_REF_TO_TEXTURE: number;
  126118. readonly TEXTURE_WRAP_R: number;
  126119. readonly HALF_FLOAT: number;
  126120. readonly RGB8: number;
  126121. readonly RED_INTEGER: number;
  126122. readonly RG_INTEGER: number;
  126123. readonly RGB_INTEGER: number;
  126124. readonly RGBA_INTEGER: number;
  126125. readonly R8_SNORM: number;
  126126. readonly RG8_SNORM: number;
  126127. readonly RGB8_SNORM: number;
  126128. readonly RGBA8_SNORM: number;
  126129. readonly R8I: number;
  126130. readonly RG8I: number;
  126131. readonly RGB8I: number;
  126132. readonly RGBA8I: number;
  126133. readonly R8UI: number;
  126134. readonly RG8UI: number;
  126135. readonly RGB8UI: number;
  126136. readonly RGBA8UI: number;
  126137. readonly R16I: number;
  126138. readonly RG16I: number;
  126139. readonly RGB16I: number;
  126140. readonly RGBA16I: number;
  126141. readonly R16UI: number;
  126142. readonly RG16UI: number;
  126143. readonly RGB16UI: number;
  126144. readonly RGBA16UI: number;
  126145. readonly R32I: number;
  126146. readonly RG32I: number;
  126147. readonly RGB32I: number;
  126148. readonly RGBA32I: number;
  126149. readonly R32UI: number;
  126150. readonly RG32UI: number;
  126151. readonly RGB32UI: number;
  126152. readonly RGBA32UI: number;
  126153. readonly RGB10_A2UI: number;
  126154. readonly R11F_G11F_B10F: number;
  126155. readonly RGB9_E5: number;
  126156. readonly RGB10_A2: number;
  126157. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  126158. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  126159. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  126160. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126161. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  126162. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  126163. 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;
  126164. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  126165. readonly TRANSFORM_FEEDBACK: number;
  126166. readonly INTERLEAVED_ATTRIBS: number;
  126167. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  126168. createTransformFeedback(): WebGLTransformFeedback;
  126169. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  126170. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  126171. beginTransformFeedback(primitiveMode: number): void;
  126172. endTransformFeedback(): void;
  126173. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  126174. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126175. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126176. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126177. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  126178. }
  126179. interface ImageBitmap {
  126180. readonly width: number;
  126181. readonly height: number;
  126182. close(): void;
  126183. }
  126184. interface WebGLQuery extends WebGLObject {
  126185. }
  126186. declare var WebGLQuery: {
  126187. prototype: WebGLQuery;
  126188. new(): WebGLQuery;
  126189. };
  126190. interface WebGLSampler extends WebGLObject {
  126191. }
  126192. declare var WebGLSampler: {
  126193. prototype: WebGLSampler;
  126194. new(): WebGLSampler;
  126195. };
  126196. interface WebGLSync extends WebGLObject {
  126197. }
  126198. declare var WebGLSync: {
  126199. prototype: WebGLSync;
  126200. new(): WebGLSync;
  126201. };
  126202. interface WebGLTransformFeedback extends WebGLObject {
  126203. }
  126204. declare var WebGLTransformFeedback: {
  126205. prototype: WebGLTransformFeedback;
  126206. new(): WebGLTransformFeedback;
  126207. };
  126208. interface WebGLVertexArrayObject extends WebGLObject {
  126209. }
  126210. declare var WebGLVertexArrayObject: {
  126211. prototype: WebGLVertexArrayObject;
  126212. new(): WebGLVertexArrayObject;
  126213. };
  126214. // Type definitions for WebVR API
  126215. // Project: https://w3c.github.io/webvr/
  126216. // Definitions by: six a <https://github.com/lostfictions>
  126217. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126218. interface VRDisplay extends EventTarget {
  126219. /**
  126220. * Dictionary of capabilities describing the VRDisplay.
  126221. */
  126222. readonly capabilities: VRDisplayCapabilities;
  126223. /**
  126224. * z-depth defining the far plane of the eye view frustum
  126225. * enables mapping of values in the render target depth
  126226. * attachment to scene coordinates. Initially set to 10000.0.
  126227. */
  126228. depthFar: number;
  126229. /**
  126230. * z-depth defining the near plane of the eye view frustum
  126231. * enables mapping of values in the render target depth
  126232. * attachment to scene coordinates. Initially set to 0.01.
  126233. */
  126234. depthNear: number;
  126235. /**
  126236. * An identifier for this distinct VRDisplay. Used as an
  126237. * association point in the Gamepad API.
  126238. */
  126239. readonly displayId: number;
  126240. /**
  126241. * A display name, a user-readable name identifying it.
  126242. */
  126243. readonly displayName: string;
  126244. readonly isConnected: boolean;
  126245. readonly isPresenting: boolean;
  126246. /**
  126247. * If this VRDisplay supports room-scale experiences, the optional
  126248. * stage attribute contains details on the room-scale parameters.
  126249. */
  126250. readonly stageParameters: VRStageParameters | null;
  126251. /**
  126252. * Passing the value returned by `requestAnimationFrame` to
  126253. * `cancelAnimationFrame` will unregister the callback.
  126254. * @param handle Define the hanle of the request to cancel
  126255. */
  126256. cancelAnimationFrame(handle: number): void;
  126257. /**
  126258. * Stops presenting to the VRDisplay.
  126259. * @returns a promise to know when it stopped
  126260. */
  126261. exitPresent(): Promise<void>;
  126262. /**
  126263. * Return the current VREyeParameters for the given eye.
  126264. * @param whichEye Define the eye we want the parameter for
  126265. * @returns the eye parameters
  126266. */
  126267. getEyeParameters(whichEye: string): VREyeParameters;
  126268. /**
  126269. * Populates the passed VRFrameData with the information required to render
  126270. * the current frame.
  126271. * @param frameData Define the data structure to populate
  126272. * @returns true if ok otherwise false
  126273. */
  126274. getFrameData(frameData: VRFrameData): boolean;
  126275. /**
  126276. * Get the layers currently being presented.
  126277. * @returns the list of VR layers
  126278. */
  126279. getLayers(): VRLayer[];
  126280. /**
  126281. * Return a VRPose containing the future predicted pose of the VRDisplay
  126282. * when the current frame will be presented. The value returned will not
  126283. * change until JavaScript has returned control to the browser.
  126284. *
  126285. * The VRPose will contain the position, orientation, velocity,
  126286. * and acceleration of each of these properties.
  126287. * @returns the pose object
  126288. */
  126289. getPose(): VRPose;
  126290. /**
  126291. * Return the current instantaneous pose of the VRDisplay, with no
  126292. * prediction applied.
  126293. * @returns the current instantaneous pose
  126294. */
  126295. getImmediatePose(): VRPose;
  126296. /**
  126297. * The callback passed to `requestAnimationFrame` will be called
  126298. * any time a new frame should be rendered. When the VRDisplay is
  126299. * presenting the callback will be called at the native refresh
  126300. * rate of the HMD. When not presenting this function acts
  126301. * identically to how window.requestAnimationFrame acts. Content should
  126302. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126303. * asynchronously from other displays and at differing refresh rates.
  126304. * @param callback Define the eaction to run next frame
  126305. * @returns the request handle it
  126306. */
  126307. requestAnimationFrame(callback: FrameRequestCallback): number;
  126308. /**
  126309. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126310. * Repeat calls while already presenting will update the VRLayers being displayed.
  126311. * @param layers Define the list of layer to present
  126312. * @returns a promise to know when the request has been fulfilled
  126313. */
  126314. requestPresent(layers: VRLayer[]): Promise<void>;
  126315. /**
  126316. * Reset the pose for this display, treating its current position and
  126317. * orientation as the "origin/zero" values. VRPose.position,
  126318. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126319. * updated when calling resetPose(). This should be called in only
  126320. * sitting-space experiences.
  126321. */
  126322. resetPose(): void;
  126323. /**
  126324. * The VRLayer provided to the VRDisplay will be captured and presented
  126325. * in the HMD. Calling this function has the same effect on the source
  126326. * canvas as any other operation that uses its source image, and canvases
  126327. * created without preserveDrawingBuffer set to true will be cleared.
  126328. * @param pose Define the pose to submit
  126329. */
  126330. submitFrame(pose?: VRPose): void;
  126331. }
  126332. declare var VRDisplay: {
  126333. prototype: VRDisplay;
  126334. new(): VRDisplay;
  126335. };
  126336. interface VRLayer {
  126337. leftBounds?: number[] | Float32Array | null;
  126338. rightBounds?: number[] | Float32Array | null;
  126339. source?: HTMLCanvasElement | null;
  126340. }
  126341. interface VRDisplayCapabilities {
  126342. readonly canPresent: boolean;
  126343. readonly hasExternalDisplay: boolean;
  126344. readonly hasOrientation: boolean;
  126345. readonly hasPosition: boolean;
  126346. readonly maxLayers: number;
  126347. }
  126348. interface VREyeParameters {
  126349. /** @deprecated */
  126350. readonly fieldOfView: VRFieldOfView;
  126351. readonly offset: Float32Array;
  126352. readonly renderHeight: number;
  126353. readonly renderWidth: number;
  126354. }
  126355. interface VRFieldOfView {
  126356. readonly downDegrees: number;
  126357. readonly leftDegrees: number;
  126358. readonly rightDegrees: number;
  126359. readonly upDegrees: number;
  126360. }
  126361. interface VRFrameData {
  126362. readonly leftProjectionMatrix: Float32Array;
  126363. readonly leftViewMatrix: Float32Array;
  126364. readonly pose: VRPose;
  126365. readonly rightProjectionMatrix: Float32Array;
  126366. readonly rightViewMatrix: Float32Array;
  126367. readonly timestamp: number;
  126368. }
  126369. interface VRPose {
  126370. readonly angularAcceleration: Float32Array | null;
  126371. readonly angularVelocity: Float32Array | null;
  126372. readonly linearAcceleration: Float32Array | null;
  126373. readonly linearVelocity: Float32Array | null;
  126374. readonly orientation: Float32Array | null;
  126375. readonly position: Float32Array | null;
  126376. readonly timestamp: number;
  126377. }
  126378. interface VRStageParameters {
  126379. sittingToStandingTransform?: Float32Array;
  126380. sizeX?: number;
  126381. sizeY?: number;
  126382. }
  126383. interface Navigator {
  126384. getVRDisplays(): Promise<VRDisplay[]>;
  126385. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  126386. }
  126387. interface Window {
  126388. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  126389. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  126390. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  126391. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126392. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126393. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  126394. }
  126395. interface Gamepad {
  126396. readonly displayId: number;
  126397. }
  126398. type XRSessionMode =
  126399. | "inline"
  126400. | "immersive-vr"
  126401. | "immersive-ar";
  126402. type XRReferenceSpaceType =
  126403. | "viewer"
  126404. | "local"
  126405. | "local-floor"
  126406. | "bounded-floor"
  126407. | "unbounded";
  126408. type XREnvironmentBlendMode =
  126409. | "opaque"
  126410. | "additive"
  126411. | "alpha-blend";
  126412. type XRVisibilityState =
  126413. | "visible"
  126414. | "visible-blurred"
  126415. | "hidden";
  126416. type XRHandedness =
  126417. | "none"
  126418. | "left"
  126419. | "right";
  126420. type XRTargetRayMode =
  126421. | "gaze"
  126422. | "tracked-pointer"
  126423. | "screen";
  126424. type XREye =
  126425. | "none"
  126426. | "left"
  126427. | "right";
  126428. interface XRSpace extends EventTarget {
  126429. }
  126430. interface XRRenderState {
  126431. depthNear?: number;
  126432. depthFar?: number;
  126433. inlineVerticalFieldOfView?: number;
  126434. baseLayer?: XRWebGLLayer;
  126435. }
  126436. interface XRInputSource {
  126437. handedness: XRHandedness;
  126438. targetRayMode: XRTargetRayMode;
  126439. targetRaySpace: XRSpace;
  126440. gripSpace: XRSpace | undefined;
  126441. gamepad: Gamepad | undefined;
  126442. profiles: Array<string>;
  126443. }
  126444. interface XRSession {
  126445. addEventListener: Function;
  126446. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126447. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  126448. requestAnimationFrame: Function;
  126449. end(): Promise<void>;
  126450. renderState: XRRenderState;
  126451. inputSources: Array<XRInputSource>;
  126452. }
  126453. interface XRReferenceSpace extends XRSpace {
  126454. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  126455. onreset: any;
  126456. }
  126457. interface XRFrame {
  126458. session: XRSession;
  126459. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  126460. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  126461. }
  126462. interface XRViewerPose extends XRPose {
  126463. views: Array<XRView>;
  126464. }
  126465. interface XRPose {
  126466. transform: XRRigidTransform;
  126467. emulatedPosition: boolean;
  126468. }
  126469. declare var XRWebGLLayer: {
  126470. prototype: XRWebGLLayer;
  126471. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  126472. };
  126473. interface XRWebGLLayer {
  126474. framebuffer: WebGLFramebuffer;
  126475. framebufferWidth: number;
  126476. framebufferHeight: number;
  126477. getViewport: Function;
  126478. }
  126479. interface XRRigidTransform {
  126480. position: DOMPointReadOnly;
  126481. orientation: DOMPointReadOnly;
  126482. matrix: Float32Array;
  126483. inverse: XRRigidTransform;
  126484. }
  126485. interface XRView {
  126486. eye: XREye;
  126487. projectionMatrix: Float32Array;
  126488. transform: XRRigidTransform;
  126489. }
  126490. interface XRInputSourceChangeEvent {
  126491. session: XRSession;
  126492. removed: Array<XRInputSource>;
  126493. added: Array<XRInputSource>;
  126494. }